Jump to content

How do I know if an element is the last of its kind


Recommended Posts

How do I know if an element is the last of its kind in the entire document...For example, I think this gets the last HEADING element in the doc//HEADING[last()] So, If I'm within the HEADING template, how do I basically write:<xsl:if test="self = //HEADING[last()]">.......It seems like //HEADING[last()] is always returning the last heading relative to it's level.----------------Follow-Up: OK... through experimentation, I've proved that //HEADING[last()] is always returing the last element on the first level rather than anywhere in the document. How does one get the last element, regardless of it's level of nesting.

<X>  <B>	<A>1	  <A>2</A>	</A>  </B>  <C>	<D>	   <A>3</A>	</D>  </C></X>

I would suspect that //A[last()] would return A3, but it returns A1.... Why? and how do you generically get to A3.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...