• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comment tag is xsl file - is it not correct

 
Shoba Ramachandran
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a xsl file with comment tag as below
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:comment>Helooooo</xsl:comment>
<xsl:template match="order">
<xsl:for-each select="*">
<xsl:value-of select="name()"/>
<br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
And my xml file is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="order.xsl"?>
<order number="312597">
<date>2000/1/1</date>
<!-- this is the customer A-->
<customer id="216A">Company A</customer>
<item>
<part-number warehouse="Warehouse 11">E16-25A</part-number>
<description>Production-class widget</description>
<quantity>16</quantity>
</item>
<!-- this is the customer A-->
<customer id="216B">Company B</customer>
<item>
<part-number warehouse="Warehouse 12">E16-25B</part-number>
<description>Production-class widgetA</description>
<quantity>20</quantity>
</item>
</order>
When I try to execute it, says this error
Keyword xsl:stylesheet may not contain xsl:comment.
Is comment tag not allowed in xsl file?
Thanks
Shoba
 
Srikanth Vrudhula
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You are getting the error because, the <xsl:comment> element is always used within a template body.
Your order.xsl file should be like
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="order">
<xsl:comment>Helooooo</xsl:comment>
<xsl:for-each select="*">
<xsl:value-of select="name()"/>
<br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Now you wouldn't get the error "Keyword xsl:stylesheet may not contain xsl:comment.".
Srikanth
divine India Ltd
Mail id: srikanth.vrudhula@divine.com
 
Shoba Ramachandran
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, Srikanth.
Shoba
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic