Hi There,
I'm using jaxb2 in a project managed by maven, my pom.xml contains
(with plugin usage) :
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.3</version>
</dependency>
[...]
<repositories>
<repository>
<id>java.net</id>
<name>java.net Maven Repository</name>
<url>
https://maven-repository.dev.java.net/nonav/repository</url>
<layout>legacy</layout>
</repository>
<repository>
<id>biblio</id>
<name>ibiblio Maven Repository</name>
<url>
http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
<layout>legacy</layout>
</repository>
</repositories>
[...]
<pluginRepositories>
<pluginRepository>
<id>java.net</id>
<name>java.net Maven Repository</name>
<url>
https://maven-repository.dev.java.net/nonav/repository</url>
<layout>legacy</layout>
</pluginRepository>
</pluginRepositories>
<developers>
<developer>
<id>ap</id>
<name>Andy Petrella</name>
<email>
ap@ionicsoft.com</email>
<organization>IONIC Software</organization>
<organizationUrl>
http://www.ionicsoft.com</organizationUrl>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>
[...]
<groupId>com.sun.tools.xjc.maven2</groupId>
<artifactId>maven-jaxb-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/schemas/mapping</schemaDirectory>
<generateDirectory>${project.build.sourceDirectory}</generateDirectory>
<generatePackage>com.ionicsoft.wrs.modelconverter.datamapping.schema</generatePackage>
<removeOldOutput>false</removeOldOutput>
<extension>true</extension>
<verbose>true</verbose>
</configuration>
</plugin>
Secondly, my problem is when I use the xsd:any in my schema, like this :
[...]
<xsd:complexType name="StructXMLValueType">
<xsd:sequence>
<xsd:any processContents="skip" minOccurs="0"
maxOccurs="unbounded" namespace="##any"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="xmlValue" type="StructXMLValueType"/>
[...]
And here is it my instance, using this trick :
<data
path="gmd:geographicElement">
<data
path="gmd:EX_GeographicBoundingBox">
<struct
path="episo19139:envelope/episo19139:Envelope">
<struct
path="rim:valueList/wrs:ValueListType">
<struct
path="wrs:anyValue/wrs:AnyValueType">
<struct
path="@wrs:any">
<literal>
<xmlValue>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:4326">
<gml:lowerCorner>${West} ${South}
</gml:lowerCorner>
<gml:upperCorner>${East} ${North}
</gml:upperCorner>
[line 559]
</gml:Envelope>
</xmlValue>
<param ID="West">
<dataValue
path="gmd:westBoundLongitude/gco:Decimal|gmd:westBoundLongitude/gco:Angle"/>
</param>
<param ID="South">
<dataValue
path="gmd:southBoundLatitude/gco:Decimal|gmd:southBoundLatitude/gco:Angle"/>
</param>
<param ID="East">
<dataValue
path="gmd:eastBoundLongitude/gco:Decimal|gmd:eastBoundLongitude/gco:Angle"/>
</param>
<param ID="North">
<dataValue
path="gmd:northBoundLatitude/gco:Decimal|gmd:northBoundLatitude/gco:Angle"/>
</param>
</literal>
</struct>
</struct>
</struct>
</struct>
</data>
</data>
I have an unmarshal problem, see :
JAXBContext jb =
JAXBContext.newInstance("com.ionicsoft.wrs.modelconverter.datamapping.schema");
Unmarshaller um = jb.createUnmarshaller();
um.setEventHandler(new
javax.xml.bind.helpers.DefaultValidationEventHandler());
JAXBElement e = (JAXBElement)um.unmarshal(in);
return (StructMappingType) e.getValue();
} catch (JAXBException e) {
e.printStackTrace();
return null;
}
stacktrace :
XML-22103: (Fatal Error) DOMResult can not be this kind of node.
DefaultValidationEventHandler: [ERROR]: XML-22103: (Fatal Error)
DOMResult can not be this kind of node.
Location: line
559
javax.xml.bind.UnmarshalException: XML-22103: (Fatal Error) DOMResult
can not be this kind of node.
- with linked exception:
[javax.xml.transform.TransformerException: XML-22103: (Fatal Error)
DOMResult can not be this kind of node.]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:556)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:585)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:581)
at
com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.leaveElement(DomLoader.java:127)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:427)
at
com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:109)
at
oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1254)
at
oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:311)
at
oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:278)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:181)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:195)
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
at
com.ionicsoft.wrs.modelconverter.datamapping.tools.MappingHelperImpl.unmarshall(MappingHelperImpl.java:261)
at
com.ionicsoft.wrs.modelconverter.datamapping.tools.MappingHelperImpl.saveMapping(MappingHelperImpl.java:203)
at
com.ionicsoft.test.catalog.modelconverter.datamapping.MappingTest.testNewMapping(MappingTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at
com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:65)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at
com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:24)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
Caused by: javax.xml.transform.TransformerException: XML-22103: (Fatal
Error) DOMResult can not be this kind of node.
at
oracle.xml.jaxp.JXTransformerHandler.endDocument(JXTransformerHandler.java:145)
at
com.sun.xml.bind.v2.runtime.unmarshaller.DomLoader.leaveElement(DomLoader.java:125)
... 29 more
Please, can someone help... it makes me crazy :-P.
Thx.
Andy Petrella