Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

For historic reasons we have a mixture of

<xsl:output method="xml">

and

<xsl:output method="html">

and

<xsl:output method="xhtml">

inside an include-hierarchy of XSL files. Now we want to refactor so all XSL files use the same output method.

In the end we want to produce XHTML-output so I suppose the latter would be the best choice.

But what are the differences between those three output-methods and which would you use for what kind of solution?

Edit: I'm using XSLT 2.0

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
610 views
Welcome To Ask or Share your Answers For Others

1 Answer

HTML will serialize as HTML, so the output may not be well-formed XML. If you are only sending to browsers and don't care about being able to parse as XML then that may work for you.

XML will serialize as XML, so the output will be well-formed, but you may run into some issues with browsers using the output. Small things, like self closing <script /> and <div /> elements. In order to avoid that issue you would have to play games, like adding comments inside of the element (e.g. <script src="someJSFile.js"><!--don't close my script tag --></script>)

If you have an XSLT 2.0 engine and want well formed HTML output without the headache of worrying about how some elements are serialized, then use XHTML.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...