Hi,
I always get an error when the unmarshaller is validating a tag with mixed
content in this xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tdsp:spare-part-catalog project-name="xxx"
last-update="2004-05-10T11:10:15.984+02:00" project-id="0" type="complete"
xsi:schemaLocation="
http://www.traindoc.de/spec/spare
http://www.traindoc.de/spec/spareparts.xsd"
xmlns:tdc="
http://www.traindoc.de/spec/common"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:tdsp="
http://www.traindoc.de/spec/spare">
<tdsp:vendor-list>
<tdsp:vendor short-name="vendorA" width="0" block-id="vid-0">
<tdc:table-body>
<tdc:tr>
<tdc:td width="0"/>
</tdc:tr>
</tdc:table-body>
</tdsp:vendor>
</tdsp:vendor-list>
<tdsp:spare-part-list>
<tdsp:spare-part occurences-in-master="1.0" fbs-code="1.2.3"
function-group="highcost" occurences-unit="pc">
<tdsp:name>
<tdc:translation source-language="de-DE"
language="en-UK">Pantograph complete</tdc:translation>
<tdc:translation source-language="de-DE"
language="sv-SE">Strömavtagare komplett</tdc:translation>
<tdc:translation source-language="de-DE"
language="de-DE">Pantograph complete</tdc:translation>
</tdsp:name>
<tdsp:description>
<tdc:translation source-language="de-DE" language="en-UK"/>
<tdc:translation source-language="de-DE" language="sv-SE"/>
<tdc:translation source-language="de-DE" language="de-DE"/>
</tdsp:description>
<tdsp:extended-infos width="100%">
<tdc:table-body>
<tdc:tr>
<tdc:td width="40%">
<tdc:p source-language="de-DE"
language="de-DE">technical data</tdc:p><!-- Line 28, Column 99 -->
</tdc:td>
<tdc:td width="60%">
<tdc:p source-language="de-DE"
language="de-DE"/>
</tdc:td>
</tdc:tr>
</tdc:table-body>
</tdsp:extended-infos>
<tdsp:vendor-ref vendor-id="vid-0" order-number="00-0000-A"/>
</tdsp:spare-part>
</tdsp:spare-part-list>
<tdsp:image-list/>
</tdsp:spare-part-catalog>
(XMLSpy accepts the file as valid.)
The error message is:
Error in Line 28, Column 99: unexpected character literal [ERROR]
Object: null
Node : null
Offset: -1
URL : file:/E:/spareparts.xml
com.sun.msv.verifier.ValidityViolation: unexpected character literal
at com.sun.msv.verifier.Verifier.onError(Verifier.java:332)
at com.sun.msv.verifier.Verifier.onError(Verifier.java:324)
at com.sun.msv.verifier.Verifier.verifyText(Verifier.java:130)
at com.sun.msv.verifier.Verifier.endElement(Verifier.java:284)
at
com.sun.msv.verifier.VerifierFilter.endElement(VerifierFilter.java:102)
at
org.iso_relax.verifier.impl.ForkContentHandler.endElement(ForkContentHandler
.java:80)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at
de.traindoc.xml.addinfos.impl.runtime.UnmarshallerImpl.unmarshal(Unmarshalle
rImpl.java:142)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshall
erImpl.java:131)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshall
erImpl.java:136)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshall
erImpl.java:145)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshall
erImpl.java:163)
at
de.traindoc.server.xml.SparepartsReader.readSpareparts(SparepartsReader.java
:278)
...
Line 278 is the unmarshaller-call in the following fragment:
Unmarshaller u = jc.createUnmarshaller();
u.setEventHandler(new JaxbValidationEventHandler());
u.setValidating(true);
Object o = u.unmarshal(spFile);
The schema definition for the p-Tag is
...
<xs:element name="p" maxOccurs="unbounded">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<jaxb:class name="P_ct_Type"/>
</xs:appinfo>
</xs:annotation>
<xs:complexContent>
<xs:extension base="pType">
<xs:attribute name="block-id" type="xs:ID" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
...
<xs:complexType name="pType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="link">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="action" use="optional" default="jump">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="jump"/>
<xs:enumeration value="include"/>
<xs:enumeration value="show"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ref-block-id" type="xs:IDREF"
use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="span">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="style" type="xs:string" use="required">
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attributeGroup ref="translationAttribs"/>
</xs:complexType>
...
Changeing u.setValidating to false, no problems occured.
Where is my fault: in the code, in the schema or is it a jaxb problem? Any
ideas are welcome!
Thanks in advance
Detlef Kahlert.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net