I am trying to use my XSLT code in an online tool [XSLT 1.0 processor]:
http://www.freeformatter.com/xsl-transformer.html
Recently, I had to use xs:dateTimeand therefore started using a tool that uses the XSLT 2.0 processor,
http://xsltransform.net/
Now, when I tried to solve the problem, I see that I get different output for the same XML input in these two processors. The code shown here is not the real code I'm working on; this should mimic the strange exit that I came across.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<book>
<title></title>
</book>
<phone>apple</phone>
</items>
XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:template match="/">
<items><xsl:apply-templates select="items/*" /></items>
</xsl:template>
<xsl:template match="*[not(normalize-space())]" />
<xsl:template match="book">
<newbook><xsl:apply-templates /></newbook>
</xsl:template>
<xsl:template match="title">
<newtitle><xsl:apply-templates /></newtitle>
</xsl:template>
<xsl:template match="phone">
<newphone><xsl:apply-templates /></newphone>
</xsl:template>
</xsl:stylesheet>
Conclusion from http://xsltransform.net/: [Conclusion 1]
<?xml version="1.0" encoding="UTF-8"?>
<items>
<newbook>
<newtitle/>
</newbook>
<newphone>apple</newphone>
</items>
Exit from http://www.freeformatter.com/xsl-transformer.html: [pin 2]
<?xml version="1.0" encoding="UTF-8"?>
<items>
<newphone>apple</newphone>
</items>
XML output 2.
, ?
note: SO: XSL?, .
Edit
, , :
http://xsltransform.net/ output 1
http://www.freeformatter.com/xsl-transformer.html output 2
[02/10/2014] -
, . , , .
<xsl:template match="*[not(normalize-space())]" />
XSLT1, XSLT2. , 2
* 1 - http://xsltransform.net/: *
- @michael.hor257k, ,
<book>. - Saxon-HE 9.5.1.3, 1, , , [@Michael Kay ]
- @Ian Roberts, , .
:
<xsl:template match="*[not(normalize-space())]" priority="2"/>
, Saxon, .