« Return to Thread: xmlbeans error

xmlbeans error

by smx_ :: Rate this Message:

Reply to Author | View in Thread

Hello,
I am trying to create document object
RequestDocument doc2 = RequestDocument.Factory.parse("Input.xml");
from the following xml  schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xmlbeans.apache.org/myschema"
        xmlns:mc="http://xmlbeans.apache.org/myschema"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified">
       
        <xs:element name="request" type="mc:requestType">
        </xs:element>
        <xs:complexType name="requestType">
                <xs:sequence>
                        <xs:element name="serviceName" type="xs:string"/>
                        <xs:element name="serviceMethod" type="xs:string"/>
                </xs:sequence>
        </xs:complexType>
</xs:schema>

I see the following exception:
( here is Input.xml)
<xml-fragment><any:serviceName xmlns:any="http://xmlbeans.apache.org/samples/any">test_serviceName</any:serviceName><any:serviceMethod xmlns:any="http://xmlbeans.apache.org/samples/any">test_serviceMethod</any:serviceMethod></xml-fragment>
!!!!
error: The document is not a request@http://xmlbeans.apache.org/samples/any: multiple document elements
org.apache.xmlbeans.XmlException: error: The document is not a request@http://xmlbeans.apache.org/samples/any: multiple document elements
        at org.apache.xmlbeans.impl.store.Locale.verifyDocumentType(Locale.java:452)
        at org.apache.xmlbeans.impl.store.Locale.autoTypeDocument(Locale.java:357)
        at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:709)
        at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:690)
        at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:677)
        at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:208)
        at org.apache.xmlbeans.samples.any.RequestDocument$Factory.parse(Unknown Source)
        at Test.main(Test.java:30)

Can someone point me what the nature of problem is with that schema?
Thank you for the help,

 « Return to Thread: xmlbeans error