Jump to content
Algimka

XSL generates empty document

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...