How to get position of parent element - XSL
Posted
by joe
on Stack Overflow
See other posts from Stack Overflow
or by joe
Published on 2010-04-02T16:00:10Z
Indexed on
2010/04/02
16:03 UTC
Read the original article
Hit count: 393
What I wish I could do in xsl is the following, but unfortunatly parent/position() is not valid.
XSL
<xsl:template match="li">
<bullet>
<xsl:apply-templates/>
</bullet>
<!-- todo: if this is the last bullet AND there are no more "p" tags, output footer -->
<xsl:if test="count(ancestor::div/*) = parent/position()">
<footer/>
</xsl:if>
</xsl:template>
XML
<html>
<div>
<p>There is an x number of me</p>
<p>There is an x number of me</p>
<p>There is an x number of me</p>
<ul>
<li>list item</li>
<li>list item</li>
<li>list item</li>
<li>list item</li>
<li>list item</li>
</ul>
</div>
</html>
Anyone have any ideas how to figure out this problem from WITHIN my template match for li?
Thanks!
© Stack Overflow or respective owner