users@jaxb.java.net

Re: Problems with multiple root elements in same package

From: Russell Johns <johns_at_lanl.gov>
Date: Thu, 24 Apr 2003 10:06:57 -0600

>> 3 levels deep it insists qualified names become unqualified. the
>> original Xml file passed XmlSpy 5.2 validation, after massaging the
>> file so that
>
>I'm sorry, you lost me. I got your schema and instance,
>
> - Can JAXB-RI unmarshal that instance?

The instance I supplied is the "massaged" version that JAXB-RI can unmarshall- It cannot unmarshall the version that uses unqualified element names i.e <TvTrac-DaemonConfig xmlns="tvTrac" ... > instead of
<TvTrac-DaemonConfig xmlns:tvt="tvTrac" ... > which is attached below.

> - Does XMLSpy validate that instance?

XmlSpy does not validate the "massaged" Xml file supplied last time, nor
the file that was marshalled by JAXB-RI after unmarshalling the "massaged" version.

>If not, what are the error messages? Have you tried other schema
>validators?

I Have not tried any other validators- as for XmlSpy-

errors start with element 'location' inside element 'repository-info' inside root element 'TvTrac-DaemonConfig':

"Mandatory element 'ns1:location' expected instead of 'location'"
if corrected, the error repeats for all elements that are not globally defined.

when I try to unmarshall the file with unqalified names
i.e. the root element looks like <TvTrac-DaemonConfig xmlns="tvTrac" ... >

I get the following exception when validation is turned on-

com.sun.msv.verifier.ValidityViolation: namespace URI of tag "location" is wrong. It must be ""
        at com.sun.msv.verifier.Verifier.onError(Verifier.java:319)
        at com.sun.msv.verifier.Verifier.onError(Verifier.java:315)
        at com.sun.msv.verifier.Verifier.startElement(Verifier.java:188)
        at com.sun.msv.verifier.VerifierFilter.startElement(VerifierFilter.java:97)
        at org.iso_relax.verifier.impl.ForkContentHandler.startElement(Unknown Source)
        at com.sun.xml.bind.validator.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:104)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:452)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:313)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1541)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:346)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:529)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:585)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1142)
        at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:130)
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:139)
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:186)
        at JvTrac.Daemon.JvTracDaemon.main(JvTracDaemon.java:39)
--------------- linked to ------------------
javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.msv.verifier.ValidityViolation: namespace URI of tag "location" is wrong. It must be ""]
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:306)
        at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:134)
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:139)
        at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:186)
        at JvTrac.Daemon.JvTracDaemon.main(JvTracDaemon.java:39)
DefaultValidationEventHandler: [ERROR]: namespace URI of tag "location" is wrong. It must be ""


as the only 'location' element in the file is :
        ...
 <repositoryInfo type="local">
  <location>/home/cvs/TvTrac</location>
  <port>0</port>
 </repositoryInfo>
        ...

what is JAXB-RI looking for? <:location> ??

Aside - is there a way to get the exception to identify where in the file
it is having issues- while 'location' is unique, many other elements aren't...

Thanks for any insights you might have-

Regards -

Russ Johns


Below is the XML instance with unqualified element names:

>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TvTrac-DaemonConfig MinorVersion="1" MajorVersion="0" xmlns="tvTrac" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="tvTrac
E:\Trac\TvTrac\JvTrac\Xml\TvTrac-DaemonConfig.xsd">
 <port>8189</port>
 <processors>2</processors>
 <speedIndex>0.5</speedIndex>
 <isReferenceSystem>false</isReferenceSystem>
 <buildCapable>true</buildCapable>
 <repositoryInfo type="local">
  <location>/home/cvs/TvTrac</location>
  <port>0</port>
 </repositoryInfo>
 <executableInfo>
  <inFiles>
   <name>tracin</name>
   <suffix>.inp</suffix>
   <type>ASCII</type>
   <input>req</input>
   <output>NA</output>
  </inFiles>
  <inFiles>
   <name>taskList</name>
   <suffix>.List</suffix>
   <type>ASCII</type>
   <input>req</input>
   <output>NA</output>
  </inFiles>
  <outFiles>
   <name>trcout</name>
   <suffix>.out</suffix>
   <type>ASCII</type>
   <input>NA</input>
   <output>req</output>
  </outFiles>
  <outFiles>
   <name>trcdmp</name>
   <suffix>.dmp</suffix>
   <type>bin</type>
   <input>NA</input>
   <output>req</output>
  </outFiles>
  <cmdLineOptions>
   <optName>-usetpr</optName>
   <numDataArgs>0</numDataArgs>
   <reqFilesReplaced>trcdmp</reqFilesReplaced>
   <newOutFiles>trctpr</newOutFiles>
  </cmdLineOptions>
  <appliesTo>
   <startVersion>
    <category>NRC</category>
    <MajorVersion>3</MajorVersion>
    <MinorVersion>1110</MinorVersion>
    <release> </release>
   </startVersion>
   <RangeClass>AllMinor</RangeClass>
  </appliesTo>
 </executableInfo>
 <diffInfo>
  <numFileTypes>2</numFileTypes>
  <comparators>
   <tag>ASCII</tag>
   <path>diff.exe</path>
   <argList>%Reference%</argList>
   <argList>%Test%</argList>
   <resultType>Text</resultType>
  </comparators>
  <comparators>
   <tag>SigDif</tag>
   <path>rtrcsno.exe</path>
   <argList>%Reference%</argList>
   <argList>%Test%</argList>
   <resultType>Text</resultType>
  </comparators>
 </diffInfo>
</TvTrac-DaemonConfig>


>regards,
>--
>Kohsuke KAWAGUCHI 408-276-7063 (x17063)
>Sun Microsystems kohsuke.kawaguchi_at_sun.com