Re: combining schemas

Eric van der Vlist <[email protected]>
Newsgroups gmane.text.xml.relaxng.general
Organization Dyomedea (http://dyomedea.com)
Message-ID <1069829754.1097.270.camel@delleric>
On Wed, 2003-11-26 at 01:53, Bruce D'Arcus wrote:
> OK, I finally got it to work correctly, more or less.  

Good!

> Thanks all!
> 
> Here's an example fragment created using nxml mode:
> 
>      <extension xmlns:bn="http://refdb.sourceforge.net/biblio-notes-ns">
>        <bn:biblio-notes>
> 	<bn:note user="darcusb">
> 	  <bn:para>Got it to <bn:emphasis>work!</bn:emphasis></bn:para>
> 	</bn:note>
>        </bn:biblio-notes>
>      </extension>
> 
> I just have a couple of questions remaining.
> 
> The first is about namespaces.  In the biblio-notes schema, I have the 
> following namespace definition:
> 
> 	default namespace  = "http://refdb.sourceforge.net/biblio-notes-ns"
> 
> The most obvious question is whether this is the correct way to specify 
> the namespace in this circumstance.

Yes.

> Also, should I be requiring the namespace prefix here, when the 
> namespace is defined on the extension element?  

The namespaces rec states that prefixes are just shortcuts assigned to
namespaces identifiers and that their values are not significant. As a
result, you can't require a namespace prefix with RELAX NG (nor with W3C
XML Schema). To require a specific prefix, you'd need to use either DTDs
or Schematron but, again, that would not be conform to the intention of
namespaces.

> In this example, if remove the namespace prefix from the declaration 
> and the included elements, I get an "unknown element" error on the
> extension element.

What do you mean? 

Per the namespaces spec, this is a different document that should be
invalid:

     <extension>
       <biblio-notes>
        <note user="darcusb">
          <para>Got it to <emphasis>work!</emphasis></para>
        </note>
       </biblio-notes>
     </extension>

But this one is equivalent to your snippet and it should be valid:

     <extension>
       <biblio-notes
xmlns="http://refdb.sourceforge.net/biblio-notes-ns">
        <note user="darcusb">
          <para>Got it to <emphasis>work!</emphasis></para>
        </note>
       </biblio-notes>
     </extension>

> Finally, as I recall nxml mode normally automatically completes the 
> namespace declaration.  it does not do so in this circumstance.  Is 
> this likely a limitation of nxml, or a problem in my definition?

Your definition looks good.

Eric
-- 
Read me on XML.com.
                                            http://www.xml.com/pub/au/74
Upcoming XML schema languages tutorials:
 - Philadelphia -full day- ( 7/12/2003)        http://masl.to/?V28612FC5
 - Santa Clara  -half day- (15/03/2004)        http://masl.to/?J24916E96
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.