This XSLT problem makes no sense to me

Discussion in 'XML' started by Jean-François Michaud, Mar 11, 2008.

  1. Context:

    I'm trying to compare XML tree fragments and I'm doing so by
    outputting the attributes of each element in the tree and outputting
    it to a string then normalizing the strings. Then I'm doing a contains
    of the current string against the following-sibling::* to determine if
    we have duplicates. If we have a duplicate, we move to the next item,
    if there is no duplicate, we output the small tree.

    I'm hitting a completely ridiculous problem that I can't wrap my head
    around. I spend easily 2 hours trying to understand why this happened
    yesterday and I'm about to punch the computer. When I output a string
    that's not directly tied to the logic (or at least apparently not tied
    to the logic), the logic works. When I remove the string output, the
    logic stops working. Argh!

    Here's the XSLT snippet

    <xsl:template match="item-wrapper" mode="string">

    <xsl:variable name="current">
    <xsl:apply-templates mode="string" />
    </xsl:variable>

    <xsl:variable name="rest">
    <xsl:apply-templates select="following-sibling::*"
    mode="string" />
    </xsl:variable>

    <xsl:variable name="current-normalized">
    <xsl:value-of select="normalize-space($current)" />
    </xsl:variable>

    <xsl:variable name="rest-normalized">
    <xsl:value-of select="normalize-space($rest)" />
    </xsl:variable>

    <!-- <fix/> What the hell? -->
    <!-- <xsl:value-of select="$current-normalized"/>-->

    <xsl:choose>
    <xsl:when test="contains($rest-normalized, $current-
    normalized)">
    <duplicate/>
    </xsl:when>
    <xsl:eek:therwise>
    <noproblem/>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    When <xsl:value-of select="$current-normalized"/> is not commented
    out, I get the string representation of the XML tree in a normalized
    form in the output for each item and the correct <duplicate/> and
    <noproblem/> get outputted in the correct location after the
    normalized strings. When I comment out the <xsl:value-of
    select="$current-normalized"/>, the normalized current string, as
    expected, stops being outputted, but all my outputs are <noproblem/>.
    What the hell? What am I missing here?

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 11, 2008
    #1
    1. Advertising

  2. Hard to be certain without seeing a full runnable copy, but this sounds
    more like a bug in your XSLT processor than an expected behavior of XSLT.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Mar 11, 2008
    #2
    1. Advertising

  3. Jean-François Michaud wrote:

    > When <xsl:value-of select="$current-normalized"/> is not commented
    > out, I get the string representation of the XML tree in a normalized
    > form in the output for each item and the correct <duplicate/> and
    > <noproblem/> get outputted in the correct location after the
    > normalized strings. When I comment out the <xsl:value-of
    > select="$current-normalized"/>, the normalized current string, as
    > expected, stops being outputted, but all my outputs are <noproblem/>.
    > What the hell? What am I missing here?


    I am not sure what the problem is, I would first try a second XSLT
    processor to see if the problem is processor specific or not, if not
    then there is certainly a problem with your code.
    Try to isolate the problem and post a minimal but complete XML document
    and stylesheet that allows us to reproduce the problem.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 11, 2008
    #3
  4. On Mar 11, 10:24 am, Joseph Kesselman <>
    wrote:
    > Hard to be certain without seeing a full runnable copy, but this sounds
    > more like a bug in your XSLT processor than an expected behavior of XSLT.
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Thanks much. I thought I was going insane ;-). I tried with SaxonB9
    and I get the same behavior. I'd have to try with Xalan, but I'd have
    to modify the code a bit because Xalan doesn't behave exactly the same
    way Saxon8/B9 does.

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 11, 2008
    #4
  5. On Mar 11, 10:31 am, Martin Honnen <> wrote:
    > Jean-François Michaud wrote:
    > > When <xsl:value-of select="$current-normalized"/> is not commented
    > > out, I get the string representation of the XML tree in a normalized
    > > form in the output for each item and the correct <duplicate/> and
    > > <noproblem/> get outputted in the correct location after the
    > > normalized strings. When I comment out the <xsl:value-of
    > > select="$current-normalized"/>, the normalized current string, as
    > > expected, stops being outputted, but all my outputs are <noproblem/>.
    > > What the hell? What am I missing here?

    >
    > I am not sure what the problem is, I would first try a second XSLT
    > processor to see if the problem is processor specific or not, if not
    > then there is certainly a problem with your code.
    > Try to isolate the problem and post a minimal but complete XML document
    > and stylesheet that allows us to reproduce the problem.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/


    Ya tried SaxonB9. Same behavior. I'd have to try with Xalan but I'd
    first have to modify the code so that it behaves the same way because
    Xalan doesn't behave exactly like Saxon. I'm getting other odd
    behaviors around this piece of code (Saxon) that are definitely not
    expectable XSLT behavior. It looks like Saxon is not able to resolve
    the strings correctly at runtime in this particular case.

    I have to make this work so I'll just implement something else I have
    in mind that's more painful to implement but less likely to fail.

    If I get a second. I'll try to create a reduced set. I didn't want to
    post a lot of code on the newsgroup uselessly.

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 11, 2008
    #5
  6. Jean-François Michaud wrote:
    > On Mar 11, 10:31 am, Martin Honnen <> wrote:
    >> Jean-François Michaud wrote:
    >>> When <xsl:value-of select="$current-normalized"/> is not commented
    >>> out, I get the string representation of the XML tree in a normalized
    >>> form in the output for each item and the correct <duplicate/> and
    >>> <noproblem/> get outputted in the correct location after the
    >>> normalized strings. When I comment out the <xsl:value-of
    >>> select="$current-normalized"/>, the normalized current string, as
    >>> expected, stops being outputted, but all my outputs are <noproblem/>.
    >>> What the hell? What am I missing here?

    >> I am not sure what the problem is, I would first try a second XSLT
    >> processor to see if the problem is processor specific or not, if not
    >> then there is certainly a problem with your code.
    >> Try to isolate the problem and post a minimal but complete XML document
    >> and stylesheet that allows us to reproduce the problem.
    >>
    >> --
    >>
    >> Martin Honnen
    >> http://JavaScript.FAQTs.com/

    >
    > Ya tried SaxonB9. Same behavior. I'd have to try with Xalan but I'd
    > first have to modify the code so that it behaves the same way because
    > Xalan doesn't behave exactly like Saxon.


    If you are using XSLT 2.0 then I would not try to change the stylesheet
    for Xalan to compare Saxon 9 and Xalan, I would rather try another XSLT
    2.0 processor like Gestalt <URL:http://gestalt.sourceforge.net/> or like
    AltovaXML <URL:http://www.altova.com/altovaxml.html>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 11, 2008
    #6
  7. I should have said: ... Or a bug in your data model.

    Can you reduce the problem to a stand-alone stylesheet of just a few
    lines? Does the problem occur when you just run it from a stylesheet and
    an input document using a stand-alone XSLT processor?

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Mar 11, 2008
    #7
  8. On Mar 11, 11:49 am, Joseph Kesselman <>
    wrote:
    > I should have said: ... Or a bug in your data model.
    >
    > Can you reduce the problem to a stand-alone stylesheet of just a few
    > lines? Does the problem occur when you just run it from a stylesheet and
    > an input document using a stand-alone XSLT processor?
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Both the stylesheet and the parser are standalone. I'm rolling the
    testing through a .bat script and the saxon8.jar via command line.

    I reduced the problem to the snippet I sent out. The stylesheet is
    *much* larger. I'd have to spend some time to try and reduce the
    example further and reproduce the problem on a reduced set. I'm
    actually starting to think it might have to do with node-set
    limitations.

    I tried implementing the same end result through a different path I
    had in mind; through string manipulation (string reduction) instead of
    XML tree comparison via string comparison and I'm hitting a really
    stupid out-of-scope limitation when I'm referencing an out of sequence
    element (through a <xsl:for-each select="//whatever">). I'm unable to
    reference values contained in the node-set inside the for-each
    statement, and that, even if I drop the values from the node-set in a
    variable prior to the for-each statement (referencing the variable
    inside the for-each). The variable is always empty.

    I can reference a variable, even if I'm out of sequence in the left
    hand XML tree, only if I'm not playing with node-set values. This
    parser is seriously starting to piss me off.

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 11, 2008
    #8
  9. Jean-François Michaud wrote:
    > Context:
    >
    > I'm trying to compare XML tree fragments and I'm doing so by
    > outputting the attributes of each element in the tree and outputting
    > it to a string then normalizing the strings. Then I'm doing a contains
    > of the current string against the following-sibling::* to determine if
    > we have duplicates. If we have a duplicate, we move to the next item,
    > if there is no duplicate, we output the small tree.
    >
    > I'm hitting a completely ridiculous problem that I can't wrap my head
    > around. I spend easily 2 hours trying to understand why this happened
    > yesterday and I'm about to punch the computer. When I output a string
    > that's not directly tied to the logic (or at least apparently not tied
    > to the logic), the logic works. When I remove the string output, the
    > logic stops working. Argh!
    >
    > Here's the XSLT snippet
    >
    > <xsl:template match="item-wrapper" mode="string">
    >
    > <xsl:variable name="current">
    > <xsl:apply-templates mode="string" />
    > </xsl:variable>
    >
    > <xsl:variable name="rest">
    > <xsl:apply-templates select="following-sibling::*"
    > mode="string" />
    > </xsl:variable>
    >
    > <xsl:variable name="current-normalized">
    > <xsl:value-of select="normalize-space($current)" />
    > </xsl:variable>
    >
    > <xsl:variable name="rest-normalized">
    > <xsl:value-of select="normalize-space($rest)" />
    > </xsl:variable>
    >
    > <!-- <fix/> What the hell? -->
    > <!-- <xsl:value-of select="$current-normalized"/>-->
    >
    > <xsl:choose>
    > <xsl:when test="contains($rest-normalized, $current-
    > normalized)">
    > <duplicate/>
    > </xsl:when>
    > <xsl:eek:therwise>
    > <noproblem/>
    > </xsl:eek:therwise>
    > </xsl:choose>
    > </xsl:template>
    >
    > When <xsl:value-of select="$current-normalized"/> is not commented
    > out, I get the string representation of the XML tree in a normalized
    > form in the output for each item and the correct <duplicate/> and
    > <noproblem/> get outputted in the correct location after the
    > normalized strings. When I comment out the <xsl:value-of
    > select="$current-normalized"/>, the normalized current string, as
    > expected, stops being outputted, but all my outputs are <noproblem/>.
    > What the hell? What am I missing here?
    >
    > Regards
    > Jean-Francois Michaud


    without seeing full input and code it's hard to really tell, but the
    behaviour seems expected to me.
    with the code as it is (with the value-of commented out) the template
    never puts any text into the result tree, just empty elements
    <duplicate/> or <noproblem/> so if this template is typical, then
    <xsl:variable name="rest">
    <xsl:apply-templates select="following-sibling::*" mode="string"/>
    </xsl:variable>

    will just produce a sequence of empty elements, so the string value will
    be "" so

    <xsl:when test="contains($rest-normalized, $current-normalized)">

    is testing if "" contains as a substring the normalised string value of
    the current node, which will presumably test as false so you get
    <noproblem/> every time.

    As you are using saxon9 (thus xslt2) you probably want to be looking as
    xsl:for-each-group to do duplicate removal, which is likely to be much
    more efficient.

    David



    --
    http://dpcarlisle.blogspot.com
    David Carlisle, Mar 11, 2008
    #9
  10. In article <>,
    Jean-François Michaud <> wrote:

    >When I output a string
    >that's not directly tied to the logic (or at least apparently not tied
    >to the logic), the logic works. When I remove the string output, the
    >logic stops working. Argh!


    Look carefully:

    > <xsl:template match="item-wrapper" mode="string">
    >
    > <xsl:variable name="current">
    > <xsl:apply-templates mode="string" />
    > </xsl:variable>


    $current is set to the result of applying the string-mode templates to
    the children of the current node. And this *is* the string-mode template.
    So when you comment out this:

    ><!-- <xsl:value-of select="$current-normalized"/>-->


    you are changing $current!

    -- Richard
    --
    :wq
    Richard Tobin, Mar 11, 2008
    #10
  11. On Mar 11, 3:01 pm, David Carlisle <>
    wrote:
    > Jean-François Michaud wrote:
    > > Context:

    >
    > > I'm trying to compare XML tree fragments and I'm doing so by
    > > outputting the attributes of each element in the tree and outputting
    > > it to a string then normalizing the strings. Then I'm doing a contains
    > > of the current string against the following-sibling::* to determine if
    > > we have duplicates. If we have a duplicate, we move to the next item,
    > > if there is no duplicate, we output the small tree.

    >
    > > I'm hitting a completely ridiculous problem that I can't wrap my head
    > > around. I spend easily 2 hours trying to understand why this happened
    > > yesterday and I'm about to punch the computer. When I output a string
    > > that's not directly tied to the logic (or at least apparently not tied
    > > to the logic), the logic works. When I remove the string output, the
    > > logic stops working. Argh!

    >
    > > Here's the XSLT snippet

    >
    > > <xsl:template match="item-wrapper" mode="string">

    >
    > > <xsl:variable name="current">
    > > <xsl:apply-templates mode="string" />
    > > </xsl:variable>

    >
    > > <xsl:variable name="rest">
    > > <xsl:apply-templates select="following-sibling::*"
    > > mode="string" />
    > > </xsl:variable>

    >
    > > <xsl:variable name="current-normalized">
    > > <xsl:value-of select="normalize-space($current)" />
    > > </xsl:variable>

    >
    > > <xsl:variable name="rest-normalized">
    > > <xsl:value-of select="normalize-space($rest)" />
    > > </xsl:variable>

    >
    > > <!-- <fix/> What the hell? -->
    > > <!-- <xsl:value-of select="$current-normalized"/>-->

    >
    > > <xsl:choose>
    > > <xsl:when test="contains($rest-normalized, $current-
    > > normalized)">
    > > <duplicate/>
    > > </xsl:when>
    > > <xsl:eek:therwise>
    > > <noproblem/>
    > > </xsl:eek:therwise>
    > > </xsl:choose>
    > > </xsl:template>

    >
    > > When <xsl:value-of select="$current-normalized"/> is not commented
    > > out, I get the string representation of the XML tree in a normalized
    > > form in the output for each item and the correct <duplicate/> and
    > > <noproblem/> get outputted in the correct location after the
    > > normalized strings. When I comment out the <xsl:value-of
    > > select="$current-normalized"/>, the normalized current string, as
    > > expected, stops being outputted, but all my outputs are <noproblem/>.
    > > What the hell? What am I missing here?

    >
    > > Regards
    > > Jean-Francois Michaud

    >
    > without seeing full input and code it's hard to really tell


    Understandably but I can't really produce a subset at this time, it
    would be too time consuming so I opted for the problem area.

    , but the
    > behaviour seems expected to me.


    Hmmm.

    > with the code as it is (with the value-of commented out) the template
    > never puts any text into the result tree, just empty elements
    > <duplicate/> or <noproblem/>


    That's what I had in mind and is the behavior that I expected to test
    out the logic and see if duplicates vs non-duplicates were recognized
    correctly.

    so if this template is typical, then
    > <xsl:variable name="rest">
    > <xsl:apply-templates select="following-sibling::*" mode="string"/>
    > </xsl:variable>
    >
    > will just produce a sequence of empty elements, so the string value will
    > be "" so


    Nope! The string templates actually take the attribute names and
    values of each element found and outputs it's content so we end up
    with a long string of concatenated attribute names and attribute
    values. The string is used to effectively "condense" an XML tree into
    a string form for comparison purposes. The idea is to test and verify
    that two XML trees are identical or not.

    The rest variable then contains a similar soup of long string of
    attribute names and values (of ALL the siblings). The content is then
    normalized to avoid potential whitespace inconsistencies (same with
    the current node) and then I simply verify that the current node in a
    string form isn't found anywhere in the following siblings string
    form, effectively determining that the current node and all it's
    children isn't found in any of it's siblings.

    > <xsl:when test="contains($rest-normalized, $current-normalized)">
    >
    > is testing if "" contains as a substring the normalized string value of
    > the current node, which will presumably test as false so you get
    > <noproblem/> every time.


    This seems to be a reasonable explanation for <noproblem> being
    outputted everywhere.

    The magic bit though is that when you uncomment out the <xsl:value-of
    select="$current-normalized">, which, as I understand, has nothing to
    do with the evaluation of $rest against the following siblings in a
    string form or $rest-normalized or the logic layed down to output
    <noproblem/> or <duplicate/>, the logic actually outputs <noproblem>
    where I expect and <duplicates> where I expect ;-).

    If you're explanation was right, $rest being empty and by extension,
    $rest-normalized being empty, it would imply that outputting value-of
    $current-normalized somehow made $rest get populated correctly. That
    is not what I would call expectable behavior. Or maybe I'm missing
    something else?

    > As you are using saxon9 (thus xslt2) you probably want to be looking as
    > xsl:for-each-group to do duplicate removal, which is likely to be much
    > more efficient.


    Actually using Saxon8 and we dont' really have the option of hopping
    to SaxonB9 at this point in time ;-).

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 12, 2008
    #11
  12. Jean-François Michaud wrote:
    > Understandably but I can't really produce a subset at this time, it
    > would be too time consuming so I opted for the problem area.


    Unfortunately, without adequate context it takes a lot of *our* type to
    try to diagnose what's going on. If it isn't worth your time, is it
    worth ours?

    For example: You're producing current by recursion in string mode. The
    actual change may be happening when an inner item-wrapper is processed;
    it now contains something that wasn't expected and may be changing
    behavior in another template you haven't shown us, thus changing
    current's value.

    Without seeing the rest of the stylesheet, we can't do more than guess
    at that kind of interaction.

    Spend the time to reduce your problem to a runnable minimal testcase. In
    the course of doing so you may solve it yourself. If not, you'll at
    least have something other people can help you with.


    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Mar 12, 2008
    #12
  13. On Mar 11, 3:52 pm, (Richard Tobin) wrote:
    > In article <>,
    > Jean-François Michaud <> wrote:
    >
    > >When I output a string
    > >that's not directly tied to the logic (or at least apparently not tied
    > >to the logic), the logic works. When I remove the string output, the
    > >logic stops working. Argh!

    >
    > Look carefully:
    >
    > > <xsl:template match="item-wrapper" mode="string">

    >
    > > <xsl:variable name="current">
    > > <xsl:apply-templates mode="string" />
    > > </xsl:variable>

    >
    > $current is set to the result of applying the string-mode templates to
    > the children of the current node. And this *is* the string-mode template.
    > So when you comment out this:
    >
    > ><!-- <xsl:value-of select="$current-normalized"/>-->

    >
    > you are changing $current!


    An interesting idea, but since the whole stylesheet isn't around, from
    my understanding, this is not the case (this is an interresting twist
    through and something might be happening there that I'm not perceiving
    correctly). item-wrapper contains other elements and templates exist
    (mode="string") for those elements also. As mentioned in the answer to
    David Carlisle, those templates only output the name and value of each
    of their attributes, effectively creating a long string that uniquely
    identifies (hopefully) the XML tree under item-wrapper.

    Also, because of the hierarchical relationship of nodes, I would
    expect $current, to be isolated from the $current of other calls. If
    it wasn't, we'd certainly be in trouble ;-).

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 12, 2008
    #13
  14. On Mar 12, 10:43 am, Joseph Kesselman <>
    wrote:
    > Jean-François Michaud wrote:
    > > Understandably but I can't really produce a subset at this time, it
    > > would be too time consuming so I opted for the problem area.

    >
    > Unfortunately, without adequate context it takes a lot of *our* type to
    > try to diagnose what's going on. If it isn't worth your time, is it
    > worth ours?


    I understand, I just thought I'd get some thoughts flowing that could
    help me pinpoint the problem. I'll spend some time and try and extract
    a subset. This would further my understanding of XSLT in any case If
    there is something wrong with my code or would help us pinpoint the
    Saxon bug if this is the real underlying problem.

    I implemented another solution from scratch through string reduction
    prior to right hand XML tree creation and hit a silly node-set/for-
    each scope limitation. I had to settle for a less graceful solution
    (variant on the node-set/for-each solution) that seems to now be
    working. I still want to understand what happened on this one though.

    > For example: You're producing current by recursion in string mode. The
    > actual change may be happening when an inner item-wrapper is processed;
    > it now contains something that wasn't expected and may be changing
    > behavior in another template you haven't shown us, thus changing
    > current's value.
    >
    > Without seeing the rest of the stylesheet, we can't do more than guess
    > at that kind of interaction.
    >
    > Spend the time to reduce your problem to a runnable minimal testcase. In
    > the course of doing so you may solve it yourself. If not, you'll at
    > least have something other people can help you with.
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 12, 2008
    #14
  15. Alright, here goes a reduced form of the input.xml and stylesheet.
    This is as small as I can get the input on short notice, but the
    stylesheet is relatively simple. I use saxon8.jar command line to run
    the standalone stylesheet against the input.xml. Toggling line 163
    (comment vs no comment) would yield the unexpected, from my stand
    point, result.

    I really appreciate the help guys.

    XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <S1000DEffectivity>
    <inlineapplics>

    <applic id = "A-G1C0" >
    <displaytext>Group 1</displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "lineno" actvalues = "1~35" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "serialno" actvalues = "34743" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HATS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G2C0" >
    <displaytext>Group 2</displaytext>
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "lineno" actvalues = "36~9999" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "serialno" actvalues = "36000~38000" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HELMETS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G3C0" >
    <displaytext>Group 3</displaytext>
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "or" >
    <assert actreftype = "prodattr" actidref
    = "lineno" actvalues = "1~3|5~6" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34638" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "primary" actvalues = "ZA044~ZA099" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH SKIRTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C0" >
    <displaytext>Group 4</displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C1" >
    <displaytext>Group 4, Configuration 1</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BLUE PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C2" >
    <displaytext>Group 4, Configuration 2</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH GREEN PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C3" >
    <displaytext>Group 4, Configuration 3</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH RED PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C4" >
    <displaytext>Group 4, Configuration 4</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH ORANGE PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C5" >
    <displaytext>Group 4, Configuration 5</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH PURPLE PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C6" >
    <displaytext>Group 4, Configuration 6</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH MAUVE PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C7" >
    <displaytext>Group 4, Configuration 7</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH TURQUOISE PANTS</
    assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C8" >
    <displaytext>Group 4, Configuration 8</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH CRIMSON PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C9" >
    <displaytext>Group 4, Configuration 9</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH MAGENTA PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C10" >
    <displaytext>Group 4, Configuration 10</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH TEAL PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C11" >
    <displaytext>Group 4, Configuration 11</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BROWN PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G4C12" >
    <displaytext>Group 4, Configuration 12</
    displaytext>
    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr" actidref
    = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH FUSCHIA PANTS</assert>
    </evaluate>
    </applic>

    <applic id = "A-G1C0G2C0" >
    <displaytext>Group 1-2</displaytext>
    <evaluate operator = "or">

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "lineno" actvalues = "1~35" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34743" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HATS</assert>
    </evaluate>

    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "lineno" actvalues = "36~9999" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "36000~38000" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HELMETS</assert>
    </evaluate>

    </evaluate>
    </applic>

    <applic id = "A-G1C0G4C1G4C2" >
    <displaytext>Group 1; Group 4, Configuration
    1-2</displaytext>
    <evaluate operator = "or">

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "lineno" actvalues = "1~35" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34743" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HATS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BLUE PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH GREEN PANTS</assert>
    </evaluate>

    </evaluate>
    </applic>

    <applic id = "A-
    G1C0G4C1G4C2G4C4G4C5G4C6G4C7G4C8G4C9G4C10G4C11G4C12" >
    <displaytext>Group 1; Group 4, Configuration
    1-2, 4-12</displaytext>
    <evaluate operator = "or">

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "lineno" actvalues = "1~35" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA039" />
    </evaluate>
    <assert actreftype = "prodattr" actidref
    = "serialno" actvalues = "34743" />
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH HATS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BLUE PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH GREEN PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH ORANGE PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH PURPLE PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH MAUVE PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH TURQUOISE PANTS</
    assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH CRIMSON PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH MAGENTA PANTS</
    assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH TEAL PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BROWN PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH FUSCHIA PANTS</
    assert>
    </
    evaluate>

    </evaluate>
    </applic>

    <applic id = "A-G4C10G4C11G4C12" >
    <displaytext>Group 4, Configuration 10-12</
    displaytext>
    <evaluate operator = "or">

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH TEAL PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH BROWN PANTS</assert>
    </evaluate>

    <evaluate operator = "and">
    <evaluate operator = "and" >
    <evaluate operator = "or" >
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA030~ZA040" />
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "35939~35999" />
    </evaluate>
    <evaluate operator = "and" >
    <assert actreftype = "prodattr"
    actidref = "serialno" actvalues = "34600~34899" />
    <assert actreftype = "prodattr"
    actidref = "primary" actvalues = "ZA036~ZA043" />
    </evaluate>
    </evaluate>
    <assert actreftype = "prodattr" actidref =
    "typecertmodel" actvalues = "787-8" />
    </evaluate>
    <assert>AIRPLANES WITH FUSCHIA PANTS</
    assert>
    </evaluate>

    </evaluate>
    </applic>

    </inlineapplics>
    </S1000DEffectivity>
    <Figure
    applicability="1:0;4:1;4:2;4:4;4:5;4:6;4:7;4:8;4:9;4:10;4:11;4:12" />
    </root>

    XSLT:

    <?xml version="1.0"?>

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
    Transform"
    xmlns:exsl="http://exslt.org/common"
    exclude-result-prefixes="exsl">

    <xsl:eek:utput method="xml" indent="yes"/>

    <xsl:template match="root">
    <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="Figure">
    <xsl:result-document href="output.xml">
    <xsl:call-template name="applic" />
    </xsl:result-document>
    </xsl:template>

    <xsl:template name="refapplic-recursion">
    <xsl:param name="applicability" />
    <xsl:choose>
    <xsl:when test="$applicability='' or $applicability=' ' or
    $applicability='All' or $applicability='all'"/>
    <xsl:eek:therwise>
    <xsl:variable name="g"><xsl:call-template name="g"><xsl:with-
    param name="applic" select="$applicability" /><xsl:with-param name="n"
    select="1" /></xsl:call-template></xsl:variable>
    <xsl:variable name="c"><xsl:call-template name="c"><xsl:with-
    param name="applic" select="$applicability" /><xsl:with-param name="n"
    select="1" /></xsl:call-template></xsl:variable>
    <xsl:text>G</xsl:text><xsl:value-of select="$g"/>
    <xsl:text>C</xsl:text><xsl:value-of select="$c"/>
    <xsl:call-template name="refapplic-recursion"><xsl:with-param
    name="applicability"><xsl:value-of select="substring-
    after($applicability, ';')"/></xsl:with-param></xsl:call-template>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="g">
    <xsl:param name="applic" />
    <xsl:param name="n" />
    <xsl:choose>
    <xsl:when test="$n > 1">
    <xsl:call-template name="g"><xsl:with-param name="applic"
    select="substring-after($applic, ';')" /><xsl:with-param name="n"
    select="$n - 1" /></xsl:call-template>
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:value-of select="substring-before($applic, ':')" />
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="c">
    <xsl:param name="applic" />
    <xsl:param name="n" />
    <xsl:choose>
    <xsl:when test="$n > 1">
    <xsl:call-template name="c"><xsl:with-param name="applic"
    select="substring-after($applic, ';')" /><xsl:with-param name="n"
    select="$n - 1" /></xsl:call-template>
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:choose>
    <xsl:when test="substring-after($applic, ';')!=''">
    <xsl:value-of select="substring-after(substring-
    before($applic, ';'), ':')" />
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:choose>
    <xsl:when test="substring-before(substring-
    after($applic, ':'), ';')!=''">
    <xsl:value-of select="substring-before(substring-
    after($applic, ':'), ';')"/>
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:value-of select="substring-after($applic, ':')" /
    >

    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="applic">
    <applic>
    <xsl:variable name="mra-string">
    <xsl:text>A-</xsl:text><xsl:call-template name="refapplic-
    recursion"><xsl:with-param name="applicability"><xsl:value-of
    select="@applicability" /></xsl:with-param></xsl:call-
    template>
    </xsl:variable>
    <xsl:for-each select="//S1000DEffectivity">
    <xsl:for-each select="inlineapplics">

    <xsl:variable name="correct-applic">
    <xsl:apply-templates select="applic" mode="unique">
    <xsl:with-param name="mra-string"><xsl:copy-of
    select="$mra-string" /></xsl:with-param>
    </xsl:apply-templates>
    </xsl:variable>

    <xsl:variable name="applic-with-duplicates">
    <xsl:apply-templates select="exsl:node-set($correct-
    applic)" mode="correct-applic" />
    </xsl:variable>

    <xsl:apply-templates select="exsl:node-set($applic-with-
    duplicates)" mode="string"/>

    </xsl:for-each>
    </xsl:for-each>
    </applic>
    </xsl:template>

    <xsl:template match="applic" mode="unique">
    <xsl:param name="mra-string"></xsl:param>

    <xsl:variable name="id">
    <xsl:value-of select="@id" />
    </xsl:variable>

    <xsl:if test="$mra-string = $id">
    <xsl:copy-of select="." />
    </xsl:if>
    </xsl:template>

    <xsl:template match="applic" mode="correct-applic">
    <xsl:apply-templates mode="correct-applic" />
    </xsl:template>

    <xsl:template match="evaluate" mode="correct-applic">
    <xsl:choose>
    <xsl:when test="assert[.!='']">
    <item-wrapper>
    <xsl:apply-templates mode="correct-applic" />
    </item-wrapper>
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:copy>
    <xsl:copy-of select="@*" />
    <xsl:apply-templates mode="correct-applic" />
    </xsl:copy>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template match="assert[.='']" mode="correct-applic">
    <xsl:copy>
    <xsl:copy-of select="@*" />
    <xsl:apply-templates mode="correct-applic" />
    </xsl:copy>
    </xsl:template>

    <xsl:template match="assert[.!='']" mode="correct-applic">
    </xsl:template>

    <xsl:template match="displaytext" mode="correct-applic">
    </xsl:template>

    <!-- Do a string comparison on the attributes of the trees to
    determine if the trees are equal -->
    <xsl:template match="item-wrapper" mode="string">

    <xsl:variable name="current">
    <xsl:apply-templates mode="string" />
    </xsl:variable>

    <xsl:variable name="rest">
    <xsl:apply-templates select="following-sibling::*"
    mode="string" />
    </xsl:variable>

    <xsl:variable name="current-normalized">
    <xsl:value-of select="normalize-space($current)" />
    </xsl:variable>

    <xsl:variable name="rest-normalized">
    <xsl:value-of select="normalize-space($rest)" />
    </xsl:variable>

    <!-- <fix/> What the hell? -->
    <!-- <xsl:value-of select="$current-normalized"/>-->

    <xsl:choose>
    <xsl:when test="contains($rest-normalized, $current-
    normalized)">
    <duplicate/>
    </xsl:when>
    <xsl:eek:therwise>
    <noproblem/>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template match="/evaluate" mode="string">
    <xsl:apply-templates mode="string" />
    </xsl:template>

    <xsl:template match="evaluate" mode="string">
    <xsl:value-of select="@*" />
    <xsl:apply-templates mode="string" />
    </xsl:template>

    <xsl:template match="assert" mode="string">
    <xsl:value-of select="@*" />
    <xsl:apply-templates mode="string" />
    </xsl:template>

    <xsl:template match="S1000DEffectivity">
    </xsl:template>

    </xsl:stylesheet>

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 12, 2008
    #15
  16. Jean-François Michaud wrote:


    >
    >> with the code as it is (with the value-of commented out) the template
    >> never puts any text into the result tree, just empty elements
    >> <duplicate/> or <noproblem/>

    >
    > That's what I had in mind and is the behavior that I expected to test
    > out the logic and see if duplicates vs non-duplicates were recognized
    > correctly.
    >
    > so if this template is typical, then
    >> <xsl:variable name="rest">
    >> <xsl:apply-templates select="following-sibling::*" mode="string"/>
    >> </xsl:variable>
    >>
    >> will just produce a sequence of empty elements, so the string value will
    >> be "" so

    >
    > Nope! The string templates actually take the attribute names and
    > values of each element found and outputs it's content


    The teplate you posted outputs nothing, which is teh cause of your
    problem. When you remove the comment then it outputs something, and your
    problem goes.


    > so we end up
    > with a long string of concatenated attribute names and attribute
    > values. The string is used to effectively "condense" an XML tree into
    > a string form for comparison purposes. The idea is to test and verify
    > that two XML trees are identical or not.


    why not use deep-equal ?


    >
    > The rest variable then contains a similar soup of long string of
    > attribute names and values (of ALL the siblings). The content is then
    > normalized to avoid potential whitespace inconsistencies (same with
    > the current node) and then I simply verify that the current node in a
    > string form isn't found anywhere in the following siblings string
    > form, effectively determining that the current node and all it's
    > children isn't found in any of it's siblings.
    >
    >> <xsl:when test="contains($rest-normalized, $current-normalized)">
    >>
    >> is testing if "" contains as a substring the normalized string value of
    >> the current node, which will presumably test as false so you get
    >> <noproblem/> every time.

    >
    > This seems to be a reasonable explanation for <noproblem> being
    > outputted everywhere.
    >
    > The magic bit though is that when you uncomment out the <xsl:value-of
    > select="$current-normalized">, which, as I understand, has nothing to
    > do with the evaluation of $rest against the following siblings in a

    yes it has everything to do with that, as I tried to explain. the
    siblings are all evaluate elements, and so if you leave the comment in
    $rest is evaluated using this template and will have empty string value.

    > string form or $rest-normalized or the logic layed down to output
    > <noproblem/> or <duplicate/>, the logic actually outputs <noproblem>
    > where I expect and <duplicates> where I expect ;-).
    >
    > If you're explanation was right, $rest being empty and by extension,
    > $rest-normalized being empty, it would imply that outputting value-of
    > $current-normalized somehow made $rest get populated correctly. That
    > is not what I would call expectable behavior. Or maybe I'm missing
    > something else?


    Sorry I'm not sure how else I can explain it, but just look carefully at
    your template for evaluate; it generates no output.
    >
    >> As you are using saxon9 (thus xslt2) you probably want to be looking as
    >> xsl:for-each-group to do duplicate removal, which is likely to be much
    >> more efficient.

    >
    > Actually using Saxon8 and we dont' really have the option of hopping
    > to SaxonB9 at this point in time ;-).


    saxon8 is the same as 9 for this purposes they both implement teh same
    version of XSLt (2.0) saxon 6 was the xslt 1 processor.

    >
    > Regards
    > Jean-Francois Michaud



    --
    http://dpcarlisle.blogspot.com
    David Carlisle, Mar 12, 2008
    #16
  17. Jean-François Michaud

    keshlam Guest

    The only thing that needs 2.0 is the redirection -- which is
    irrelevant. Commented it out for debugging under 1.0.

    Fixing the various line wraps was a pain. Generally it's easier for
    everyone if you put the files on a website somewhere so they can be
    downloaded intact, rather than risking the newsgroup tools mucking
    with them.

    You say the failure's in the template for item-wrapper in string mode.
    The appropriate test is to see what the output of that template is.
    Quickest approach is changing the root to just apply-templates
    against //item-wrapper in that mode.

    Sure enough, that template produces no output; your change forces some
    non-empty output into it. David is absolutely right.

    So the thing to investigate is why you expected this template to
    produce non-empty results, not why forcing non-empty results has an
    effect. You asked the wrong question. Go back and ask the right one.

    Divide-and-conquer works wonders.

    xsl:message can also be a lifesaver, for displaying where you've
    gotten to and what some of the values are. Standard pointer to my
    DeveloperWorks articles on "styling stylesheets" for a way to
    automatically insert some stylesheet tracing information.
    keshlam, Mar 13, 2008
    #17
  18. On Mar 12, 5:18 pm, keshlam <> wrote:
    > The only thing that needs 2.0 is the redirection -- which is
    > irrelevant. Commented it out for debugging under 1.0.
    >
    > Fixing the various line wraps was a pain. Generally it's easier for
    > everyone if you put the files on a website somewhere so they can be
    > downloaded intact, rather than risking the newsgroup tools mucking
    > with them.
    >
    > You say the failure's in the template for item-wrapper in string mode.
    > The appropriate test is to see what the output of that template is.
    > Quickest approach is changing the root to just apply-templates
    > against //item-wrapper in that mode.
    >
    > Sure enough, that template produces no output; your change forces some
    > non-empty output into it. David is absolutely right.
    >
    > So the thing to investigate is why you expected this template to
    > produce non-empty results, not why forcing non-empty results has an
    > effect. You asked the wrong question. Go back and ask the right one.
    >
    > Divide-and-conquer works wonders.
    >
    > xsl:message can also be a lifesaver, for displaying where you've
    > gotten to and what some of the values are. Standard pointer to my
    > DeveloperWorks articles on "styling stylesheets" for a way to
    > automatically insert some stylesheet tracing information.


    Alright, I'll give it some further thought. Thanks a bunch to
    everybody for taking the time to review the code. I really appreciate
    the help ;-).

    Regards
    Jean-Francois Michaud
    Jean-François Michaud, Mar 19, 2008
    #18
    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. Debashish Chakravarty

    when GOTO makes sense.

    Debashish Chakravarty, Nov 29, 2003, in forum: C Programming
    Replies:
    45
    Views:
    1,073
    Dan Pop
    Dec 9, 2003
  2. Replies:
    1
    Views:
    359
    Peter Otten
    Aug 30, 2006
  3. Replies:
    11
    Views:
    637
    Crouchinho
    Sep 26, 2006
  4. Replies:
    3
    Views:
    363
  5. Neroku
    Replies:
    6
    Views:
    10,202
    Chris Uppal
    Feb 8, 2007
Loading...

Share This Page