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] Namespace trouble (was xsd : root element not found)

[ Lists Home | Date Index | Thread Index ]

Thanks Jeff.

I need a better understanding of namespaces and how to make them work in a
modular XML Schema environment.

It seems to me that what you're saying is that all of my elements for this
xml schema must exist in the same namespace. Obviously that's not what I'm
doing since my schema is made up of modular elements that can be combined to
form new schemas as needed for new types of publications (I'm attempting to
model several types of publications with my modular schema design).

Where can I look to find out how to do what I'm attempting? Or in lieu of
that, what more information would the group need to point me in the right
direction?

Thanks,

Darren

-----Original Message-----
From: Jeff Rafter [mailto:lists@jeffrafter.com] 
Sent: Tuesday, May 23, 2006 12:44 PM
To: Darren Hall
Cc: 'XML-Dev Mailing list'
Subject: Re: [xml-dev] Namespace trouble (was xsd : root element not found)

You haven't given us quite enough to give you the full solution. But the 
problem is evident. The <article> element must be qualified with a 
different namespace (specifically: 
"http://globals.namespace.org/content/xml/xsd/v10/article/";) so 
something like:

<art:article 
xmlns:art="http://globals.namespace.org/content/xml/xsd/v10/article/"/>

should work. Right now, because of the default xmlns, you are suggesting 
that <article> is in the 
"http://globals.namespace.org/content/xml/xsd/v10/article/single/"; 
namespace.


Keep in mind, you declared a namespace in article.xsd. There that global 
element definition must be qualified with that namespace name regardless 
of where it is referenced. You import it into your schema and then reuse 
it using a ref, so it definitely must be qualified with the original 
namespace.

there are workarounds to have separate modules and one global namespace. 
But we would need to see more to give you the full breakdown.

Cheers,
Jeff Rafter


Darren Hall wrote:
> 
> Hello again.
> 
> I'm having trouble validating an xml file I've created against an xsd I've
> made. I'm trying to use a modular design in my XML Schema so that I can
get
> reuse out of elements I've defined. I'm using XMLSpy Home as my validation
> tool.
> 
> When I attempt to validate my xml document, I'm getting the message that
> it's hitting an unexpected element. Ironically, the unexpected element is
in
> fact the element it should be expecting. I believe the problem may be
> related to namespace (which I'm not very good with).
> 
> Can anyone help me with this, or point me in the direction of a page that
> might help? Any help would be appreciated. Thanks.
> 
> Darren
> 
> **relevant code**
> 
> [from article.xml - the document being validated]
> 
> <?xml version="1.0" encoding="utf-8"?>
> <standaloneArticle
> xmlns="http://globals.namespace.org/content/xml/xsd/v10/article/single/";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  
>
xsi:schemaLocation="http://globals.namespace.org/content/xml/xsd/v10/article
> /single/ standaloneArticle.xsd">
>   <article>
> ...
>   </article>
> </standaloneArticle>
> 
> ----------------------------------
> [from standaloneArticle.xsd]
> <?xml version="1.0" encoding="UTF-8" ?> 
> <xs:schema
>
targetNamespace="http://globals.namespace.org/content/xml/xsd/v10/article/si
> ngle/"
>   xmlns:sar="http://globals.
> namespace.org/content/xml/xsd/v10/article/single/"
>   xmlns:art="http://globals.namespace.org/content/xml/xsd/v10/article/";
>   xmlns:ref="http://globals.namespace.org/content/xml/xsd/v10/reference/";
>   xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>   elementFormDefault="qualified" 
>   attributeFormDefault="qualified">
>   <!-- import of external definitions -->
>   <xs:import
> namespace="http://globals.namespace.org/content/xml/xsd/v10/article/";
> schemaLocation="article.xsd"/>
>   <xs:import
> namespace="http://globals.namespace.org/content/xml/xsd/v10/reference/";
> schemaLocation="reference.xsd"/>
>   <!-- definition of complex type elements -->
>   <xs:element name="standaloneArticle">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element ref="art:article" minOccurs="1" maxOccurs="1"/>
>         <xs:element ref="ref:reference" minOccurs="1" maxOccurs="1"/>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> ----------------------------------
> [from article.xsd]
> <?xml version="1.0" encoding="UTF-8" ?> 
> <xs:schema
>
targetNamespace="http://globals.namespace.org/content/xml/xsd/v10/article/";
>  
> xmlns:art="http://globals.namespace.org/content/xml/xsd/v10/article/";
>  
> xmlns:aut="http://globals.namespace.org/content/xml/xsd/v10/author/";
>  
> xmlns:sty="http://globals.namespace.org/content/xml/xsd/v10/style/";
>            xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
>            elementFormDefault="qualified" 
>            attributeFormDefault="qualified">
>   <!-- import of external definitions -->
> ...
> </xs:schema>
> 
> 
> 
> -----------------------------------------------------------------
> 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://www.oasis-open.org/mlmanage/index.php>
> 
> 

-----------------------------------------------------------------
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://www.oasis-open.org/mlmanage/index.php>








 

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

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