This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

comment tag is xsl file - is it not correct

 
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
 
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
 
I am going to test your electrical conductivity with this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic