Forum Moderators: phranque
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?
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