I'm trying to create a bind file to change the base type of a property:
XSD
My bind file:
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd"
version="2.1">
<bindings schemaLocation="*">
<bindings node="//xsd:element[#name='EFilingPriorDocumentNumber']">
<baseType name="java.lang.String"/>
</bindings>
</bindings>
</bindings>
But XJC always give me the error:
[ERROR] XPath evaluation of "//xsd:element[#name='EFilingPriorDocumentNumber']" results in empty target node
Someone knows how to fix it?
I try to grasp the mechanics of Nuxeo and as such started with all tutorials and documents around. I put together a bundle that seemed quite right for me and tried now for several hours to make it work in any flavor - without success.
Using Nuxeo 8.3.
Anything i am missing?
The manifest at META_INF/MANIFEST.MF
Manifest-Version: 1.0
Bundle-SymbolicName: de.foo.nuxeo.tutorial.tutorial-demo1;singlet
on=true
Bundle-Version: 1.0.0
Bundle-Name: tutorial-demo1
Bundle-ClassPath: .
Bundle-ManifestVersion: 2
Bundle-Vendor: de.foo.nuxeo.tutorial
Nuxeo-Component: OSGI-INF/foo-demo-component-core-types.xml,OSGI-INF/foo-demo-component-ui-types.xml
A core document type at OSG-INF/foo-demo-component-core-types.xml
<?xml version="1.0"?>
<component name="de.foo.demo.component.core.types" version="1.0">
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
<schema name="foo" src="schemas/foo-demo-foo.xsd"
prefix="isfoo" />
</extension>
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype" >
<doctype extends="File" name="FooFile">n
<schema name="foo" />
</doctype>
</extension>
</component>
A ECM document type at OSGI-INF/foo-demo-component-ui-types.xml
<?xml version="1.0"?>
<component name="de.foo.demo.component.ui.types" version="1.0">
<require>org.nuxeo.ecm.platform.types</require>
<extension target="org.nuxeo.ecm.platform.types.TypeService"
point="types">
<type id="FooFile">
<label>Foo File</label>
<icon>/icons/file.gif</icon>
<bigIcon>/icons/file_100.png</bigIcon>
<category>SimpleDocument</category>
<description>A foo file</description>
<default-view>view_documents</default-view>
<layouts mode="any">
<layout>heading</layout>
<layout>file</layout>
</layouts>
</type>
<type id="Folder">
<subtypes>
<type>FooFile</type>
</subtypes>
</type>
</extension>
</component>
A schema at schemas/foo-demo-foo.xsd
<?xml version="1.0"?>
<xs:schema
targetNamespace="http://www.foo.de/nuxeo/schemas/foo/"
xmlns="http://www.foo.de/nuxeo/schemas/foo/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="gnu" type="xs:string" />
<xs:element name="gnat" type="xs:string" />
</xs:schema>
Packed in a jar and deployed to nxserver/bundles. After a restart i see the bundle loaded in the administrator view, no errors in the log file. When i create a new document, i do not see the new type...
What am i missing?
I'm creating a NuGet package that contains a web.release.config.install.xdt file. But, every transform in the file is processed by NuGet.
Here's the contents of the web.release.config.install.xdt file:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- I only want this xdt:Transform to be handled by NuGet -->
<solr xdt:Transform="Insert">
<!-- the below xdt:Transform attributes are also processed by NuGet -->
<server id="location" url="http://192.168.1.100:8983/solr/geo" xdt:Transform="SetAttributes" xdt:Locator="Match(id)" />
</solr>
</configuration>
Any suggestions on the proper way to escape the nested transforms so they are retained for the web.release.config file?
I tried to find a solution for some time to the following problem. I have a wsdl file containing several (6) xsd imports. I cannot change these xsd's because they are external to my project. There are 4 definitions all together which are slightly defined different in 2 of these schemas. I was attempting to translate each 'conflicting' xsd schema to it's own package. I tried following bindings, but it did not do the job:
testbindings.jaxb:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1">
<bindings schemaLocation="a.xsd">
<schemaBindings>
<package name="org.wsi.a" />
</schemaBindings>
</bindings>
</bindings>
using: wsimport -p org.wsi -b testbindings.jaxb broker.wsdl
All classes are generated in org.wsi and no classes in org.wsi.a. Without the -p switch all xsd are generated in their own default package. But could not tell wsimport to use specific packages for each xsd. At this moment I use following binding file, which is probably incorrect, but for which the wsimport doesn't complain:
<?xml version="1.0"?>
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxws:bindings wsdlLocation="broker.wsdl" node="wsdl:definitions/wsdl:types/xsd:schema">
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" node="//xs:schema/xs:import[#namespace='http://docs.oasis-open.org/wsn/b-2']">>
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.b_2"/>
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" node="//xs:schema/xs:import[#namespace='http://docs.oasis-open.org/wsn/t-1']">>
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.t_1"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxws:bindings>
In packages org.broker.wsi.b_2 and org.broker.wsi.t_1, no files are generated.
I used bindings as specified in: http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv/data_types.html#wp227713 but probably incorrect.
Suggestions are welcome.
The problem of setting up the correct package names for the wsdl, the internal xsd and the external xsd's is described in question/answer:
wsimport - how to generate service endpoint classes and JAXB classes in separate projects/folders, posted by:
dma-k
int-bindings.xml file:
<?xml version="1.0"?>
<jaxws:bindings version="2.0"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
wsdlLocation="broker.wsdl">
<jaxws:package name="org.broker.wsi" />
<jaxb:bindings node="//xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.al"/>
</jaxb:schemaBindings>
</jaxb:bindings>
The external-bindings file (abbreviated):
<jaxb:bindings version="1.0"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="http://docs.oasis-open.org/wsn/b-2.xsd" node="//xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.oasis.b2"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
I have a CommonTypes.xsd which I'm including in my all other XSDs using xs:include. I get
Multiple <schemaBindings> are defined for the target namespace ""
when I try to compile it into different packages using binding files. Please tell me whether there is a way to compile them into different packages. I'm using jaxb 2.1
Yeah, there is a way.
Assuming:
xsd/common/common.xsd
xsd/foo/foo.xsd
In the common directory place common.xjb:
<jxb:schemaBindings>
<jxb:package name="mypkg.common">
</jxb:package>
</jxb:schemaBindings>
In the foo directory place foo.xjb:
<jxb:schemaBindings>
<jxb:package name="mypkg.foo">
</jxb:package>
</jxb:schemaBindings>
In the build.xml file, create one xjc task for each:
<xjc destdir="${app.src}" readOnly="true" package="mypkg.common">
<schema dir="${app.schema}/common" includes="*.xsd" />
<binding dir="${app.schema}/common" includes="*.xjb" />
</xjc>
<xjc destdir="${app.src}" readOnly="true" package="mypkg.foo">
<schema dir="${app.schema}/foo" includes="*.xsd" />
<binding dir="${app.schema}/foo" includes="foo.xjb" />
</xjc>
You need to make sure that common.xsd has a targetNameSpace that is different from foo.xsd's targetNameSpace.
As stated already by Ben there is no way to do that if they have the same namespace.
But how to do it if you do have different namespaces?
<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<jxb:bindings namespace="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" schemaLocation="oagi/Common/UNCEFACT/ATG/CoreComponents/UnqualifiedDataTypes.xsd" >
<jxb:schemaBindings>
<jxb:package name="com.test.oagi.udt"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings namespace="http://www.openapplications.org/oagis/9/codelists" schemaLocation="oagi/Common/OAGi/Components/CodeLists.xsd" >
<jxb:schemaBindings>
<jxb:package name="com.test.oagi.cl"/>
</jxb:schemaBindings>
</jxb:bindings>
</jxb:bindings>
but be sure you do not use the command line parameter -p, since that will override your config.
I've meet the same problem and haven't solve it yet, but I'm afraid that it can't be possible to generate XSD into differents packages :
It is not legal to have more than one <jaxb:schemaBindings> per namespace, so it is impossible to have two schemas in the same target namespace compiled into different Java packages
from Compiler Restrictions at the end of this page
but if some one find some work around, just inform us please
I know it is an old post, but, as there is no answer for the exact question, here is my proposal:
As mmoossen explained, the trick is to specify different namespaces for the XSDs.
But, adding a namespace attribute in the jxb:bindings tag doesn't work:
<jxb:bindings namespace="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" schemaLocation="oagi/Common/UNCEFACT/ATG/CoreComponents/UnqualifiedDataTypes.xsd" >
Instead of that, you need to add a targetNamespace attribute to the xs:schema tags of your XSDs:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="some.namespace"
version="1.0">
Once done, you will be able to have 1 external customization file (.xjb) declaring different schemaBindings, each of them possibly using a different package:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
jaxb:extensionBindingPrefixes="xjc annox inherit">
<jaxb:bindings schemaLocation="MyFirstXSD.xsd">
<jaxb:schemaBindings>
<jaxb:package name="com.test.a" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="MySecondXSD.xsd">
<jaxb:schemaBindings>
<jaxb:package name="com.test.b" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="MyThirdXSD.xsd">
<jaxb:schemaBindings>
<jaxb:package name="com.test.c" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Can be done as mentioned in jaxb maven plugin usage page in case of having Multiple schemas with different configuration.
Separate packages can be configured for each schema.
<packageName>se.west</packageName>
complete example configuration below:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<!-- Use all XSDs under the west directory for sources here. -->
<sources>
<source>src/main/xsds/west</source>
</sources>
<!-- Package name of the generated sources. -->
<packageName>se.west</packageName>
</configuration>
</execution>
<execution>
<id>xjc-schema2</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<!-- Use all XSDs under the east directory for sources here. -->
<sources>
<source>src/main/xsds/east</source>
</sources>
<!-- Package name of the generated sources. -->
<packageName>se.east</packageName>
<!--
Don't clear the output directory before generating the sources.
Clearing the output directory removes the se.west schema from above.
-->
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>