Skip to content

Instantly share code, notes, and snippets.

@martin-honnen
Created October 19, 2023 18:22
Show Gist options
  • Select an option

  • Save martin-honnen/f0c75239c6e9b823a560f4ca1bc19472 to your computer and use it in GitHub Desktop.

Select an option

Save martin-honnen/f0c75239c6e9b823a560f4ca1bc19472 to your computer and use it in GitHub Desktop.
collection-uri and base-uri test
<doc>First test XML instance.</doc>
<doc>Second test XML instance.</doc>
<doc>Third test XML instance.</doc>
import saxonche
with saxonche.PySaxonProcessor(license=False) as proc:
print(proc.version)
xsltproc = proc.new_xslt30_processor()
executable = xsltproc.compile_stylesheet(stylesheet_file="document-uri-test1.xsl")
content = executable.call_template_returning_string()
print(f"\ncontent:\n{content}")
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" expand-text="yes">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template name="xsl:initial-template">
<xsl:for-each select="collection('?select=*.(xml|XML)&amp;content-type=application/xml')">
<debug-message>Processing document-uri "{document-uri()}"...base-uri "{base-uri()}"</debug-message>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment