-
Notifications
You must be signed in to change notification settings - Fork 38
Unnecessary addition of "rest" property breaking marshaling #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Also, for reference, here is a mapping that works as I would expect: {
name: 'testxsd',
defaultElementNamespaceURI: 'testxsd',
typeInfos: [
{
localName: 'ExampleElement',
typeName: null,
baseTypeInfo: '.ExtensionType',
propertyInfos: [
{ name: 'aaa' },
{ name: 'exampleId' },
{ name: 'bbb' },
{ name: 'constant' },
{ name: 'exampleName' }
]
},
{
localName: 'ExtensionType',
typeName: 'extensionType',
propertyInfos: [
{
name: 'extId',
attributeName:
{
localPart: 'extId'
},
type: 'attribute'
}
]
}
],
elementInfos: [
{
elementName: 'exampleName',
scope: '.ExampleElement'
},
{
elementName: 'bbb',
scope: '.ExampleElement'
},
{
elementName: 'exampleId',
scope: '.ExampleElement'
},
{
elementName: 'constant',
scope: '.ExampleElement'
},
{
elementName: 'aaa',
scope: '.ExampleElement'
},
{
typeInfo: '.ExampleElement',
elementName: 'exampleElement'
}
]
} |
You get <xs:sequence>
<xs:choice>
<xs:element name="exampleId" type="xp:string25Type"/>
<xs:element name="exampleName" type="xp:string25Type"/>
</xs:choice>
<xs:element name="constant" type="xp:string25Type" minOccurs="0"/>
<xs:element name="aaa" type="xp:string25Type"/>
<xs:element name="bbb" type="xp:string25Type" minOccurs="0"/>
</xs:sequence> , you have two To work around this, use a binding file and Something like: <jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:bindings schemaLocation="my.xsd"
node="/xs:schema">
<jaxb:bindings node="xs:element[@name='exampleElement']/....../xs:choice/xs:sequence[xs:element[@name='exampleId']]/xs:element[@name='constant']">
<jaxb:property name="ExampleIdConstant"/>
</jaxb:bindings>
<jaxb:bindings node="xs:element[@name='exampleElement']/....../xs:choice/xs:sequence[xs:element[@name='exampleName']]/xs:element[@name='constant']">
<jaxb:property name="ExampleNameConstant"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings> |
Hi @highsource - thanks so much for the quick reply and for pointing me in the right direction with the really helpful example. This totally makes sense, and I was able to successfully create a binding file that resolved all such conflicts. As I was learning more about jaxb I stumbled across this configuration, which happened to work perfectly for my particular use case, but certainly won't for other cases (especially since it's global here): <jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings generateElementProperty="false">
<xjc:simple />
</jaxb:globalBindings>
</jaxb:bindings> I just figured I'd leave that here as well in case somebody else comes searching the issues with a similar situation. Thanks again! |
Hi there, this may be related to #69 and highsource/jsonix#149, but has a slightly different manifestation.
Essentially, a
sequence
embedded in achoice
that is not the only part of a parentsequence
somehow causes the child's elements to be mapped to a nonexistantrest
property. Unmarshalling works as expected, even with the strange mapping; but when trying to marshal the unmarshalled value back to XML (or when trying to marshal any expected data structure), the relevant properties are stripped.Here's a simplified XSD that illustrates this case, but the real ones that show this problem live here.
This generates the following mapping; notice the surprise
name: 'rest'
piece:When using this mapping, I get the following results:
The text was updated successfully, but these errors were encountered: