[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Expert's advice needed about XML Schema and defining some


idref xml schema
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









PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.