users@jaxb.java.net

Re: jaxb binding file for + <extension base="anyType"/>

From: indra_4011 <indra4011_at_gmail.com>
Date: Mon, 9 Nov 2009 05:01:33 -0800 (PST)

hi,
Is it possible to add these follwing

   <jxb:bindings node="//xs:extension[@base='anyType']">
            <jxb:property >
                <jxb:baseType name="java.lang.Object"/>
            </jxb:property>
      </jxb:bindings>


rather the one that u suggested
<jxb:bindings node="//xs:element[@name='primaryKey']">
     <jxb:property>
       <jxb:baseType name="java.lang.String"/>
     </jxb:property>
   </jxb:bindings>
COz unmarshalling does not work in these case fail with ClassCast Exception

i am unable to genate the Classes with the one i mentioned it fails with the
exception
[xjc] [ERROR] Specified property customization is not used. which does not
tell us the exact reason behind the exception, i am also sending the OSS/J
standard xsd also which has the defination
http://old.nabble.com/file/p26266053/OSSJ-Common-v1-5.xsd
OSSJ-Common-v1-5.xsd



Wolfgang Laun-2 wrote:
>
> If the key is a simple (String) type, then why does the XML Schema
> contain a complexType?
>
> Anyway, to match the XML, simply do
>
> <jxb:bindings node="//xs:element[@name='primaryKey']">
> <jxb:property>
> <jxb:baseType name="java.lang.String"/>
> </jxb:property>
> </jxb:bindings>
>
> -W
>
>
>
> On Mon, Nov 9, 2009 at 11:14 AM, indra_4011 <indra4011_at_gmail.com> wrote:
>>
>> Hi,
>>
>> Sorry  it did not worked with following xml attached ,
>> and the follwing code snippet
>> JAXBContext jc =
>> JAXBContext.newInstance("org.ossj.xml.ordermanagement.v1_0");
>> Unmarshaller u = jc.createUnmarshaller();
>> File f = new File("Resource.xml")
>> CreateAndStartRequestByValueResponse element =
>> (CreateAndStartRequestByValueResponse) u.unmarshal(f);
>> System.out.println("ApplicationDN is :
>> "+element.getRequestKey().getApplicationDN());
>> System.out.println("Type is : "+element.getRequestKey().getType());
>> JAXBContext jc1 = JAXBContext.newInstance("org.ossj.xml.common.v1_5");
>> Unmarshaller u1 = jc1.createUnmarshaller();
>> u1.unmarshal((Element)element.getRequestKey().getPrimaryKey().getAny(0));
>>
>>
>> Wolfgang Laun-2 wrote:
>>>
>>> The given XML schema is so designed as to permit you to have arbitrary
>>> elements and attributes as children of the primaryKey element. It is up
>>> to
>>> the application using this OSS framework to provide these elements and
>>> attributes in a form that can be marshalled, and to provide a way to
>>> unmarshal the application specific XML data.
>>>
>>> If you unmarshal an XML data file conforming to this XML schema, the
>>> getter
>>> getPrimaryKey gives you a ManagedEntityKey.PrimaryKey key object. For
>>> simplicity's sake, let's say that this is supposed to contain a single
>>> subelement, to be retrieved from the Element[] returned by key.getAny().
>>>
>>> In some given application context, one would know what to expect, i.e.,
>>> what
>>> is represented by this XML document tree. And there should be - perhaps
>>> from
>>> another XML schema or written by hand - a set of Java classes
>>> representing
>>> this XML tree. Then it's possible to create another JAXBContext, obtain
>>> an
>>> Unmarshaller from it, and call u.unmarshal( elem ). - Inspecting the
>>> Element
>>> object's properties such as getLocalName() and getNamespaceURI() would
>>> permit you to distinguish between different types acting as key
>>> elements.
>>>
>>> For marshalling, the reverse process is used.
>>>
>>> -W
>>>
>>>
>>> On Sun, Nov 8, 2009 at 5:45 PM, indra_4011 <indra4011_at_gmail.com> wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> I am attaching both the xsd and the xjb file
>>>> is there any resolution for these coz if  i don't  customize the xsd
>>>> then
>>>> it
>>>> generates  Class Primary key
>>>> with getters of or and setters of org.w3c.dom.Element .
>>>>
>>>>
>>>>
>>>>
>>>> Wolfgang Laun-2 wrote:
>>>> >
>>>> > On Fri, Nov 6, 2009 at 10:48 PM, Claus Nagel <claus.nagel_at_gmail.com>
>>>> > wrote:
>>>> >
>>>> >> Hi Wolfgang,
>>>> >
>>>> >> I am just trying to understand how to handle a variable of type
>>>> >> java.lang.Object in a JAXB class. Is it possib
>>>> >> http://old.nabble.com/file/p26255409/bindings.xjb bindings.xjb
>>>> >> http://old.nabble.com/file/p26255409/OSSJ-Common-v1-5.xsd
>>>> >> OSSJ-Common-v1-5.xsd le to read any content into
>>>> >> such a generic variable even if the JAXBContext does not know about
>>>> the
>>>> >> corresponding XML element?
>>>> >>
>>>> >>
>>>> > Sort of, yes. There are variations, depending on the information
>>>> provided
>>>> > by
>>>> > the XML document. I'm assuming an element which would have the schema
>>>> > type xs:anyType.
>>>> >
>>>> > If there is no information, you'll get the document element (subtree)
>>>> as
>>>> a
>>>> > org.w3c.dom.Element.
>>>> >
>>>> > If the element provides information about its type, e.g.
>>>> > <elemAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> >                          xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>> >                          xsi:type="xs:int">10</elemAnyType>
>>>> > and JAXB knows how to handle this schema type, it will be
>>>> unmarshalled
>>>> > into
>>>> > an
>>>> > object of the corresponding Java type.
>>>> >
>>>> >
>>>> >> For example, suppose a schema is associated with the namespace
>>>> "foo".
>>>> It
>>>> >> is
>>>> >> mapped to a set of JAXB classes. One of these classes contains an
>>>> >> attribute
>>>> >> of type java.lang.Object. An XML instance document contains an
>>>> element
>>>> >> associated with the namespace "bar" as corresponding property
>>>> element.
>>>> >> Would
>>>> >> this element be returned as java.lang.Object by the getter of that
>>>> class
>>>> >> even if the JAXBContext does not know about the namespace "bar"? Or
>>>> would
>>>> >> this require to explicitly bind the xsd:anyType property to DOM
>>>> using
>>>> a
>>>> >> JAXB
>>>> >> binding declaration?
>>>> >>
>>>> >>
>>>> > A schema "wildcard" (e,g,, <xs:any/>) would result in a Java field
>>>> Object
>>>> > any,
>>>> > annotated with @XmlanyElement, and the actual type would again be
>>>> > org.w3c.dom.Element. The namespace is arbitrary. This object can be
>>>> > analyzed using the DOM API, but it might also be passed to some
>>>> (other)
>>>> > unmarshaller, to be created from a suitable context.
>>>> >
>>>> > -W
>>>> >
>>>> >
>>>> >> Cheers,
>>>> >> Claus
>>>> >>
>>>> >>
>>>> >> Von: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
>>>> >> Gesendet: Freitag, 6. November 2009 15:32
>>>> >> An: users_at_jaxb.dev.java.net
>>>> >> Betreff: Re: jaxb binding file for + <extension base="anyType"/>
>>>> >>
>>>> >> This customization isn't possible. If properly constrained,
>>>> xs:anyType
>>>> >> might
>>>> >> be mapped to java.lang.Object anyway, but as it is now, you are
>>>> getting
>>>> >> org.w3c.dom.Element, which means that you'll get the XML document
>>>> tree
>>>> >> without any unmarshalling.
>>>> >>
>>>> >> -W
>>>> >> On Fri, Nov 6, 2009 at 3:14 PM, indra_4011 <indra4011_at_gmail.com>
>>>> wrote:
>>>> >>
>>>> >> Hi  i have xsd defination
>>>> >> <element name="primaryKey" nillable="false">
>>>> >> <complexType mixed="false">
>>>> >>     <complexContent mixed="false">
>>>> >> <extension base="anyType"/>
>>>> >>   </complexContent>
>>>> >> </complexType>
>>>> >> </element>
>>>> >> and i using binding file to
>>>> >> <jxb:bindings node="//xs:extension[@base='anyType']">
>>>> >>            <jxb:property>
>>>> >>                <jxb:baseType name="java.lang.Object"/>
>>>> >>            </jxb:property>
>>>> >>        </jxb:bindings> to generate the jaxb classes but i am unable
>>>> to
>>>> >> do
>>>> >> so its giving error
>>>> >> [xjc] [ERROR] Specified property customization is not used.
>>>> >> Please help
>>>> >> --
>>>> >> View this message in context:
>>>> >>
>>>> >>
>>>> http://old.nabble.com/jaxb-binding-file-for-%2B-%3Cextension-base%3D%22anyTy
>>>> >> pe%22-%3E-tp26230531p26230531.html<
>>>> http://old.nabble.com/jaxb-binding-file-for-%2B-%3Cextension-base%3D%22anyTy%0Ape%22-%3E-tp26230531p26230531.html
>>>> >
>>>> >> Sent from the java.net - jaxb users mailing list archive at
>>>> Nabble.com.
>>>> >>
>>>> >>
>>>> >>
>>>> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>>> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>>> >>
>>>> >>
>>>> >>
>>>> >>
>>>> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>>> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/jaxb-binding-file-for-%2B-%3Cextension-base%3D%22anyType%22-%3E-tp26230531p26255409.html
>>>> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>>>
>>>>
>>>
>>>
>> http://old.nabble.com/file/p26263905/Resource.xml Resource.xml
>> --
>> View this message in context:
>> http://old.nabble.com/jaxb-binding-file-for-%2B-%3Cextension-base%3D%22anyType%22-%3E-tp26230531p26263905.html
>> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>

-- 
View this message in context: http://old.nabble.com/jaxb-binding-file-for-%2B-%3Cextension-base%3D%22anyType%22-%3E-tp26230531p26266053.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.