xsd schema definition problems

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi.
Dont know if this is the right place to post this question, but cant find any better place in this forum :)
I m having a hard time understanding how to create xsd schema definitions. I m trying to do it on my own, and not with the xsd.exe. Different validators results in different results when I try to validate xml examples from an xsd schema.
This is my xml:
<Assignments><br/>
<Assignment><br/>
<Identifier Value="99999" /><br/>
<ActivationMethod Value="Automatic" /><br/>
<ActivationTime Value="13-17-30-00" /><br/>
<Attributes><br/>
<Attribute><br/>
<Name Value="Large" /><br/>
</Attribute><br/>
<Attribute><br/>
<Name Value="Small" /><br/>
</Attribute>
</Attributes><br/>
</Assignment><br/>
<br/>
</Assignments>

This is the basic xml I have. Now I want an xsd schema that can validate this. And the ActivationTime value should match the regex that would look something like this
<span>
<pre><span style="color:#ff0000 "d{2}-d{2}-d{2}-d{2}"
[/code]



What I have now is this:
<?xml version="1.0" encoding="ISO-8859-1" ?><br/>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <br/>
<br/>
<xs:element name="Assignments <br/>
<xs:complexType><br/>
<xs:choice minOccurs="0" maxOccurs="unbounded <br/>
<br/>
<xs:element name="Assignment <br/>
<xs:complexType><br/>
<xs:sequence><br/>
<br/>
<xs:element name="Identifier" minOccurs="0" maxOccurs="unbounded <br/>
<xs:complexType><br/>
<xs:attribute name="Value" type="xs:string" /><br/>
</xs:complexType><br/>
</xs:element><br/>
<br/>
<br/>
<xs:element name="ActivationMethod" minOccurs="0" maxOccurs="unbounded <br/>
<xs:complexType><br/>
<xs:attribute name="Value" type="xs:string" /><br/>
</xs:complexType><br/>
</xs:element><br/>
<br/>
<br/>
<xs:element name="ActivationTime" minOccurs="0" maxOccurs="unbounded <br/>
<xs:complexType><br/>
<xs:attribute name="Value" type="xs:customtype" /><br/>
</xs:complexType><br/>
</xs:element><br/>
<br/>
<br/>
</xs:sequence><br/>
</xs:complexType><br/>
</xs:element><br/>
<br/>
<br/>
</xs:choice><br/>
</xs:complexType><br/>
</xs:element><br/>
<br/>
<xs:simpleType name="ssnumber <br/>
<xs:restriction base="xs:string <br/>
<xs:length value="11" /><br/>
<xs:pattern value="d{2}-d{2}-d{2}-d{2}"/><br/>
</xs:restriction><br/>
</xs:simpleType><br/>
<br/>
<br/>
<br/>
</xs:schema>

But this generates a System.Xml.Schema.XmlSchemaValidationException saying "Type http://www.w3.org/2001/XMLSchema:ssnumber is not declared, or is not a simple type."
I ve fiddled with this for many frustrating hours now. Really hope you can help me understand this :)
Thanks alot
Lars


View the full article
 
Back
Top