I'd been 3 years since I messed with schemas and I remember them being very particular about name space prefixes and all. I also remember complex types not parsing so easily without unrolling when using the XML editor in Eclipse (I have Indigo).
So could one is you XML gurus look at my XML file and tell me what is wrong with the prepended XSD XML schema?
Thanks.
Ciao
+++++
Eclipse complains of:
The markup in the document following the root element must be well-formed.
I should point out I created the XML by hand and autogenerated the XML from it at:
http://www.xmlforasp.net/codebank/system_xml_schema/buildschema/buildxmlschema.aspx
(Seperate Complex Types: as I did manually 3 years ago with Amazon's Amazon Seller Central XML files manually)
If seems to me as ref should be used in one case but I'll defer to the experts.
+++++
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="idioms" type="idiomsType" />
<xsd:complexType name="idiomsType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="idiom" type="idiomType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="idiomType">
<xsd:sequence>
<xsd:element name="phrase" type="xsd:string" />
<xsd:element name="meaning" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<idioms>
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching.</meaning>
</idiom>
</idioms>
OK, update. My shortcut of including XSD inline with XML is illegal. So I put it back in XSD file. I also learned that I can't start a prefix with xml so I changed it to 'tc'.
The XSD now is correct (in the same style as I unrolled Amazon Seller Central XSDs).
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:tcidioms="urn:tcidioms" targetNamespace="urn:tcidioms" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="idioms" type="tcidioms:idiomsType"/>
<xsd:complexType name="idiomsType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="idiom" type="tcidioms:idiomType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="idiomType">
<xsd:sequence>
<xsd:element name="phrase" type="xsd:string" />
<xsd:element name="meaning" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
But I have trouble trying to include this im my XML file which now looks like this (the XML & XSD are in the same directory):
It complains: No grammar constraints (DTD or XML schema) detected for the document.
Meaning the 2 line in my XML document isn't correct. I've tried several variants to include this file but none have worked. Keep in mine this XML (and XSD) is going to be read off a local file systems rather than via http. Will it still validate in this manner?
<?xml version="1.0" encoding="utf-16"?>
<idioms xmlns:tcidioms="urn:tcidioms" targetNamespace="urn:tcidioms ./EnglishIdioms.xsd">
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.
</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching, going too far
and getting into trouble
or
failing.
</meaning>
</idiom>
</idioms>
Visual Studio 2010 (it created the schema Russian Doll Style):
The XML file although set to use the schema in the VS2010 interface doesn't show that in the code?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="idioms">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="idiom">
<xs:complexType>
<xs:sequence>
<xs:element name="phrase" type="xs:string" />
<xs:element name="meaning" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="utf-8"?>
<idioms>
<idiom>
<phrase>A bit much</phrase>
<meaning>Excessive or annoying.</meaning>
</idiom>
<idiom>
<phrase>A bridge too far</phrase>
<meaning>Act of overreaching.</meaning>
</idiom>
<idiom>
<phrase>A chain is no stronger than its weakest link</phrase>
<meaning>The weakest part of an object is it's strength.</meaning>
</idiom>
</idioms>