Confusion over patterns and expressions

M

mikea_59

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?
 
D

David Carlisle

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

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

David
 

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

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top