Jump to content

XSL generates empty document


Algimka

Recommended Posts

My xslt code generates empty document

Source document:

<root xmlns="http://www.w3schools.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sender="CODE1">
	<general>
		<date>2016-06-15</date>
	</general>
	<document>
		<documentType>ORIGINAL</documentType>
		<documentNumber>123</documentNumber>
	</document>
</root>

Xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" encoding="windows-1251" indent="yes" />

   <xsl:template match="/">
      <xsl:element name="root">
         <xsl:element name="sender">
            <xsl:value-of select="/root/@sender" />
         </xsl:element>

         <xsl:element name="number">
            <xsl:value-of select="/root/document/documentNumber" />
         </xsl:element>

         <xsl:element name="date">
            <xsl:value-of select="/root/general/date" />
         </xsl:element>
      </xsl:element>
   </xsl:template>
</xsl:stylesheet>

But when from source document root tag remove all xmls parameters - everything works fine.

 

How can I solve this problem?

Edited by Algimka
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...