W3C home > Mailing lists > Public > xproc-dev@w3.org > June 2012

Matching element pairs from two documents - variable value type problem

From: Dr. Yves Forkl (SRZ) <Y.Forkl@srz.de>
Date: Fri, 08 Jun 2012 17:09:41 +0200
Message-ID: <4FD215B5.1070305@srz.de>
To: XProc Dev <xproc-dev@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 8 June 2012 15:10:29 GMT