filtering resultsets

Poster Content
nk4um User
Posts: 89
June 30, 2008 13:07intersect works on nodes not values
Hi Tom,

The intersect XPath operator works on nodes not values, and as you''ve two sets from different documents they can never intersect. You may use the value-intersect function from the functx library:

http://www.xqueryfunctions.com/xq/functx_value-intersect.html

That one works on values. You can just copy and paste the function definition into your code.

If you want to use the functx XQuery module there is currently a known problem: the NK resolver for Saxon doesn''t support the loading of the plain text files of XQuery modules, i.e. the resolver currently only loads XML resources. In that case, for now, you could switch to XSLT 2.0 where loading the XSLT functx module works fine.

Hope this helps,

Menzo
nk4um User
Posts: 129
June 30, 2008 12:34filtering resultsets
I''ve got two xml documents, for example
<nvp>
  <option>SVLIPC16</option>
  <option>SVLIPC17</option>
</nvp>

and
<nvp>
  <option>SVLIPC16</option>
</nvp>

What is the best way to UNION, INTERSECT, EXCEPT them ? I''ve been trying with xquery ... like ...
<idoc>
<seq>
  <instr>
   <type>xquery</type>
   <operator>
    <xquery>
     declare variable $assets as node() external;
     declare variable $assetsfilter as node() external;
     let $result := ($assets intersect $assetsfilter)
     return $result
    </xquery>
   </operator>
   <assets>
    <nvp>
     <option>SVLIPC16</option>
     <option>SVLIPC17</option>
    </nvp>
   </assets>
   <assetsfilter>
    <nvp>
     <option>SVLIPC16</option>
    </nvp>
   </assetsfilter>
   <target>this:response</target>
  </instr>
</seq>
</idoc>


but that doesn''t seem to work.
Any pointers ?
Any better way to do this ?

Regards,
Tom