0
votes

I need help with my XSLT.

I have an XML with encoded HTML tags with a tag:

input code

Using XmlSpy (Altova) this DOES work:

'<xsl:value-of select="de" disable-output-escaping="yes"/>'

which returns html tags within the data tag.

But executing this XSL on SAXON does not work. The XSL is executed and returns output, but the output-escaping seems to be ignored.

Any ideas?

1
How do you run Saxon exactly? Show us your command line or your Java/C#/etc. code. It will also help if you post the code as readable and copyable text and not as only as images.Martin Honnen
For instance, at xsltfiddle.liberty-development.net/bEzkTdk you can see that e.g. Saxon 9.8 HE supports disable-output-escaping="yes". You will really need to show us more details on how you use Saxon when you say disable-output-escaping is ignored. Make sure Saxon is in charge of serializing the XSLT result, don't expect a tree/node destination to contain the nodes. disable-output-escaping happens only during serialization.Martin Honnen
As an alternative, to not depend on serialization, don't forget that there is an HTML parser implementation github.com/davidcarlisle/web-xslt/blob/master/htmlparse/… in pure XSLT 2 you can use and import and then you can parse the contents of the de elements into nodes you can copy through to the output, even an output tree: xsltfiddle.liberty-development.net/bEzkTdk/1Martin Honnen
@MartinHonnen: Thx for this brilliant hint - that parser helps me a lot, it is exactly what I was looking for!Martin Schmidt

1 Answers

1
votes

The key thing to remember is that disable-output-escaping is an instruction to the serializer, and it has no effect unless the XSLT processor is serializing the output. The most common reason for it "not working" is that the transformation output is going to a destination other than the serializer (for example, a DOM tree). So we need to know how you are running the transformation.

Also related to this, there have been changes to the spec regarding what happens if you use disable-output-escaping while writing to a temporary tree (that is, to a variable).

Processors are allowed to ignore disable-output-escaping entirely, but Saxon doesn't do that, except of course when the output isn't serialized. (That's because "escaping" is a serialization thing, and if you're not serializing, then you're not escaping anything, so there is nothing to disable).