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

Joining XML files?

Subject: Joining XML files?
From: "rhino"
Date: Tue, 1 Jul 2008 16:03:23 -0400
Newsgroups: comp.text.xml

I'm very new to XML and maybe just a touch impatient because I'm going to 
ask a moderately advanced question even though I'm just learning the basics.

I've spent many years working with databases, both hierarchical and 
relational. So far, XML is obviously hierarchical in nature. I'm wondering 
if there is anything analogous to a relational "join" in XML?

For example, let's say I have an XML file that has a root element of 
departments. Each record of the file has information about a single 
department in a company and consists of a department number, department 
name, manager name, and location. Let's say I have another XML file that 
lists employees. Each record is an employee and gives information about the 
employee's name, date of birth, department number, home address, etc.

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? Something like this:

Marketing
    Department Number: 001
    Location: New York
    Manager: T. Jones

    Other Staff
    E. Humperdinck
    E. Presley
    J. Hendrix

Information Systems
    Department Number: 666
    Location: Toronto
    Manager: M. Slate

    Other Staff
    F. Flintstone
    B. Rubble
    J. Rockhead

In other words, we're getting the department name and manager name from the 
departments file and the "other staff" names from the employees file. We 
know which employees go in which departments because the department number 
is in both the departments file and in the employees file.

Is it conceptually possible to do this kind of joining in XSLT? If so, what 
is this called? In other words, what are the main terms I need to know here? 
I'd call this a join in relational database terminology but I imagine XSLT 
has different terminology.

If this IS possible, can someone point me to a tutorial or reference that 
explains how to write XSLT to do this?

--
Rhino 



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