comp.text.xml
[Top] [All Lists]

Re: Joining XML files?

Subject: Re: Joining XML files?
From: "Joseph J. Kesselman"
Date: Tue, 01 Jul 2008 16:15:20 -0400
Newsgroups: comp.text.xml


rhino wrote:
Given that these are two separate XML files but that there is some common information, specifically the department number, could I use XSLT to generate a report that shows me each department name followed by the names of the people who work in the department?

XSLT can certainly reference more than one input source, using the document() function; then it's just a matter of writing expressions that use data from one document to look up information in the other document.

There are probably examples on the XSLT FAQ website... but seriously, once you know about the document() function it really isn't any harder than if you were recombining data read from a single document.

The only tricky part, really, is deciding how you're going to tell the stylesheet which two sources to look at. Common solutions are passing one of the URIs in as a parameter, or having one hardcoded into the stylesheet, or having a front-end document which the stylesheet obtains both the actual URIs from.... Which of those solutions is best depends on the environment you're performing this operation in. Note that all of 'em are extensible to more than 2 documents.

As to what to call it: Conceptually it's certainly a join or merge. The former term is more likely to be recognized by DB and data-structure folks, the latter is more familiar to folks coming to XML and XSLT from the document-markup side of the world. I wouldn't get hung up on the terminology; the clearest solution is probably to do exactly what you did, provide a brief example of what you're trying to accomplish.

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy