XSLT 2.0 Header Leaks into Transformed XML
Posted
by
user1303797
on Stack Overflow
See other posts from Stack Overflow
or by user1303797
Published on 2012-03-30T17:26:25Z
Indexed on
2012/03/30
17:28 UTC
Read the original article
Hit count: 187
First, a thank you in advance. Second, this is my first post so apologies for any errors or wrongdoings.
I am a noob w/ xml and xslt, and can't seem to figure this out. When I transform some xml using xslt 2.0, some of the headers from the xslt leaks into the new xml. It doesn't seem to do it in xslt 1.0 (granted the xslt is a little different). Here is the xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xml_content>
<feed_name>feed</feed_name>
<feed_info>
<entry_1>
<id>1</id>
<pub_date>1320814800</pub_date>
</entry_1>
</feed_info>
</xml_content>
Here is the xslt:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:output method="xml" indent="yes" />
<xsl:template match="xml_content">
<Records>
<xsl:for-each select="feed_info/entry_1">
<Record>
<ID><xsl:value-of select="id" /></ID>
<PublicationDate><xsl:value-of select='xs:dateTime("1970-01-01T00:00:00") + xs:integer(pub_date) * xs:dayTimeDuration("PT1S")'/></PublicationDate>
</Record>
</xsl:for-each>
</Records>
</xsl:template>
</xsl:stylesheet>
Here is the new xml. Look specifically at the first "Records" element.
<?xml version="1.0" encoding="UTF-8"?>
<Records xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<Record>
<ID>1</ID>
<PublicationDate>2011-11-09T05:00:00</PublicationDate>
</Record>
</Records>
© Stack Overflow or respective owner