[
Lists Home |
Date Index |
Thread Index
]
Hi,
Michael Champion wrote:
>
> On Dec 5, 2003, at 3:36 AM, Barwell Jonathan wrote:
>
>> I wonder whether you are actually using the right technologies to
>> solve your problems. In essence you are trying to design a relational
>> database using XML.
>
>
> I had the same reaction to the original post. As useful as XML is for
> lots of things, one needs to guard against the temptation to see nails
> that need pounding simply because one has a hammer. XML per se has no
> notion of cross-document referential integrity nor does XPath/XSLT 1.x
> have the notion of a join. Obviously these are two great strengths of
> the relational approach.
>
> To the extent that other aspects of the situation here demand an XML
> approach, XSLT 2.0 / XQuery joins across two documents seem like a more
> natural fit than trying to coerce the data into a single document where
> DTD/Schema id/idref constraints can apply.<snip/>
This is the second post I have seen that pooh-poohs the value of
id/idref, XML Schemas and xslt1.0 to manage a project's validity. I am
wondering if the context here is unique or if it is generally a bad
practice to use these types of things. I use them for a few reasons:
provide a UI for a user to manage their project and ensure validity for
our cms.
Below is a simplified example of some things I do; could you (anyone)
comment on it? (tear it to shreds if you like; I have a thick skin)
This is a config XML that describes a brochure-type website (site.xml):
<site ...>
<folder id="f123" index_page="a123" ...>
<page id="a123" ...more system independent metadata...>
<region name="wideColumn">
<content ref="c123"/>
</region>
</page>
</folder>
<page id="a234" ...>
...
</page>
</site>
This is a config XML that describes a kind of topic mapping or dmoz-type
website (topics.xml):
<topics>
...
<topic id="t123" label="some_grouping">
<topic id="t234" label="some_sub_grouping">
<content id="c123" label="blah" ...more system independent
metadata.../>
</topic>
</topic>
...
</topics>
When validating I bring in config files like so:
<config>
&site;
&topics;
</config>
and here is a the content piece referenced/identified in the content
elements above (c123.xml):
<article>
<p>blah blah <link page_idref="a234">blah</link>
</article>
when transforming and possibly writing to a file /site/page[@id='a123']
(or any page) I use the document function and a URIResolver to bring in
the content piece:
...
<div id="wideColumn">
<xsl:apply-templates
select="$focus_page/region[@name='wideColumn']/*"
mode="load_regions"/>
</div>
...
<xsl:template match="content" mode="load_columns">
<xsl:apply-templates select="document(@ref)"/>
</xsl:template>
--o--
In addition and among other things, I ocassionally validate that the
content pieces referenced in the site.xml//page/region/content exists in
topics.xml/topics//content (automated).
site.xml/site//folder has the index_page attribute which is an xs:IDREF
while site.xml//page/@id is an xs:ID.
c123.xml//link/@page_idref is not defined in a schema as an xs:IDREF.
Rather, I use XSL to verify that the 'virtual page' (to be rendered as
HTML to the file system or sent back to a browser) that the content
piece attempts to link to actually exists in the site.xml.
If the above is understandable (:-o), am I following bad or good practices?
If anyone is interested in some 'real' examples I can provide those.
thanks,
-Rob
|