File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Product and Other Certifications and the fly likes comment tag is xsl file - is it not correct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "comment tag is xsl file - is it not correct" Watch "comment tag is xsl file - is it not correct" New topic
Author

comment tag is xsl file - is it not correct

Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
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

Joined: Apr 25, 2002
Posts: 14
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

Joined: Mar 29, 2001
Posts: 68
Thanks very much, Srikanth.
Shoba
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comment tag is xsl file - is it not correct