Re: parse-xml-fragment() Fails in Saxon 9.5 but not in 9.8

Martin Honnen <[email protected]> Fri, 15 Jan 2021 20:15:01 +0100
Newsgroups gmane.text.xml.saxon.help
Organization Liberty Development
Message-ID <[email protected]>
On 15.01.2021 18:03, Eliot Kimber wrote:
> I realize this is another "help me with a version you never want to think about again question" but I have to ask it.
>
> Per my recent post on the XSLT list, I'm using saxon:parse-pseudo-attribute() function to get the value of an Oxygen delete PI @content attribute, which contains escaped XML markup.
>
> Using this code:
>
> <xsl:variable name="rawMarkup" as="xs:string" select="saxon:parse-pseudo-attribute('content')"/>
> <xsl:variable name="deletedMarkup" as="element">
>    <deletedMarkup xmlns="">
>     <xsl:sequence select="parse-xml-fragment($rawMarkup)"/>
>    </deletedMarkup>
> </xsl:variable>
>
> <xsl:apply-templates select="$deletedMarkup" mode="handle-deleted-markup"/>
>
> it works perfectly with Saxon 9.8.
>
> However, with Saxon 9.5 I get these errors:
>
> Error reported by XML parser processing
> file:/home/kimberw/workspace/nbs/src/xslt/gaonb-pe/preProcessPhase.xsl: Scanner State 24
> not Recognized
> Error on line 109 of preProcessPhase.xsl:
> FODC0006: First argument to parse-xml-fragment() is not a well-formed and
> namespace-well-formed XML fragment. XML parser reported: Error reported by XML parser
>
> With Saxon 9.5 I can write the value of $rawMarkup to a file and see that it is in fact well-formed XML, but of course there's no way that Oxygen would not put well-formed XML here.
>
> Given that Saxon 9.5 is required for this application, any idea if there's any workaround for this particular error?

I am kind of surprised 9.5 supports parse-xml or parse-xml-fragment and
I am not sure where the error comes from.

Does David's suggestion the XSL list to not use the
saxon:parse-pseudo-attribute function but instead throw the value of the
pi as the attribute part of an on the fly constructed element tag with
   parse-xml(parse-xml(concat('&lt;x ',.,'/&gt;'))/x/@content)
perhaps work better?