Basic XML Schema and Valid XML generation
Hi,
I have an XML schema file as below. Creating and parsing the XML results works but I don't understand how to validate. I understand the concept of a namespace but not the implementation. Why do I need to refer to "http://www.w3.org/2001/XMLSchema"? I just want to create a validation based on my schema file below. I am not interested in qualified versus non qualified unless I have to have to address that in terms of my validation. Please tell me how the XML file must be formed also. I have sample extract below the schema. The XML formation is from java and it is correct from my solution. If I need to remove the data element from the schema please show me. Should there be attributes in the XML referring to the schema?
The XML schema doc is similar to:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="CoolItems">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="CoolItem">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="object" type="xsd:string" />
<xsd:element name="name" type="xsd:string" />
<xsd:element name="instance" type="xsd:int" />
<xsd:element name="time" type="xsd:decimal" />
<xsd:element name="data">
<xsd:complexType>
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="value" type="xsd:int" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="xsi:noNamespaceSchemaLocation" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
xml: <?xml version="1.0" encoding="UTF-8"?>
<CoolItems>
<CoolItem>
<object>birchTree</object>
<name>myName</name>
<time>1295183422931</time>
<type>String</type>
<value>84</value>
</CoolItem>
</CoolItems>
Ben
|