You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Manoj Pansare <Ma...@mathworks.com> on 2011/06/16 16:25:48 UTC

XmlException : multiple document elements

HI,

I am getting the error XmlException : The document is not a xml-fragment@http://something/Buildtools: multiple document elements
(Full trace is below).

The xml used is :


<xml-fragment>
      <con:platforms xmlns:con="http://something/Buildtools">
            <con:windows>
                  <con:architectures>
                        <con:architecture name="win64">
                              <con:properties>
                                    <con:item name="PATH" value="$BUILD_TOOLS/1.2/win32/bin"
                                          export="always" action="add" />
                              </con:properties>
                        </con:architecture>
                        <con:architecture name="win32">
                              <con:properties>
                                    <con:item name="PATH" value="/bin" export="always"
                                          action="add" />
                                    <con:filepath name="C_INCLUDE_PATH" value="/include"
                                          export="always" />
                                    <con:string name="GHS_LMHOST" value="@ghlicencsesrv.com"
                                          export="always" />
                              </con:properties>
                        </con:architecture>
                  </con:architectures>
                  <con:properties>
                        <con:filepath name="MATLAB" value="$MW_INSTALL" export="always" />
                        <con:item name="PATH" value="$BUILD_TOOLS/MKSTK_9.0p2/mksnt"
                              export="always" action="add" />
                        <con:string name="MWE_MSVS_VERSION" value="8.00" export="always" />
                  </con:properties>
            </con:windows>
            <con:unix>
                  <con:architectures>
                        <con:architecture name="glnx86">
                              <con:properties>
                                    <con:item name="PATH" value="$BUILD_TOOLS " export="always"
                                          action="add" />
                                    <con:filepath name="MANPATH" value="$MANPATH" export="always" />
                                    <con:string name="GHS_LMHOST" value="@ghlicencsesrv.com"
                                          export="always" />
                              </con:properties>
                        </con:architecture>
                        <con:architecture name="glnxa64">
                              <con:properties>
                                    <con:item name="PATH" value="/bin" export="always"
                                          action="add" />
                                    <con:filepath name="MANPATH" value=" $MANPATH"
                                          export="always" />
                                    <con:string name="BAT_RSH" value="/ /bin/rsh" export="always" />
                              </con:properties>
                        </con:architecture>
                        <con:architecture name="maci">
                              <con:properties>
                                    <con:item name="PATH" value="$BUILD_TOOLS/bin" export="always"
                                          action="add" />
                                    <con:integer name="BUILD_LEOPARD" value="1" export="always" />
                                    <con:string name="BAT_RSH" value="/rsh" export="always" />
                                    <con:filepath name="BAT_STALL_CAPTURE" value="$MW_TOOLS/share/SnagNSave"
                                          export="always" />
                              </con:properties>
                        </con:architecture>
                        <con:architecture name="maci64">
                              <con:properties>
                                    <con:item name="PATH" value="/bin" export="always"
                                          action="add" />
                                    <con:integer name="MACI64" value="1" export="always" />
                                    <con:string name="BAT_RSH" value="/rsh" export="always" />
                                    <con:filepath name="BAT_STALL_CAPTURE" value="$MW_TOOLS/share/SnagNSave"
                                          export="always" />
                              </con:properties>
                        </con:architecture>
                        <con:architecture name="sol64">
                              <con:properties>
                                    <con:item name="PATH" value="/bin" export="always"
                                          action="add" />
                                    <con:filepath name="MANPATH" value="$MANPATH" export="always" />
                              </con:properties>
                        </con:architecture>
                  </con:architectures>
                  <con:properties>
                        <con:string name="LANG" value="" export="always" />
                        <con:integer name="PATCH_GET" value="0" export="always" />
                        <con:filepath name="BAT_PERL" value="$MW_TOOLS/share/batperl"
                              export="always" />
                  </con:properties>
            </con:unix>
      </con:platforms>
      <con:properties xmlns:con="http://something/Buildtools">
            <con:integer name="BH_USE_WP64_WIN64" value="1" export="always" />
            <con:filepath name="BUILD_HARNESS" value=" $MW_ARCH"
                  export="always" />
            <con:item name="PATH" value="$PACKAGE_HARNESS/bin" export="always"
                  action="add" />
            <con:string name="ROOT_3P_BASE" value="/3rdparty" export="always" />
            <con:list name="nodeGroup" export="never">
                  <con:li value="$nodePlatform" />
                  <con:li value="$stageName" />
            </con:list>
            <con:boolean name="jobSterile" value="0" export="never" />
            <con:string name="nextCluster" value="Bbatmain" export="never"
                  action="add" />
      </con:properties>
</xml-fragment>









The xsd goes something like this:


<xs:schema xmlns:con="http://something/Buildtools" xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://something/Buildtools">
      <xs:element name="windows">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:architectures" />
                        <xs:element ref="con:properties" />
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="unix">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:architectures" />
                        <xs:element ref="con:properties" />
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="string">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:string" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
                  <xs:attribute name="action" type="xs:string" />
            </xs:complexType>
      </xs:element>
      <xs:element name="properties">
            <xs:complexType>
                  <xs:choice>
                        <xs:sequence>
                              <xs:choice>
                                    <xs:sequence>
                                          <xs:element ref="con:integer" />
                                          <xs:element ref="con:filepath" />
                                          <xs:element ref="con:item" />
                                          <xs:element ref="con:string" />
                                          <xs:element ref="con:list" />
                                          <xs:element ref="con:boolean" />
                                    </xs:sequence>
                                    <xs:sequence>
                                          <xs:element ref="con:filepath" />
                                          <xs:element ref="con:item" />
                                    </xs:sequence>
                              </xs:choice>
                              <xs:element ref="con:string" />
                        </xs:sequence>
                        <xs:sequence>
                              <xs:element ref="con:string" />
                              <xs:element ref="con:integer" />
                              <xs:element ref="con:filepath" />
                        </xs:sequence>
                        <xs:sequence>
                              <xs:element ref="con:item" />
                              <xs:choice minOccurs="0">
                                    <xs:sequence>
                                          <xs:element ref="con:integer" />
                                          <xs:element ref="con:string" />
                                          <xs:element ref="con:filepath" />
                                    </xs:sequence>
                                    <xs:sequence>
                                          <xs:element ref="con:filepath" />
                                          <xs:element ref="con:string" minOccurs="0" />
                                    </xs:sequence>
                              </xs:choice>
                        </xs:sequence>
                  </xs:choice>
            </xs:complexType>
      </xs:element>
      <xs:element name="platforms">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:windows" />
                        <xs:element ref="con:unix" />
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="list">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:li" maxOccurs="unbounded" />
                  </xs:sequence>
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="li">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="item">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:string" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
                  <xs:attribute name="action" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="integer">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:byte" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="filepath">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:string" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="boolean">
            <xs:complexType>
                  <xs:attribute name="value" type="xs:byte" use="required" />
                  <xs:attribute name="name" type="xs:string" use="required" />
                  <xs:attribute name="export" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="architectures">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:architecture" maxOccurs="unbounded" />
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
      <xs:element name="architecture">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:properties" />
                  </xs:sequence>
                  <xs:attribute name="name" type="xs:string" use="required" />
            </xs:complexType>
      </xs:element>
      <xs:element name="xml-fragment">
            <xs:complexType>
                  <xs:sequence>
                        <xs:element ref="con:platforms" />
                        <xs:element ref="con:properties" />
                  </xs:sequence>
            </xs:complexType>
      </xs:element>
</xs:schema>



The code to access the doc is :

xdoc = XmlFragmentDocument.Factory.parse(inputXMLFile);



The full error trace is :

org.apache.xmlbeans.XmlException: S:\something\build\config\buildtools.xml:0: error: The document is not a xml-fragment@http://something/Buildtools: 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.parseToXmlObject(Locale.java:1273)
                at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
                at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
                at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:252)
                at com.mathworks.x2010.bat.x01.propertyflattening.buildtools.XmlFragmentDocument$Factory.parse(Unknown Source)
                at com.mathworks.bat.server.propertyflattening.lib.BuildtoolsUpdaterNew.applyChanges(BuildtoolsUpdaterNew.java:32)
                at com.mathworks.bat.server.system.SystemTestPropertyFlatteningGeneral.testPropertyValueFlattening(SystemTestPropertyFlatteningGeneral.java:51)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
                at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
                at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
                at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
                at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
                at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
                at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
                at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
                at org.junit.runners.Parameterized$TestClassRunnerForParameters.run(Parameterized.java:98)
                at org.junit.internal.runners.CompositeRunner.runChildren(CompositeRunner.java:33)
                at org.junit.runners.Parameterized.access$000(Parameterized.java:55)
                at org.junit.runners.Parameterized$1.run(Parameterized.java:131)
                at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
                at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
                at org.junit.runners.Parameterized.run(Parameterized.java:129)
                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)




Any help is appreciated.

Sorry for long e-mail...... I tried preparing small sample, but they work like charm, so added the actual one.


Thanks & Regards
- Manoj


Re: Conflict When Having Two XMLBean Generated classes for the same Schema...

Posted by Cezar Andrei <ce...@oracle.com>.
Best way to avoid this problem is to have different target namespaces for your schemas, or same target namespace but without conflicts.

If you can't do that next is to manage the jars/classes in different classloaders like Kevin suggested.

If this is not possible, at least use different java package names for the two files (see .sconfig files), but there are limitations about this, is you start with xml/schema names you'll always get the resources from the first jar on the classpath.

Cezar

On Jun 23, 2011, at 12:46 PM, Kevin Krouse wrote:

> If you have schemas that define components in the same namespace you'll need to isolate the generated schema jars using classloaders.  The issue is similar to trying to load two different java classes with the same name.
> 
> Kevin
> 
> 
> On Thu, Jun 16, 2011 at 7:35 AM, Horst Heistermann <ho...@oracle.com> wrote:
> Hi,
> 
>  I am having an issue in my environment because I have two XMLBean generated classes pointing to the same schema. Sometimes when I use the factory of one class
> it tries to create an instance of the other XMLBean class (even though I am using the factory of the class I want to create!).  This causes a classcastexeception
> 
> Is there a way to avoid this? The issue is indeterminate because it works fine most of the time but once in a while this issue crashes the program
> 
> Thanks,
> 
> Horst
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 


Re: Conflict When Having Two XMLBean Generated classes for the same Schema...

Posted by Kevin Krouse <kk...@apache.org>.
If you have schemas that define components in the same namespace you'll need
to isolate the generated schema jars using classloaders.  The issue is
similar to trying to load two different java classes with the same name.

Kevin


On Thu, Jun 16, 2011 at 7:35 AM, Horst Heistermann <
horst.heistermann@oracle.com> wrote:

> Hi,
>
>  I am having an issue in my environment because I have two XMLBean
> generated classes pointing to the same schema. Sometimes when I use the
> factory of one class
> it tries to create an instance of the other XMLBean class (even though I am
> using the factory of the class I want to create!).  This causes a
> classcastexeception
>
> Is there a way to avoid this? The issue is indeterminate because it works
> fine most of the time but once in a while this issue crashes the program
>
> Thanks,
>
> Horst
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.**apache.org<us...@xmlbeans.apache.org>
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Conflict When Having Two XMLBean Generated classes for the same Schema...

Posted by Horst Heistermann <ho...@oracle.com>.
Hi,

   I am having an issue in my environment because I have two XMLBean generated classes pointing to the same schema. Sometimes when I use the factory of one class
it tries to create an instance of the other XMLBean class (even though I am using the factory of the class I want to create!).  This causes a classcastexeception

Is there a way to avoid this? The issue is indeterminate because it works fine most of the time but once in a while this issue crashes the program

Thanks,

Horst


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org