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

Discussion in 'XML' started by Vijay singh, Nov 4, 2004.

  1. Vijay singh

    Vijay singh Guest

    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
    Vijay singh, Nov 4, 2004
    #1
    1. Advertising

  2. Vijay singh wrote:

    > 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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    1
    Views:
    962
    Marrow
    Jul 18, 2003
  2. Cyrille \cns\ Szymanski

    xsl apply-templates select=not(...)

    Cyrille \cns\ Szymanski, Nov 7, 2003, in forum: XML
    Replies:
    4
    Views:
    597
    Cyrille \cns\ Szymanski
    Nov 11, 2003
  3. Sparko
    Replies:
    0
    Views:
    409
    Sparko
    Jul 9, 2004
  4. KJ
    Replies:
    7
    Views:
    573
    Andreas Kraftl
    May 29, 2005
  5. Replies:
    3
    Views:
    1,347
Loading...

Share This Page