Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Composition by extension in namespaced schema

From: "Michael Kay" <mike@--------.--->
To: "'Gavin Kistner'" <phrogz@---.--->
Date: 3/14/2008 9:05:00 PM

For some strange reason which I've never understood, local element
declarations (i.e. <element name="x"/> within a complex type) default to
being in no namespace, rather than defaulting to the target namespace of the
schema. Most people change this default by adding

elementFormDefault="qualified"

to the xs:schema element.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: xmlschema-dev-request@w... 
> [mailto:xmlschema-dev-request@w...] On Behalf Of Gavin Kistner
> Sent: 14 March 2008 20:35
> To: Michael Kay
> Cc: xmlschema-dev@w...
> Subject: RE: Composition by extension in namespaced schema
> 
> 
> On Friday, March 14, 2008, at 12:24PM, "Michael Kay" 
> <mike@s...> wrote:
> >> I need to use a targetNamespace (or is it an xmlns?) in my 
> schema so 
> >> that I can validate other files without having to add 
> >> noNamespaceSchemaLocation to those files. Can someone help me 
> >> understand the core issue here, and (especially) how to modify the 
> >> file to accomplish the goal?
> 
> >The type is in a namespace, so the reference to it needs to 
> be prefixed:
> >
> >> <?xml version="1.0" encoding="UTF-8"?> <xs:schema 
> >> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >> targetNamespace="http://www.foo.com/"
> >  xmlns:tgt="http://www.foo.com/">
> >>   <xs:complexType name="mammal" />
> >>   <xs:element name="dog">
> >>     <xs:complexType><xs:complexContent>
> >>     	<xs:extension base="tgt:mammal" />
> >>     </xs:complexContent></xs:complexType>
> >>   </xs:element>
> >> </xs:schema>
> 
> Thank you again; that (oh so simple, and now understandable, 
> change) fixed the validation of the XSD itself. However, when 
> I try to validate an XML document against this schema, I get 
> a new (confusingly-reported) error:
> 
> <!-- foo.xsd -->
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="http://www.foo.com" xmlns:foo="http://www.foo.com">
>   <xs:element name="root">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element ref="foo:native"/>
>         <xs:element 
> name="bjork"><xs:simpleType><xs:restriction base="xs:string" 
> /></xs:simpleType></xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
>   <xs:element name="native"/>
> </xs:schema>
> 
> <!-- test.xml -->
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="http://www.foo.com foo.xsd" 
> xmlns="http://www.foo.com">
>   <native />
>   <bjork>Hello There</bjork>
> </root>
> 
> <!--
>   SystemID: E:\test.xml
>   Location: 6:4
>   Description: cvc-complex-type.2.4.a: Invalid content was 
> found starting with element 'bjork'. One of '{bjork}' is expected.
>   URL: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
> -->
> 
> 
> As shown above, the 'native' element in the sequence works 
> with the namespace, but the inline element does not. Is this 
> a true validation error, or is this a bug in the validator 
> that I need to work around by just moving all elements to be 
> defined at the top level?
> 
> 


From petexmldev@c... Fri Mar 14 21:28:48 2008
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent