xsl-list
[Top] [All Lists]

[xsl] XPath expression which expresses sequence-extended = (sequence, item)

2017-11-21 12:51:18
Hi Folks,

Consider this XML:

<sequences>
    <sequence>
        <item>A</item>
    </sequence>
    <sequence>
        <item>A</item>
        <item>B</item>
    </sequence>
</sequences>

Suppose that $sequence-extended has this value:

    <sequence>
        <item>A</item>
        <item>B</item>
    </sequence>

And $sequence has this value:

    <sequence>
        <item>A</item>
    </sequence>

And $item has this value: 

    <item>B</item>

I want an XPath expression which expresses this: 

    The $sequence-extended items equals
    the $sequence items plus $item. 

This XPath expression seems to work:

$sequence-extended/item = ($sequence/item, $item)

But, the XPath expression fails when $sequence is empty:

    <sequence/>

And $sequence-extended has a single item:

    <sequence>
        <item>A</item>
    </sequence>

And $item is: 

    <item>A</item>

What XPath 2.0 expression works in all cases? 

Note: I seek simplicity and plainness over efficiency and cleverness.

/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>