|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Node counting in xsl
Given an xml doc like so:
Code:
<root> <a /> <a /> <b /> <a /> <b /> </root> For a given transform of b, I want to be aware of which node it being transformed. So, the xsl template may appear like this: Code:
<xsl:template match="a"> This is an a element. </xsl:template> <xsl:template match="b"> This is b element number: <!-- What? --> </xsl:template> That is, the output would be something like: Code:
This is an a element. This is an a element. This is b element number: 1 This is an a element. This is b element number: 2 That is, the position() function can't be used, since the b nodes are intermixed with the a nodes. Does anyone know a way to do this? -Michael |
|
#2
|
|||
|
|||
|
Thanks. I thought of that though, and I don't see how I can use an iterative loop like that while still preserving the relative order of the a and b nodes.
That is, the loop can easily iterate through all b elements, returning them in order. But I want to be able to preserve the ordering of the original children (both a and b) of the root node, while counting the b nodes. |
|
#3
|
|||
|
|||
|
Hah, excellent. Thanks echolalia, I'll give that a whirl tonight, it should easily be adaptable to the project I'm working on.
Cheers! -Michael |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Node counting in xsl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|