XSLT question related to <xsl:template> and <xsl:apply-templates>

V

Vijay singh

Hi

wonder if anybody can clear by doubt


XML file :

<score id="1">
<film>A Little Princess</film>
<composer>Patrick Doyle</composer>
<year>1995</year>
<grade>
<mygrade>100</mygrade>
<vijay>50</vijay>
</grade>
</score>


XSL file 1 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="score">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

Output 1 :

<?xml version="1.0" encoding="utf-8"?>
A Little Princess
Patrick Doyle
1995

100
50

XSL file 2 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="grade">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

Output 2:

<?xml version="1.0" encoding="utf-8"?>
A Little Princess
Patrick Doyle
1995

100
50


Question is why does the ouptput 2 showed top three lines, when I only
matched "grade".

Regards
Vijay
 
M

Martin Honnen

Vijay said:
XML file :

<score id="1">
<film>A Little Princess</film>
<composer>Patrick Doyle</composer>
<year>1995</year>
<grade>
<mygrade>100</mygrade>
<vijay>50</vijay>
</grade>
</score>
XSL file 2 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="grade">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

Output 2:

<?xml version="1.0" encoding="utf-8"?>
A Little Princess
Patrick Doyle
1995

100
50


Question is why does the ouptput 2 showed top three lines, when I only
matched "grade".

There are built-in templates to recursively process the document and to
output text nodes, see
http://www.w3.org/TR/xslt#built-in-rule
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,833
Latest member
BettyeMacf

Latest Threads

Top