My XSLT stylesheet needs to load an external XML resource for use during the transformation. The external XML is essentially a lookup table needed during the transformation.
This works fine in a normal xsltproc context. I use the xslt document() function to load the XML from a URI:
<xsl:variable name="scProject" select="document('http://somepath/vx_all.xml')" />
Once the XML is available, I can do my lookup like this:
<xsl:attribute name="src">
<xsl:for-each select="$scProject/shfb:Project/shfb:ItemGroup/shfb:Image">
<xsl:if test="$myID=./shfb:ImageId" >
<xsl:value-of select="substring-after(@Include,'Media\')" />
</xsl:if>
</xsl:for-each>
</xsl:attribute>
Unfortunately, I need to execute this XSL transformation in a context in which it is not possible to load the external XML from a URI. Instead, I need to create an <xsl:variable> that contains the XML and that can be used in the same way (e.g. that XSLT will treat as a node not as text.)
tl;dr
The particular context is a Webview VS Code extension. The XSL stylesheet is precompiled for use with the Saxon.js implementation, and the argument to document() is resolved at stylesheet compilation time, not at Webview runtime. My plan is to read the contents of the external XML resource in my extension's TypeScript code and pass it to the XSLT as a parameter, but I can't figure out how to get XSLT to treat this external parameter values as a node instead of xs:text.
parse-xml()
That's embarrassing...