How could one make a root element to wrap all the complexType elements? I tried the followings and it did NOT work. Thank you ==== <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"> <xs:element name="root"> <--- NOT working <xs:complexType name="a"> .... </xs:complexType> <xs:complexType name="b"> .... </xs:complexType> <xs:complexType name="c"> .... </xs:complexType> </xs:element> <--- NOT working </xs:schema>
Your sample code puzzles me. Are you looking to use Java to create a DOM document with a root element of "xs:schema" which in turn has a single child element having a local name "root", and then create child elements for "root" in the "xs" namespace having a local name of "complexType",
Or
are you trying to transform one XML document to another using XSLT giving these results?
Since your root element contains many other elements, first it needs to be defined as complextype. And define a,b and c as complextypes. It could be written as following:
And you can also define a and b complexTypes seperately and refer them in your root definition as below: <xs:element name="aType"> <xs:complexType> .... </xs:complexType> </xs:element>
Oh.. you are right Tom. I didn't notice that. I was struggling to write that code in this forum's editor,with alignments.. So depended on copy paste. Mistake happened becuase of that.
But that doesn't work if I try to make a root element encompassing all those elements. For example, please make a root element out of the following: === <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"> <xs:complexType name="a" abstract="true"> <xs:sequence> ... </xs:sequence> </xs:complexType>
Thanks for your patience. Is it possible to put a root element in the xsd file (instead in the xml file) in your example? I am using xmlspy to generate the xml file from the xsd file and it complains of no root element. What I have is more than 10 complexType elements, including those containing 'extension'. I still have problem putting a root element in the xsd... at this point, I am not so sure it's possible or not. Thanks much. [ September 27, 2006: Message edited by: thomas silver ]
But that didn't work. Please see my first post. Maybe I should give it up on this one. Thanks anway though. [ September 29, 2006: Message edited by: thomas silver ]
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad: