Am I using xs:anyType correctly?
Posted: Wed May 24, 2006 5:34 pm
I am trying to use a published Schema for a XRPC interface. The problem is I can't even validate the example XML they provide with their own schema. Either their schema has a flaw, or the schema validator used by Oxygen7.1 isn't working.
I lean toward the first so I did a simple example that contains the problem
Here's the XML file
What I need is a schema that just address the 'mph1' namespace and ignores all others ('mph2' in this example)
First, this schema works. It does what I expect xs:anyType to do.. Ignore the NewFirst element and all that it contains.
Now, this is a modification to that working schema that reflects the published schema. It's supposed to do the same thing, but using the constructs as used by the published schema.
The main difference is rather than an inline type, I use a complexType that resolved to xs:anyType. It should be the same as the first, right?
It's not. I get an error:
Looks right to me.. the content of the second element should still resolve to xs:anyType.
Who's broken? The publiushed schema or the xsd validator?
I lean toward the first so I did a simple example that contains the problem
Here's the XML file
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:mph1 ../XSD/xsd-test-02.xsd" xmlns="urn:mph1">
<first>
<second>
<NewFirst xmlns="urn:mph2">
<NewSecond/>
</NewFirst>
</second>
</first>
</root>
First, this schema works. It does what I expect xs:anyType to do.. Ignore the NewFirst element and all that it contains.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="urn:mph1" xmlns:mph1="urn:mph1">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="mph1:first"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="first">
<xs:complexType>
<xs:sequence>
<xs:element ref="mph1:second"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="second" type="xs:anyType"/>
</xs:schema>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="urn:mph1" xmlns:mph1="urn:mph1">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="mph1:first"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="first">
<xs:complexType>
<xs:sequence>
<xs:element ref="mph1:second"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="second" type="mph1:secondType"/>
<xs:complexType name="secondType">
<xs:complexContent>
<xs:restriction base="xs:anyType"/>
</xs:complexContent>
</xs:complexType>
</xs:schema>
It's not. I get an error:
Code: Select all
SystemID: D:\mphare\Development\FW6500\XML\SchemaTest\xsd-test-01.xml
Location: 9:18
Description: cvc-complex-type.2.1: Element 'second' must have no character or element information item [children], because the type's content type is empty.
URL: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
Who's broken? The publiushed schema or the xsd validator?