users@jaxb.java.net

Re: Customizing with binding.xjc

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Sun, 18 Nov 2012 21:34:33 +0100

As a fail-safe way to specify the target of a binding location, use
the absolute XPath expression from the root node down to the node you
need to address.

  <jxb:bindings
node="/xs:schema/xs:element[@name='createMMTelSchedConf']/xs:complexType/xs:xomplexContent/xs:extension/xs:attribute[@name='publicId']">
    <jxb:property name="PublicIdentityAttribute" />
  </jxb:bindings>

When you want to nest several bindings subordinate to some node,
continue with a relative path:

<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               jxb:version="2.0" schemaLocation="pp.xsd"
               node="/xs:schema">
  <jxb:bindings
node="xs:element[@name='createMMTelSchedConf']/xs:complexType/xs:complexContent">
    <jxb:bindings node="xs:attribute[@name='publicId']">
      <jxb:property name="PublicIdentityAttribute" />
    </jxb:bindings>
  </jxb:bindings>
</jxb:bindings>

Make sure to use namespace prefixes throughout.

-W

On 17/11/2012, Lulseged Zerfu <zlulseged_at_hotmail.com> wrote:
> Hi
> I am trying to create binding.xjb to go arround schema problem but was not
> successful.
> Can any one help?
> There are two publicId defined and one of the publicId need to be customized
> with binding.xjc which I tried but my XPATH looks not working.
>
> ....<xs:element name="createMMTelSchedConf"
> substitutionGroup="cai3g:CreateMODefinition"> <xs:annotation> <xs:documentation
> xml:lang="en">Used to create an MMTel scheduled conference
> sevice.</xs:documentation> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:extension
> base="cai3g:AbstractCreateAttributeType"> <xs:sequence> <xs:element
> name="publicId"
> type="publicIdentityType"> <xs:annotation> <xs:documentation
> xml:lang="en"> The identity of the user. This identity must already
> be configured on the
> HSS. </xs:documentation> </xs:annotation> </xs:element> <!--
> the relative order of the existing services must be maintained --> <!--
> all new services shall be optional and inserted in alphabetical order within
> the existing list where possible --> <xs:element
> ref="scheduled-conference" /> </xs:sequence> <xs:attribute
> name="publicId" type="publicIdentityType" use="required"
> /> </xs:extension> </xs:complexContent> </xs:complexType>....
>
> My binding file looks like:
> ....<jxb:bindings schemaLocation="mmtel-aggregated-schedconf.xsd"
> node="/xs:schema"> <jxb:schemaBindings> <jxb:package
> name="com.ericsson.ims.mtas.xdms.schema.aggregated.scheduled.conference"
> /> </jxb:schemaBindings>
> <bindings
> node="/xs:schema/xs:element[@name='createMMTelSchedConf']/xs:complexType/xs:complexContent"> <bindings
> node="/xs:extension[@name='AbstractCreateAttributeType']"> <bindings
> node="/xs:attribute[@name='publicId']"> <jxb:property
> name="PublicIdentityAttribute" /> </bindings> </bindings> </bindings>
> </jxb:bindings>....
> Thanks in advance.
> BRLulseged
>
>