Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xlst 2.0 seqential analysys of elements

Reply
Thread Tools

xlst 2.0 seqential analysys of elements

 
 
Rolf Kemper
Guest
Posts: n/a
 
      07-01-2011
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
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      07-01-2011
> 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.


--
Joe Kesselman,
http://www.love-song-productions.com...lam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-01-2011
Rolf Kemper wrote:
> 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.




--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use xlst in asp.net? ad ASP .Net 1 02-25-2006 10:42 AM
HOW CAN I USE XLST PRAVEEN MCSD 4 12-20-2004 02:16 PM
XLST: is there a formal definition? Pascal Sartoretti XML 4 02-07-2004 05:52 PM
ACCESS -> (XML + XLST) -> to files Hai Nguyen ASP .Net 3 01-11-2004 06:31 PM
Two XML Files - One XLST Template StanH XML 0 07-17-2003 04:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57