0
votes

In my main instance I have a set of nodes as follows:

Main instance

 <Items>
    <Item>
       <Id>2</Id>
    </Item>
    <Item>
       <Id>3</Id>
    </Item>
    <Item>
       <Id>4</Id>
    </Item>
    <Item>
       <Id>5</Id>
    </Item>
 </Items>

And another (similar) instance with values such as:

Other instance

 <Items>
    <Item>
       <Id>4</Id>
    </Item>
    <Item>
       <Id>5</Id>
    </Item>
    <Item>
       <Id>6</Id>
    </Item>
 </Items>

Now I want to delete all items in the Main instance, that don't have a corresponding entry in the other Instance, so the main instance will then look like:

 <Items>
    <Item>
       <Id>4</Id>
    </Item>
    <Item>
       <Id>5</Id>
    </Item>
 </Items>

Then I want to delete all items in the other instance that DO exist in the main instance, so the other instance will look like:

 <Items>
    <Item>
       <Id>6</Id>
    </Item>
 </Items>

I'm struggling with the syntax to accomplish this. thanks in advance Peter

1

1 Answers

2
votes

Something like this:

<xf:delete
    ref="
        instance('main')/Item[
            not(
                Id = instance('other')/Item/Id
            )
        ]"
/>

and:

<xf:delete
    ref="
        instance('other')/Item[
            Id = instance('main')/Item/Id
        ]"
/>