xlst 2.0 seqential analysys of elements

Discussion in 'XML' started by Rolf Kemper, Jul 1, 2011.

  1. Rolf Kemper

    Rolf Kemper Guest

    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
    Rolf Kemper, Jul 1, 2011
    #1
    1. Advertising

  2. > 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/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
    Joe Kesselman, Jul 1, 2011
    #2
    1. Advertising

  3. 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/
    Martin Honnen, Jul 1, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hai Nguyen

    ACCESS -> (XML + XLST) -> to files

    Hai Nguyen, Jan 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    382
    Hai Nguyen
    Jan 11, 2004
  2. ad
    Replies:
    1
    Views:
    1,629
    Teemu Keiski
    Feb 25, 2006
  3. StanH
    Replies:
    0
    Views:
    933
    StanH
    Jul 17, 2003
  4. Pascal Sartoretti

    XLST: is there a formal definition?

    Pascal Sartoretti, Feb 6, 2004, in forum: XML
    Replies:
    4
    Views:
    1,011
    Patrick TJ McPhee
    Feb 7, 2004
  5. Vital Lobachevsky

    Embedding xlst element into html tag

    Vital Lobachevsky, May 8, 2004, in forum: XML
    Replies:
    1
    Views:
    428
    Patrick TJ McPhee
    May 8, 2004
Loading...

Share This Page