Confusion over patterns and expressions

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

    Confusion over patterns and expressions

    Lets say I have some XML like this:

    <AAA>
    <BBB>
    <b1>xx</b1>
    <b2>xxx</b2>
    </BBB>
    <CCC>
    <c1>z</c1>
    </CCC>
    </AAA>

    And I want to write some XSL that will process the last node of the
    root element - in this case <CCC>, ignoring all other nodes - in this
    case <BBB>. I don't know the element names ahead of time so I can't use
    them in the templates.

    So my general question is, how do I write the expressions in the
    select part of the xsl:apply-template element and/or, how do I write
    the match part of the pattern in the xsl:template element?

  • David Carlisle

    #2
    Re: Confusion over patterns and expressions


    <xsl:template match="/*">
    <xsl:apply-templates select="*[last()]"/>
    </xsl:template>

    <xsl:template match="/*/*">
    whatever you want here
    </xsl:template>

    David

    Comment

    Working...