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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vijay singh

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

    Hi

    wonder if anybody can clear by doubt


    XML file :

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


    XSL file 1 :

    <xsl:styleshe et 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:styleshe et 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
  • Martin Honnen

    #2
    Re: XSLT question related to &lt;xsl:templat e&gt; and &lt;xsl:appl y-templates&gt;



    Vijay singh wrote:
    [color=blue]
    > XML file :
    >
    > <score id="1">
    > <film>A Little Princess</film>
    > <composer>Patri ck Doyle</composer>
    > <year>1995</year>
    > <grade>
    > <mygrade>100</mygrade>
    > <vijay>50</vijay>
    > </grade>
    > </score>[/color]
    [color=blue]
    > XSL file 2 :
    >
    > <xsl:styleshe et 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".[/color]

    There are built-in templates to recursively process the document and to
    output text nodes, see
    The World Wide Web Consortium (W3C) is an international community where Member organizations, a full-time staff, and the public work together to develop Web standards.


    --

    Martin Honnen

    Comment

    Working...