xjc

Getting “compiler was unable to honor this javaType customization” with “xs:any”

懵懂的女人 提交于 2019-12-21 17:39:42
问题 I have the following xsd: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:any processContents="skip" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> and the following bindings: <jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1"> <jxb:bindings schemaLocation="format.xsd"> <jxb:bindings node="//xs:any"> <jxb

JAXB Bindings to schemas in a JAR

久未见 提交于 2019-12-21 04:52:16
问题 I'm using the maven jaxb2 plugin to generate Java classes, built from schemas in a jar. However, I'm not sure how to correctly locate to these schemas from a bindings file. If Iextract the schemas from the jar and drop them in the same directory as the bindings, all is well. However, this isn't a practical long term solution. pom.xml: <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.1</version> <executions> <execution> <goals> <goal

JAXB binding file: XmlAdapters and package name

南笙酒味 提交于 2019-12-20 10:33:08
问题 I have a binding file like this <jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <jxb:bindings schemaLocation="example.xsd" node="/xs:schema"> <jxb:schemaBindings> <jxb:package name="example" /> </jxb:schemaBindings> <jxb:globalBindings> <jxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" printMethod=

JAXB binding file: XmlAdapters and package name

 ̄綄美尐妖づ 提交于 2019-12-20 10:31:05
问题 I have a binding file like this <jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <jxb:bindings schemaLocation="example.xsd" node="/xs:schema"> <jxb:schemaBindings> <jxb:package name="example" /> </jxb:schemaBindings> <jxb:globalBindings> <jxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" printMethod=

how to make cxf-xjc-plugin generate sources in utf-8

孤者浪人 提交于 2019-12-19 05:56:23
问题 I try to generate java classes from xsd in a maven project using cxf-xjc-plugin. It runs fine, but the generated source files get platform specific encoding (cp1251 on a windows pc) instead of utf-8. If any xsd types contain non-latin characters in schema annotations, then they become readable only in that specific encoding and the compiler later complains with [WARNING] /C:/.../SomeType.java:[17,4] unmappable character for encoding UTF-8 . Please help me force utf-8 for sources generation.

JAXB XJC Possible to suppress comment creation in generated classes?

孤街浪徒 提交于 2019-12-18 13:54:19
问题 Our project uses XJC to generate Java classes from an XSD. I'm using JAVA EE 6. When all the XSDs we have are re-generated, the generated classes include this comment at the top of the file: // Generated on: 2011.02.23 at 02:17:06 PM GMT Is it possible to suppress this comment? The reason is that we use SVN for version control, and every time we regenerate our classes, every single file shows as being changed in SVN, even though the only thing that differs is this comment. So I'd like to

Generate additional custom method with jaxb-xjc

跟風遠走 提交于 2019-12-18 05:44:12
问题 There's some way to generate a custom method within an class generated with JAXB. I search around tutorials, including oracle's tutorial, but I didn't find clear instructions how can I custom methods to a generated class described on XML Schema. 回答1: You can write an XJC plugin: http://weblogs.java.net/blog/kohsuke/archive/2005/06/writing_a_plugi.html 回答2: I have found the following to be the best way to add custom behavior: https://javaee.github.io/jaxb-v2/doc/user-guide/ch03.html#compiling

Generate additional custom method with jaxb-xjc

青春壹個敷衍的年華 提交于 2019-12-18 05:44:01
问题 There's some way to generate a custom method within an class generated with JAXB. I search around tutorials, including oracle's tutorial, but I didn't find clear instructions how can I custom methods to a generated class described on XML Schema. 回答1: You can write an XJC plugin: http://weblogs.java.net/blog/kohsuke/archive/2005/06/writing_a_plugi.html 回答2: I have found the following to be the best way to add custom behavior: https://javaee.github.io/jaxb-v2/doc/user-guide/ch03.html#compiling

JAXB List Tag creating inner class

那年仲夏 提交于 2019-12-18 04:01:16
问题 So we have an XSD type in the form: <xs:complexType name="Foo"> <xs:all> <xs:element name="Bars"> <xs:complexType> <xs:sequence> <xs:element name="Bar" type="barType" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:all> </xs:complexType> to represent XML: <Foo> <!-- Elements snipped for brevity--> <Bars> <Bar> <!-- Bar Element --> </Bar> </Bars> </Foo> xjc produces almost correct results. The only annoying thing is that "Bars" is created as an inner class which

Add toString, hashCode, equals while generating JAXB classes in Java

会有一股神秘感。 提交于 2019-12-18 03:34:16
问题 I'm trying to generate JAXB classes from an XSD file programmatically, using Java. I've used the following code snippet to achieve that: .... import java.io.File; import java.io.IOException; import org.xml.sax.InputSource; import com.sun.codemodel.JCodeModel; import com.sun.tools.xjc.api.S2JJAXBModel; import com.sun.tools.xjc.api.SchemaCompiler; import com.sun.tools.xjc.api.XJC; .... .... public static void generateJaxb(String schemaPath, String outputDirectory, String packageName) throws