Matching element pairs from two documents - variable value type problem

With the help of XProc, I would like to collect element pairs that match each other within two documents, where the matching is based on the criterion of having the same value in the "id" attribute. For instance, if I have two documents:

<maindoc>
  <e1 id="a" xx="123"/>
  <e1 id="c" xx="456"/>
</maindoc>

and

<refdoc>
  <e2 id="a" yy="789"/>
  <e2 id="b" yy="012"/>
</refdoc>

then I want to retain only <e1 id="a" xx="123"/> in <maindoc> and also need to get hold of <e2 id="a" yy="789"/> in <refdoc>.
(It is safe to assume that the "id" values are indeed unique within each document.)

In XSLT, I would easily have filtered out the matching elements by iterating over the children of <maindoc>, putting the elements into variables and then comparing their values by means of a predicate. (Or by using keys, of course.)

In XProc, however, I have difficulty getting both node trees to "close up" because XProc variables, alas, can't hold nodes.

Alternatively, sending in both documents via two input ports seems promising, but I can't see how to connect p:viewport or p:xslt (or any other step that could do the filtering) to TWO input ports or input documents. Using document() within XSLT to read the second document would be less ideal, I think, because this would mean to serialize the document, which is the result of another XProc step, to disk first.

Comparing the nodes in some string representation would in itself be fine, maybe, but the matching nodes from both documents need to survive this because I need to continue to process them, so it could be only part of the solution.

Which is the best technique to solve this kind of problem in XProc?

Yves

--
Dr. Yves Forkl - Softwareentwicklung
SRZ, Bessemerstr. 83-91, 12103 Berlin
www.srz.de | Firmengruppe: www.besscom.de
tel +49 30 75301-335 | fax +49 30 75301-11335

Satz-Rechen-Zentrum Hartmann+Heenemann GmbH&Co. KG
Sitz Berlin | AG Charlottenburg | HRA 8089
Komplementärin Satz-Rechner-Betriebsgesellschaft mbH
Sitz Berlin | AG Charlottenburg | HRB 4905
Geschäftsführer: Walter Fock

Received on Friday, 8 June 2012 15:10:29 UTC