Re: Attributes and Default Namespaces

Hi Mukul,

I'm afraid I disagree with your assessment here.  After a bit of digging I 
think the following is the issue.

In the schema for schemas, xs:anyType is declared as:

  <xs:complexType name="anyType" mixed="true">
    <xs:annotation>
      <xs:documentation>
   Not the real urType, but as close an approximation as we can
   get in the XML representation</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
    </xs:sequence>
    <xs:anyAttribute processContents="lax"/>
  </xs:complexType>

The issue is the processContents="lax" on the two wildcards.

When the XML parser finds <Row> in the results, it realises its got a 
definition for that and starts validating against it.  Then we're back to 
the issue that the attributes should be qualified because they are global, 
but they are not because the default namespace doesn't affect attributes.

For the record, on Visual Studio 2008 the following XML validates fine:

<Results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://raid.raidllp.com" >
<RowOther>
<FieldOther FieldID="1234" FieldType="Ticker" Name="Ticker">CARLB DC 
Equity</FieldOther>
<FieldOther FieldID="1234" FieldType="String" Name="Name">CARLSBERG 
AS-B</FieldOther>
</RowOther>
</Results>

HTH,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
----- Original Message ----- 
From: "Mukul Gandhi"
To: "Neil Beddoe"
Sent: Saturday, November 13, 2010 1:48 AM
Subject: Re: Attributes and Default Namespaces



On Fri, Nov 12, 2010 at 12:30 PM, Mukul Gandhi  wrote:
> <xs:element name="Results">
> <xs:annotation>
> <xs:documentation>Comment describing your root
> element</xs:documentation>
> </xs:annotation>
> </xs:element>

There is a slight correction I want to make to what I wrote earlier.
For an XML schema fragment like above the schema type of element
"Results" is indeed xs:anyType. But if there is an "non null"
targetNamespace attribute on xs:schema instruction, in such a schema I
think a compliant XML Schema validator must report validation errors
(as you originally got -- so that was correct I think). This is so
because, if in instance document we have something like:

<Results xmlns="http://raid.raidllp.com">
    ...
</Results>

then the schema validator won't be able to find an element declaration
for element "Results" (in the specified namespace), since the schema
type of "Results" must be in namespace http://raid.raidllp.com (but
for an element declaration like <xs:element name="Results" /> the
schema type is xs:anyType and this is in namespace
http://www.w3.org/2001/XMLSchema).




-- 
Regards,
Mukul Gandhi

Received on Saturday, 13 November 2010 09:09:42 UTC