xlst 2.0 seqential analysys of elements

Rolf Kemper

Usenet Archive
Joined
Mar 26, 2003
Messages
35
Reaction score
0
Dear ALL,

I have an xml containing an order of elements which is quite big (Mega Bytes)
Example:
<root>
<e1 />
<e5 />
<e3 />
<e2 />
<e5 />
<e2 />
<e1 />
</root>

What I want to do is to look for a ceratin sequence of elements:
e.g. e5,e2 (e5 must be followed by e2)
e.g. e5,*,e2 (which left out e3)

In a matching template or foreach I have only the current element in scope. A variable used in that scope is re-defined in next match. Hence this does not help. How can this be solved somehow

Any hint is welcome
Rolf
 

Joe Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
1,229
Reaction score
0
What I want to do is to look for a ceratin sequence of elements:

I'd start with the child, preceding-sibling, and/or following-sibling axes and predicates -- most importantly, I suspect, positional predicates.
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Rolf said:
Dear ALL,

I have an xml containing an order of elements which is quite big (Mega Bytes)
Example:
<root>
<e1 />
<e5 />
<e3 />
<e2 />
<e5 />
<e2 />
<e1 />
</root>

What I want to do is to look for a ceratin sequence of elements:
e.g. e5,e2 (e5 must be followed by e2)
e.g. e5,*,e2 (which left out e3)

In a matching template or foreach I have only the current element in scope. A variable used in that scope is re-defined in next match. Hence this does not help. How can this be solved somehow

Doesn't
<xsl:template match="/">
<xsl:if test="root/e5[following-sibling::*[1][self::e2]]"> ... </xsl:if> </xsl:template> do the check for the first type of sequence you asked for? The second would be <xsl:if test="root/e5[following-sibling::*[1] and following-sibling::*[2][self::e2]]">...</xsl:if>

Of course instead of an xsl:if check you could use such expressions in an apply-templates or for-each, depending on what you want to do if you find a sequence.
 

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

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top