Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35988 > unrolled thread

xjb binding with xs:any

Started byPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
First post2016-11-29 11:07 -0800
Last post2016-12-07 23:54 +0100
Articles 7 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  xjb binding with xs:any Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-11-29 11:07 -0800
    Re: xjb binding with xs:any Sebastian <nowhere@nirvana.org> - 2016-11-30 19:13 +0100
      Re: xjb binding with xs:any Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-11-30 13:04 -0800
        Re: xjb binding with xs:any Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-12-02 04:30 -0800
          Re: xjb binding with xs:any Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-12-07 03:28 -0800
            Re: xjb binding with xs:any Sebastian <nowhere@nirvana.org> - 2016-12-07 23:48 +0100
              Re: xjb binding with xs:any Sebastian <nowhere@nirvana.org> - 2016-12-07 23:54 +0100

#35988 — xjb binding with xs:any

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-11-29 11:07 -0800
Subjectxjb binding with xs:any
Message-ID<71be9001-1988-401b-b04b-2b5e668e8622@googlegroups.com>
Hello,

I try to compile with XJC a XSD schema into Java classesn. The XSD file is:
https://github.com/APTD/Simulation/blob/master/src/main/xsd/network.xsd

and the binding file:
https://github.com/APTD/Simulation/blob/master/src/main/xsd/bindings.xjb

The XSD includes the main schema: http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/railML.xsd

but there a some subschema defined which uses an xs:any attribut. If I try to compile my main XSD, I get the error that Any is defined multiple time (in each subschema). e.g.:

http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/infrastructure.xsd (line 435)

http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/genericRailML.xsd (line 140)

http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/timetable.xsd (line 400)

How can I fix this error within my binding file? In my case the any elements can be skipped / ignored.

Thanks

Phil

[toc] | [next] | [standalone]


#36003

FromSebastian <nowhere@nirvana.org>
Date2016-11-30 19:13 +0100
Message-ID<o1n4sr$i2n$1@news.albasani.net>
In reply to#35988
Am 29.11.2016 um 20:07 schrieb Philipp Kraus:
> Hello,
>
> I try to compile with XJC a XSD schema into Java classesn. The XSD file is:
> https://github.com/APTD/Simulation/blob/master/src/main/xsd/network.xsd
>
> and the binding file:
> https://github.com/APTD/Simulation/blob/master/src/main/xsd/bindings.xjb
>
> The XSD includes the main schema: http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/railML.xsd
>
> but there a some subschema defined which uses an xs:any attribut. If I try to compile my main XSD, I get the error that Any is defined multiple time (in each subschema). e.g.:
>
> http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/infrastructure.xsd (line 435)
>
> http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/genericRailML.xsd (line 140)
>
> http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/timetable.xsd (line 400)
>
> How can I fix this error within my binding file? In my case the any elements can be skipped / ignored.
>
> Thanks
>
> Phil
>

Have you tried googling this? Here's a post that might help:
http://stackoverflow.com/questions/13610217/jaxb-compiling-issue-error-property-any-is-already-defined

I'm guessing the problem is caused by namespace="##other" occurring in 
each sub-schema (although they do seem to share the same target 
namespace, so it is a bit strange.) Have you made sure that the files 
define mutually exclusive sets of types?

Perhaps adding processContents="skip" in the schemas would help (see 
https://jaxb.java.net/nonav/2.2.5-5/docs/ch03.html#compiling-xml-schema-mapping-of-xs-any 
and http://docstore.mik.ua/orelly/xml/schema/ch10_11.htm), if you have 
control over the schemas. If not, I'd be interested to hear if that is 
possible via a bindings file.

There seem to have been XJC plugins to customize wildcard binding modes 
(cf. 
http://stackoverflow.com/questions/9293634/jaxb-2-1-customize-xsany-binding 
and https://github.com/highsource/jaxb2-basics/), but that particular 
project seems to be dormant and the documentation for the WildcardPlugin 
gone.

Hope this helps at least a bit,
Sebastian

[toc] | [prev] | [next] | [standalone]


#36004

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-11-30 13:04 -0800
Message-ID<f81a5812-70f9-433c-a4d3-9770d7f04afc@googlegroups.com>
In reply to#36003
Am Mittwoch, 30. November 2016 19:13:56 UTC+1 schrieb Sebastian: 
> Have you tried googling this? Here's a post that might help:
> http://stackoverflow.com/questions/13610217/jaxb-compiling-issue-error-property-any-is-already-defined
> 
> I'm guessing the problem is caused by namespace="##other" occurring in 
> each sub-schema (although they do seem to share the same target 
> namespace, so it is a bit strange.) Have you made sure that the files 
> define mutually exclusive sets of types?

I have googled this many times, but the problem is, I cannot modify the XSD schema, because it is an external schema, which must be used exactly (strict) in this configuration.

In general I would modify the XSD, but here I need the schema in the posted case, without any changes


> Perhaps adding processContents="skip" in the schemas would help (see 
> https://jaxb.java.net/nonav/2.2.5-5/docs/ch03.html#compiling-xml-schema-mapping-of-xs-any 
> and http://docstore.mik.ua/orelly/xml/schema/ch10_11.htm), if you have 
> control over the schemas. If not, I'd be interested to hear if that is 
> possible via a bindings file.

Yes exactly, this is my question!
I cannot change the XSD, so I need to define the processContents with "skip" inside the bindings.xjb file, and I'm asking here for a solution of that.


> 
> There seem to have been XJC plugins to customize wildcard binding modes 
> (cf. 
> http://stackoverflow.com/questions/9293634/jaxb-2-1-customize-xsany-binding 
> and https://github.com/highsource/jaxb2-basics/), but that particular 
> project seems to be dormant and the documentation for the WildcardPlugin 
> gone.


Thanks I will take a look, but the question is still unanswerd :-)
How can I add the skip processingContents inside the binding file.

Thanks

Phil

[toc] | [prev] | [next] | [standalone]


#36015

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-12-02 04:30 -0800
Message-ID<dac441ef-d06a-40ae-b6b4-1858a3df8030@googlegroups.com>
In reply to#36004
Am Mittwoch, 30. November 2016 22:05:02 UTC+1 schrieb Philipp Kraus:
> Thanks I will take a look, but the question is still unanswerd :-)

Some additional comments, the problems seems to be on the included schema, which is XSD 1.1 and Jaxb does not support the 1.1 definition, it supports XSD 1.0 only.

Therese seems to be a component https://xsom.java.net/ which should support 1.1, but not the xs:override, so the main question is how can I use the 1.1 schema without modifying the included schema.

Phil

[toc] | [prev] | [next] | [standalone]


#36063

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-12-07 03:28 -0800
Message-ID<d57e28a4-33f3-4361-9700-f75a70c478f8@googlegroups.com>
In reply to#36015
Am Freitag, 2. Dezember 2016 13:30:10 UTC+1 schrieb Philipp Kraus:
> Am Mittwoch, 30. November 2016 22:05:02 UTC+1 schrieb Philipp Kraus:
> > Thanks I will take a look, but the question is still unanswerd :-)
> 
> Some additional comments, the problems seems to be on the included schema, which is XSD 1.1 and Jaxb does not support the 1.1 definition, it supports XSD 1.0 only.
> 
> Therese seems to be a component https://xsom.java.net/ which should support 1.1, but not the xs:override, so the main question is how can I use the 1.1 schema without modifying the included schema.


We can solve the problem with the binding file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version = "2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb = "http://java.sun.com/xml/ns/jaxb"
>
	<jaxb:bindings schemaLocation="network.xsd">
       		<jaxb:globalBindings generateIsSetMethod="false"/>
		<jaxb:schemaBindings>
         		<jaxb:package name="com.github.aptd.simulation.model.xml"/>
      		</jaxb:schemaBindings>
	</jaxb:bindings>
	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/infrastructure.xsd">
                <jaxb:bindings node="//xs:schema/xs:complexType[@name='eTrack']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
                       	<jaxb:property name="any2"/>
                </jaxb:bindings>
	</jaxb:bindings>
	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/genericRailML.xsd">
               	<jaxb:bindings node="//xs:schema/xs:complexType[@name='tElementWithIDAndName']/xs:sequence/xs:any[@namespace='##other']">
                       	<jaxb:property name="any3"/>
               	</jaxb:bindings>
	</jaxb:bindings>
	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/timetable.xsd">
               	<jaxb:bindings node="//xs:schema/xs:complexType[@name='eTrainPart']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
                       	<jaxb:property name="any4"/>
               	</jaxb:bindings>
	</jaxb:bindings>
</jaxb:bindings>

[toc] | [prev] | [next] | [standalone]


#36066

FromSebastian <nowhere@nirvana.org>
Date2016-12-07 23:48 +0100
Message-ID<o2a3ke$nci$1@news.albasani.net>
In reply to#36063
Am 07.12.2016 um 12:28 schrieb Philipp Kraus:
> Am Freitag, 2. Dezember 2016 13:30:10 UTC+1 schrieb Philipp Kraus:
>> Am Mittwoch, 30. November 2016 22:05:02 UTC+1 schrieb Philipp Kraus:
>>> Thanks I will take a look, but the question is still unanswerd :-)
>>
>> Some additional comments, the problems seems to be on the included schema, which is XSD 1.1 and Jaxb does not support the 1.1 definition, it supports XSD 1.0 only.
>>
>> Therese seems to be a component https://xsom.java.net/ which should support 1.1, but not the xs:override, so the main question is how can I use the 1.1 schema without modifying the included schema.
>
>
> We can solve the problem with the binding file:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <jaxb:bindings version = "2.1"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:jaxb = "http://java.sun.com/xml/ns/jaxb"
>>
> 	<jaxb:bindings schemaLocation="network.xsd">
>        		<jaxb:globalBindings generateIsSetMethod="false"/>
> 		<jaxb:schemaBindings>
>          		<jaxb:package name="com.github.aptd.simulation.model.xml"/>
>       		</jaxb:schemaBindings>
> 	</jaxb:bindings>
> 	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/infrastructure.xsd">
>                 <jaxb:bindings node="//xs:schema/xs:complexType[@name='eTrack']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
>                        	<jaxb:property name="any2"/>
>                 </jaxb:bindings>
> 	</jaxb:bindings>
> 	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/genericRailML.xsd">
>                	<jaxb:bindings node="//xs:schema/xs:complexType[@name='tElementWithIDAndName']/xs:sequence/xs:any[@namespace='##other']">
>                        	<jaxb:property name="any3"/>
>                	</jaxb:bindings>
> 	</jaxb:bindings>
> 	<jaxb:bindings schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/timetable.xsd">
>                	<jaxb:bindings node="//xs:schema/xs:complexType[@name='eTrainPart']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
>                        	<jaxb:property name="any4"/>
>                	</jaxb:bindings>
> 	</jaxb:bindings>
> </jaxb:bindings>
>

Thanks for sharing this. By renaming some of the any's you will indeed 
get rid of compiler complaints about multiple definitions. But does this 
also help with getting the desired wildcard binding mode 
(processContents="skip")? I suppose it will not, but I myself am unable 
to come up with anything better.

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#36067

FromSebastian <nowhere@nirvana.org>
Date2016-12-07 23:54 +0100
Message-ID<o2a3vi$lee$1@news.albasani.net>
In reply to#36066
Am 07.12.2016 um 23:48 schrieb Sebastian:
> Am 07.12.2016 um 12:28 schrieb Philipp Kraus:
>> Am Freitag, 2. Dezember 2016 13:30:10 UTC+1 schrieb Philipp Kraus:
>>> Am Mittwoch, 30. November 2016 22:05:02 UTC+1 schrieb Philipp Kraus:
>>>> Thanks I will take a look, but the question is still unanswerd :-)
>>>
>>> Some additional comments, the problems seems to be on the included
>>> schema, which is XSD 1.1 and Jaxb does not support the 1.1
>>> definition, it supports XSD 1.0 only.
>>>
>>> Therese seems to be a component https://xsom.java.net/ which should
>>> support 1.1, but not the xs:override, so the main question is how can
>>> I use the 1.1 schema without modifying the included schema.
>>
>>
>> We can solve the problem with the binding file:
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <jaxb:bindings version = "2.1"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:jaxb = "http://java.sun.com/xml/ns/jaxb"
>>>
>>     <jaxb:bindings schemaLocation="network.xsd">
>>                <jaxb:globalBindings generateIsSetMethod="false"/>
>>         <jaxb:schemaBindings>
>>                  <jaxb:package
>> name="com.github.aptd.simulation.model.xml"/>
>>               </jaxb:schemaBindings>
>>     </jaxb:bindings>
>>     <jaxb:bindings
>> schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/infrastructure.xsd">
>>
>>                 <jaxb:bindings
>> node="//xs:schema/xs:complexType[@name='eTrack']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
>>
>>                            <jaxb:property name="any2"/>
>>                 </jaxb:bindings>
>>     </jaxb:bindings>
>>     <jaxb:bindings
>> schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/genericRailML.xsd">
>>
>>                    <jaxb:bindings
>> node="//xs:schema/xs:complexType[@name='tElementWithIDAndName']/xs:sequence/xs:any[@namespace='##other']">
>>
>>                            <jaxb:property name="any3"/>
>>                    </jaxb:bindings>
>>     </jaxb:bindings>
>>     <jaxb:bindings
>> schemaLocation="http://www.railml.org/files/download/schemas/2016/railML-2.3/schema/timetable.xsd">
>>
>>                    <jaxb:bindings
>> node="//xs:schema/xs:complexType[@name='eTrainPart']/xs:complexContent/xs:extension/xs:sequence/xs:any[@namespace='##other']">
>>
>>                            <jaxb:property name="any4"/>
>>                    </jaxb:bindings>
>>     </jaxb:bindings>
>> </jaxb:bindings>
>>
>
> Thanks for sharing this. By renaming some of the any's you will indeed
> get rid of compiler complaints about multiple definitions. But does this
> also help with getting the desired wildcard binding mode
> (processContents="skip")? I suppose it will not, but I myself am unable
> to come up with anything better.
>
> -- Sebastian

To pose the question another way: Is it still a wildcard after renaming? 
If not, won't you get validation problems with some XML files?

-- Sebastian

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web