Forum Moderators: phranque

Message Too Old, No Replies

How does/can XML handle relational data?

Can XML be modular, to deal with "many>many" relationships. File includes?

         

hollowearth

10:42 am on Nov 14, 2001 (gmt 0)



Hi there. I work on a reasonably large and complex website, virtual servers, mapped filesystems, etc. Many, many departments managing different chunks of intranet and internet.

I've considered using XML to help store information about this, XML is ideal, I thought, because it has a treelike structure, as does the directories it will be storing information about.

This is going fine, i've written a smart style sheet to help navigate the tree. Works great (in IE of course), my problem is that I need some of the data to be repeated, when the same management team looks after more than one directory in different areas of the site.

It would be okay to cut and paste the chunks of xml around, but if a member of this team changes, i'm stuck with changing every instance, which seems primitive... Ideally i'd like something like:

<team name="a">
<person><name/><tel/><email/></person>
<person><name/><tel/><email/></person>
<person><name/><tel/><email/></person>
</team>

<directory url="..." filepath="...">
<owner="*some kind of reference to team a*"/>
</directory>
<directory url="..." filepath="...">
<owner="*some kind of reference to team a*"/>
</directory>

... rather than have to repeat the information in every instance. Does anyone know if many-many relationships like this are possible in XML? Can I include XML files in XML files in any way?

Or am I on the wrong track entirely?

DaveAtIFG

6:37 pm on Nov 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We're pleased you decided to join us hollowearth, welcome! And we're not ignoring you, I swear! In addition to "floating" your question, I'll bring it up in the moderators forum. We have plenty of very knowledgeable folks here, hopefully someone will be able to point you the right way.

agerhart

7:56 pm on Nov 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hollowearth,

I asked a colleague of mine to answer your question. Here is his response:

The current XML specification doesn't easily handle such complex data
representations such as many-to-many relationships. Many-to-many
relationships can however, be represented by IDREF-ID pointers. IDREF's are
attributes that point to other elements having the an ID attribute with the
same corresponding value.

Look at the example below extracted from
[w3c.rl.ac.uk...]

Similar to anchors in HTML

------------given this DTD-------------------------------
<!ELEMENT book (title,author,publisher)>
<!ATTLIST book destination ID #REQUIRED>

<!ELEMENT bestbooks (bookref)* >
<!ELEMENT bookref (#PCDATA)>
<!ATTLIST bookref target IDREF #IMPLIED>
-----------------------------------------------------------
So a book might be:

<book destination="BookId28752">
<title>Introduction to GKS </title>
<author>Bob Hopgood </author>
<publisher>Academic </publisher>
</book>

And a reference to it might be:

<bestbooks>
<bookref target="BookId28752">Introduction to GKS </bookref>
<bookref>GKS for Dummies </bookref>
</bestbooks>

Note how target is an IDREF attribute which value
points to destination, which is an ID attribute with the same value?!?!?!?!

Yours Truly,
Dale Cover

Xoc

9:14 pm on Nov 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dale's response is correct. You could also have an attribute that is simply the filename of another XML file. When you are processing it using the DOM (Document Object Model) or XSLT (eXtensible Style Language Transformation), you could use the attribute value to tell you what other file to open. It would be up to your implementation to provide the link between the files.

hollowearth

9:24 am on Nov 22, 2001 (gmt 0)



Ah thanks folks! That's pretty much what I had in mind, though to be honest, it's been a week or so since I first posted the question, and i'm now thinking that a proper database would be a more sensible way to cope with the kind of data I had in mind.

Untill I can better figure out what it's for, i'm stepping off the XML bandwagon for the time being.