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] Namespaces and XML Schema validation

[ Lists Home | Date Index | Thread Index ]

This link may be of help
http://www.xfront.com/ZeroOneOrManyNamespaces.html

H
-----Original Message-----
From: Rex Brooks [mailto:rexb@starbourne.com] 
Sent: 19 November 2002 19:47
To: Priscilla Walmsley; 'Peter Bergström'; xml-dev@lists.xml.org
Subject: RE: [xml-dev] Namespaces and XML Schema validation


Is it possible to have a number of schemata that are extensions of a 
primary base schema within a single namespace? Or, do you have to 
create serial namespaces to accommodate such a multi-part modular 
language structure? Since that is exactly what we are doing with 
Human Markup, it would helpful. We are currently in the 30-day public 
comment period for our first spec so we are no where close to moving 
on to the secondary base schema.

Thanks,
Rex


At 9:01 AM -0500 11/19/02, Priscilla Walmsley wrote:
>Hi Peter,
>
>Yes, you can only have one schema document per namespace, so you will 
>be required to have a.xsd, b.xsd, etc.
>
>>  PROBLEM 1
>>
>>
>>  Example document:
>>  <?xml version="1.0">
>>  <a1 xsi:noNamespaceSchemaLocation="a.xsd"
>>      xmlns:b="http:\\example.org\b\"
>>      xmlns:c="http:\\example.org\c\">
>>    <b:b1>This is element B1 from namespace B</b:b1>
>>    <a2>This is the second element from schema a</a2>
>>    <c:c1>This element is from namespace c</c:c1>
>>  </a1>
>
>a.xsd would look something like this:
>
><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             xmlns:b="http:\\example.org\b\"
>             xmlns:c="http:\\example.org\c\">
><xsd:import namespace="http:\\example.org\b\" schemaLocation="b.xsd"/> 
><xsd:import namespace="http:\\example.org\c\" schemaLocation="c.xsd"/>
>
><xsd:element name="a1" type="a1Type"/>
><xsd:complexType name="a1Type">
>   <xsd:sequence>
>     <xsd:element ref="b:b1"/>
>     <xsd:element name="a2" type="xsd:string"/>
>     <xsd:element ref="c:c1"/>
>   </xsd:sequence>
></xsd:complexType>
>
>and b.xsd and c.xsd would declare the b1 and c1 elements, globally.
>
>>  PROBLEM 2
>>
>>  Can I nest the namespaces in such an XML document, so that  elements 
>> from one  namespace contains elements from other namespaces, and 
>> still  validate my XML
>>  document against one or several XML Schemas?
>
>Yes, in this case you could have a.xsd import the b namespace, and 
>b.xsd import the c namespace.
>
>>  PROBLEM 3
>>
>>  Can elements from one namespace occur several times in a  hierarchy 
>> where  elements from other namespaces occur as fathers, i.e. true
>>  nesting, and
>>  still validate my XML document against one or several XML
>>  Schemas? And how
>>  would the XML Schemas that defines those namespaces look like?
>
>Yes, in that case a.xsd could import the b namespace, and b.xsd could 
>import the a namespace.  Same thing with b and c. (there is no rule 
>that says "circular imports" are not allowed; in fact, they are 
>necessary.)
>
>
>>  PROBLEM 4
>>
>>  Can I, using the example from my problem 3, enforce (through
>>  validation)
>>  that instances are created with exactly those elements,  occuring 
>> just one  time each, with one single XML Schema?
>
>I assume you mean one single schema _document_ (since an XML Schema can 
>be made up of more than one document, as we have seen above).  No, you 
>can't - the best you could do is put wildcards where you want the 
>elements from other namespaces to go.  Wildcards will allow you to 
>constrain the namespace and number of elements that appear, but will 
>not validate those elements without a schema document for that 
>namespace.
>
>
>The examples from my XML Schema book are online at:
>
>http://www.datypic.com/books/DefXMLSchema/Examples.html
>
>I can't guarantee they're the exact same structure as your examples, 
>but they might help.
>
>Hope that helps!
>Priscilla
>
>-----------------------------------------------------
>Priscilla Walmsley             priscilla@walmsley.com
>Author, Definitive XML Schema     (Prentice Hall PTR)
>-----------------------------------------------------
>
>
>-----------------------------------------------------------------
>The xml-dev list is sponsored by XML.org <http://www.xml.org>, an 
>initiative of OASIS <http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To subscribe or unsubscribe from this list use the subscription
>manager: <http://lists.xml.org/ob/adm.pl>


-- 
Rex Brooks
Starbourne Communications Design
1361-A Addison, Berkeley, CA 94702 *510-849-2309 http://www.starbourne.com *
rexb@starbourne.com




_______________________________________________________________________ 

The information contained in this email is confidential and is intended 
for the use of the addressee only. Any unauthorised dissemination or 
copying of this email, and any use of disclosure of information 
contained in it, is strictly prohibited and may be illegal. 

Please let us know immediately by telephone if the email has been sent 
to you in error (+44 1481 711166). 
________________________________________________________________________




 

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

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