| Author |
XML Schema Definition Problem
|
Mingwei Jiang
Ranch Hand
Joined: Feb 19, 2004
Posts: 63
|
|
I've encountered a very weird problem when using XML schema. I think the issue lies in the namespace definition, but I cannot figure it out. When I use noNamespaceSchemaLocation, it works fine, but when I defined a target name space, there will be validation errors in eclipse3.1 web tools platform saying "cvc-complex-type.2.4.a: Invalid content was found starting with element 'orderperson'. One of '{"" rderperson}' is expected." Could anyone help me on this? Below is the sample.xsd file And sample.xml lies below: Italic orderperson is where Eclipse says error. Thanks.
|
 |
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
|
|
Your options are: You can give it what it wants: <orderperson>""</orderperson> You can make the element entirely optional by modifying the Schema: <xs:element name="orderperson" type="xs:string" minOccurs="0" /> You have make a major revision your schema to allow an empty element. Something along the lines of (i.e. I didn't try this): Your schema requires a string. A string of length zero is an empty string which still needs to be represented as "". Empty content is basically the absence of elements � to have empty content your element has to be a complexType. To contain character data, the complexType contains simpleContent which itself contains an extension of string.
|
"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
|
 |
Mingwei Jiang
Ranch Hand
Joined: Feb 19, 2004
Posts: 63
|
|
Thank you guy! But actually I found the problem lies in the namespace definition. If I define a prefix in the xml file namespace definition and add the prefix to the root element, then it works. But why when I try to add that prefix to the subelement, it doesn't work again?
|
 |
 |
|
|
subject: XML Schema Definition Problem
|
|
|