Skip to content

Instantly share code, notes, and snippets.

@Robbert
Created June 19, 2017 19:10
Show Gist options
  • Save Robbert/2587d7430f8784c68b827692b631fcd7 to your computer and use it in GitHub Desktop.
Save Robbert/2587d7430f8784c68b827692b631fcd7 to your computer and use it in GitHub Desktop.
XSLT includes in MarkLogic
xquery version "1.0-ml";
declare namespace xsl = "http://www.w3.org/1999/XSL/Transform";
declare namespace local = "urn:local";
declare function local:prepare-stylesheet($uri, $stylesheet)
{
let $void := xdmp:invoke-function(
function ()
{
xdmp:document-insert(
$uri,
$stylesheet
)
},
<options xmlns="xdmp:eval">
<database>{ xdmp:database("Modules") }</database>
<transaction-mode>update-auto-commit</transaction-mode>
</options>
)
return $stylesheet
};
let $stylesheet := document {
<xsl:stylesheet version="2.0">
<xsl:include href="/stylesheet2.xsl"/>
</xsl:stylesheet>
},
$stylesheet2 := document {
<xsl:stylesheet version="2.0">
<xsl:template match="/"><xsl:text>{ current-dateTime() }</xsl:text></xsl:template>
</xsl:stylesheet>
},
$void := local:prepare-stylesheet("/stylesheet.xsl", $stylesheet),
$void := local:prepare-stylesheet("/stylesheet2.xsl", $stylesheet2),
$result := xdmp:xslt-invoke('/stylesheet.xsl', document { <test/> })
return $result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment