In my XSLT, I have a variable which contains a string. This string contains a fragment of XML. This is coming in programmatically, but its the equivalent of this:
<xsl:variable name="xmlfrag" select="'<foo>this <bar>is</bar> it</foo>'"/>
Is there a way to parse this XML and add it to the output? We're using SAXON for Java.
Use the
saxon:parse()
extension function.The Dimitre solution requires a licensed version of Saxon.
Here is another solution that works also with the free version of Saxon.
I've tried it successfully with Saxon HE 9.5.X.
The inverse process is documented here.
It is about registering a custom extension function with these contents:
You can use this function as follows: