Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Schema validation with complex type

Status
Not open for further replies.

BAbram

Programmer
Feb 18, 2003
4
US
Hi all,

Let say I have the following XML snippet:

<SubRoot>
<One/>
<Two/>
</SubRoot>


This part is validated against the following schema (relevant part):


<xs:element name="SubRoot" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="One" type="sdt:d_Double"/>
<xs:element name="Two" type="sdt:d_String"/>

</xs:sequence>
</xs:complexType>
</xs:element>


The types are defined as:


<xsd:simpleType name="d_Double">
<xsd:restriction base="xsd:double">
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="d_String">
<xsd:restriction base="xsd:string">
</xsd:restriction>
</xsd:simpleType>


Now, this validation fails since <One> is a "double" and the tag is empty... If I would change it to type string it works fine. Does anyone know why this is? Also any pointer to where I could find information about validation and what would be the expected result in a case like this (for various types).

Thank you
Bjorn
 
I guess because "" is a valid string, whereas its not a double. W3C is always a good place to start looking for info:


Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top