Different XSD representation of an element.
-
Hi All, I used an Altova XMLSpy tool generate an XSD file for my XML file. The xsd equivalent for an simple xml element "Mfg" generated via the tool was
<xs:element name="Mfg">
xs:simpleType
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>I found out that modifying the above xsd to the one below just works fine.
<xs:element name="Mfg" type="xs:string"/>
Just wanted to know if these 2 XSD representations for the xml element are the same or are they different. Do the elements xs:simpleType, xs:restriction above have any signifance int he above mentioned scenario? (Actually tried going through MSDN but conldn't infer much info). It would be of great help if somebody points out the differences between the 2 if any and brief on it's significance.
-
Hi All, I used an Altova XMLSpy tool generate an XSD file for my XML file. The xsd equivalent for an simple xml element "Mfg" generated via the tool was
<xs:element name="Mfg">
xs:simpleType
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>I found out that modifying the above xsd to the one below just works fine.
<xs:element name="Mfg" type="xs:string"/>
Just wanted to know if these 2 XSD representations for the xml element are the same or are they different. Do the elements xs:simpleType, xs:restriction above have any signifance int he above mentioned scenario? (Actually tried going through MSDN but conldn't infer much info). It would be of great help if somebody points out the differences between the 2 if any and brief on it's significance.
They are exactly the same because the restriction specified doesn't actually restrict the base type (i.e. xs:string). Here's an example of a restriction on a string using a regular expression pattern that could be used as a variable or type name:
xs:simpleType
<xs:restriction baseType="xs:string">
<xs:pattern value="[A-Za-z][A-Za-z0-9_]*"/>
</xs:restriction>
</xs:simpleType>[edit]I recommend downloading the Essential XML Quick Reference PDF[^], as it's a very easy to use reference to XML technologies, including XSD.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
They are exactly the same because the restriction specified doesn't actually restrict the base type (i.e. xs:string). Here's an example of a restriction on a string using a regular expression pattern that could be used as a variable or type name:
xs:simpleType
<xs:restriction baseType="xs:string">
<xs:pattern value="[A-Za-z][A-Za-z0-9_]*"/>
</xs:restriction>
</xs:simpleType>[edit]I recommend downloading the Essential XML Quick Reference PDF[^], as it's a very easy to use reference to XML technologies, including XSD.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Oh. I see. Thanks for the info.