File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Product and Other Certifications and the fly likes Question on apply template Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Question on apply template" Watch "Question on apply template" New topic

Question on apply template

Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
<xsl:stylesheet version='1.0' xmlns:xsl=''>

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

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

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


<?xml version="1.0"?>

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

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

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
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...

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: Question on apply template
It's not a secret anymore!