OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] More on namespaces...

[ Lists Home | Date Index | Thread Index ]

I don't speak for anybody else on this list, I only speak from my own 
experiences with xml.

>1) Suppose you have a vocabulary that states that only <B> may be within
><A>.  Now suppose you have another vocabulary with element <C>.  If one were
>to do <ns1:A><ns1:B/><ns2:C/></ns1:A>, would the document still be valid
>according to the first vocabulary?
>

Well, that's really up to you.  Do you want <ns1:A/> to allow children 
in other namespaces?  Sometimes you do, sometimes you don't.  
Personally, I think you should always default to allowing it as it's 
more flexible in the long run, but it can be harder to code and there 
are going to be times when you might not want it (perhaps you're making 
an HTML only rich edit section):

<xsd:complexType name="ns1:A">

    only allow ns1:B

    <xsd:sequence>
       <xsd:element name="ns1:B"/>
    </xsd:sequence>

    or allow everything from any namspace (including ns1):

    <xsd:sequence>
        <xsd:any namespace="##any"/>
    </xsd:sequence>

     or allow all other namespaces, but just ns1:B:

    <xsd:sequence>
       <xsd:element name="ns1:B"/>
       <xsd:any namespace="##other"/>
    </xsd:sequence>

</xsd:complexType>

What do you do with content you do find that you don't recognize?  Well, 
once again that's up to you as well.  Every program behaves a little 
differently.  Sometimes you pass it to some external tool that does 
recognize it.  Sometimes you just grab the text.  Personally, I usually 
just grab the XML as is and pass it on down the line hoping some tool 
somewhere down in the chain recognizes the unknown tags (and usually 
there is one).

>2) Given the various levels of support for xml namespaces in tools, what
>would be the pros/cons of the following practice:
>
>The document's primary vocabulary is never namespaced.  Secondary
>vocabularies are always namespaced.  Default namespacing is never used.  If
>the primary vocabulary will also act in a secondary fashion (e.g.
>"mustUnderstand" in SOAP), then it will be namespaced.  However, only
>secondary uses of the vocabulary are qualified.  Primary uses are still not
>namespaced.
>

I don't really consider myself qualified to answer this correctly.  But 
I can give you a rule I live by:  It's either all namespaced or none of 
it is namespaced.  Why?  Because when you start mixing namespaced 
vocabularies with non-namespaced vocabularies, it's easy to accidentally 
mix up your non-namespaced vocabularies with each other.  Maybe I define 
a config file where I don't use namespaces, then most of my other 
documents are HTML documents and I don't bother using namespaces for 
those.  Inevitably my HTML files get mixed up with my non-html files and 
some tool somewhere in the processing chain breaks when it sees a tag it 
doesn't recognize.  I avoid that probably by namespacing everything.

>3) In one of the original posts of the recent thread, there was a sample
>document:
>
><h:html xmlns:xdc="http://www.xml.com/books";
>        xmlns:h="http://www.w3.org/HTML/1998/html4";>
> <h:head><h:title>Book Review</h:title></h:head>
> <h:body>
>  <xdc:bookreview>
>   <xdc:title>XML: A Primer</xdc:title>
>   <h:table>
>    <h:tr align="center">
>     <h:td>Author</h:td><h:td>Price</h:td>
>     <h:td>Pages</h:td><h:td>Date</h:td></h:tr>
>    <h:tr align="left">
>     <xdc:author><h:td>Simon St. Laurent</h:td></xdc:author>
>     <xdc:price><h:td>31.98</h:td></xdc:price>
>     <xdc:pages><h:td>352</h:td></xdc:pages>
>     <xdc:date><h:td>1998/01</h:td></xdc:date>
>    </h:tr>
>   </h:table>
>  </xdc:bookreview>
> </h:body>
></h:html>
>
>I am wondering if the real problem here is the way in which the vocabularies
>are being mixed.  For instance, would it possbily have been better to do
>something like:
>
><h:html xmlns:xdc="http://www.xml.com/books";
>        xmlns:h="http://www.w3.org/HTML/1998/html4";>
> <h:head><h:title>Book Review</h:title></h:head>
> <h:body>
>  <h:table>
>   <h:tr align="center">
>    <h:td>Author</h:td><h:td>Price</h:td>
>    <h:td>Pages</h:td><h:td>Date</h:td></h:tr>
>   <h:tr align="left">
>    <h:td><h:span id="author">Simon St. Laurent</h:span></h:td>
>    <h:td><h:span id="price">31.98</h:span></h:td>
>    <h:td><h:span id="pages">352</h:span></h:td>
>    <h:td><h:span id="date">1998/01</h:span></h:td>
>   </h:tr>
>  </h:table>
>  <xdc:bookreview>
>   <xdc:title>XML: A Primer</xdc:title>
>   <xdc:author idref="author"/>
>   <xdc:price idref="price"/>
>   <xdc:pages idref="pages"/>
>   <xdc:date idref="date"/>
>  </xdc:bookreview>
> </h:body>
></h:html>
>
>or maybe...
>
><h:html xmlns:xdc="http://www.xml.com/books";
>        xmlns:h="http://www.w3.org/HTML/1998/html4";>
> <h:head><h:title>Book Review</h:title></h:head>
> <h:body>
>  <h:div xdc:field="bookreview">
>   <h:span style="visiblity:none"
>    xdc:field="title">XML: A Primer</h:span>
>   <h:table>
>    <h:tr align="center">
>     <h:td>Author</h:td><h:td>Price</h:td>
>     <h:td>Pages</h:td><h:td>Date</h:td></h:tr>
>    <h:tr align="left">
>     <h:td><span xdc:field="author">Simon St. Laurent</h:span></h:td>
>     <h:td><h:span xdc:field="price">31.98</h:span></h:td>
>     <h:td><h:span xdc:field="pages">352</h:span></h:td>
>     <h:td><h:span xdc:field="date">1998/01</h:span></h:td>
>    </h:tr>
>   </h:table>
>  </h:div>
> </h:body>
></h:html>
>
>I'm not sure than any of these are any better or worse (though I admit I'm
>not crazy about the id/idref version).  I guess the point is...  in the
>original XML above, are we really trying to figure out how to separate the
>vocabularies successfully, or are we really seeing a case where the design
>is bad to start with? (I'm not saying the example was bad, just asking a
>question.)
>

Probably a valid question, I'm not qualified enough to answer it.  My 
opinion: I wouldn't approach the problem this way at all.  Too much crap 
mixed into one document, too confusing, too ambiguous, too hard to 
read.  I'd create a stylesheet and a data source XML document that 
contains nothing but the bare minimum information and use the stylesheet 
to transform the data source document into HTML.

>4) Should a vocabulary be able to dictate how other vocabularies can be used
>with it?  I am talking about the general case where the specifics of a
>secondary vocabulary are not known.  For instance, can a vocabulary state
>that absolutely no elements, regardless of where they come from, may be
>within element <x>?  Another way of looking at this question is:  should a
>vocabulary explicitly state what is allowed for secondary vocabularies?  If
>vocabulary does not define this, what should the "default" behaviour be?
>

Once again, it really depends on what you want.  By default my schema 
documents always allow other vocabularies unless I have a really really 
good reason not to.  The only one I've found so far is that the 
Microsoft InfoPath tool only let's you create RichEdit controls if you 
only allow the XHTML namespace and mixed content for an element.  Other 
than that, I allow everything I don't know by default and just try to 
ignore the stuff I don't understand in my code.

Bryan





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS