Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on apply template

 
Dhiren Joshi
Ranch Hand
Posts: 463
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">
<xsl:apply-templates/ >
</xsl:template>

<xsl:template match="/test">
<xsl:apply-templates/ >
</xsl:template>

<xsl:template match="AAA">
<DIV style="color urple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="CCC">
<DIV style="color urple">
<xsl:value-of select="name()"/>
<xsl:text> id=</xsl:text>
<xsl:value-of select="@id"/>
</DIV>
</xsl:template>
</xsl:stylesheet>

XML

<?xml version="1.0"?>
<test>

<AAA id='a1' pos='start'>
<BBB id='b1' />
<BBB id='b2' />
</AAA>
<AAA id='a2'>
<BBB id='b3' />
<BBB id='b4' />
<CCC id='c1'>
<DDD id='d1' />
</CCC>
<BBB id='b5'>
<CCC id='c2' />
</BBB>
</AAA>
</test>

a. output will not print CCC attributes
b. Output will only print AAA id
c. Both a and b are correct
d. BBB will be printed.

Please explain ..the anwser. Single select answer

Thanks
Dhiren
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhiren, since you seem to be posting a lot of XML snippets it would be a good thing to use the [CODE][/CODE] UBB tag and check the "Disable smilies in this post" checkbox in the "Options" section of the "Post A Reply/Add New Topic" view.

It would help people to read the snippets you post and thus improve your chances of getting answers...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic