This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Merging


Jeni,

> Keys index into any nodes that they match in the document that the current
> node is in.  You could define a key that only indexed into a portion of the
> document by making the match attribute only match that portion of the
> document, but you can't dynamically change the portion of the document that
> they index into.
> 
[...]
> Can you give a more concrete example of what you're after?

I'll try to keep it short.
The aim is to merge two arbitrary XML documents, i.e. I have no
further information about the elements, the structure etc.
Merging works as follows: take the children of the two root nodes
and merge these. Now I have two node sets.
Algorithm: check, if the first node of the first node set is equivalent
(same name, same attributes resp. same value for text nodes etc.) to
the first node of the second node set. If yes - fine - create one
output node and merge the children of the two nodes recursively. After
that: merge the rest of the original node sets.
If no - check if there's an other node of the second node set that is
equivalent to the first node of the first node set. If yes - copy all
preceding nodes, merge the matching nodes (as described above) and merge
the rest.
If there's no matching node, copy the first node of the first node set
to the output and merge (recursively) the rest of the first node set with
the second node set.

This implementation (available at 
http://www.informatik.hu-berlin.de/~obecker/XSLT/merge/merge.xslt )
works quite well, but as Tom pointed out - it's quite slow for large
input documents.

In my mail folder there's a mail from you to Tom Mullen
  Date: Wed, 12 Jul 2000 15:29:06 +0100,
  Subject: Re: Combining XML data
in which you propose the usage of keys. Tom now wants to use the key
method for the general objective of merging two XML docs.
I think that means: find the first equivalent node in a given node set
by using keys.

I have no idea how to do this.
Or to tell the truth: I don't think that keys are helpful in this case.

Did it become clear what I want to achieve?

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@informatik.hu-berlin.de             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]