users@jaxb.java.net

RE: Re: Accessing JAXB mappings

From: Moravec Jan <Jan.Moravec_at_ips-ag.cz>
Date: Mon, 6 Sep 2004 14:47:53 +0200

Hi,

To have a closure on this can somebody from the JAXB dev group please tell me whether the JAXB class-name/method name mappings are somehow accessible at the moment, or at least, if there are plans to make them accessible in future releases. I feel this would be an a very useful thing in cases when you work with schemas for which you generate and compile JAXB classes at runtime and you need to populate them with data. Obviously read-only access would be sufficient.

Cheers,
Jan

-----Original Message-----
From: Moravec Jan
Sent: Monday, August 30, 2004 3:48 PM
To: 'users_at_jaxb.dev.java.net'
Subject: RE: Re: Accessing JAXB mappings


That would definitely work, but as you say, one would use it in the worst case only. IMHO the preferable way would be to use the JAXB mappings. I still found no answer as for whether it is actually exposed in the public API anywhere, or if there are some plans to expose it in the future versions. In the later case I would write some temporary model that would derive method names and xface/impl class names from xpath elements as sketched earlier in this thread.

Jan

-----Original Message-----
From: santony_at_bellsouth.net [mailto:santony_at_bellsouth.net]
Sent: Monday, August 30, 2004 3:22 PM
To: users_at_jaxb.dev.java.net; users_at_jaxb.dev.java.net
Subject: RE: Re: Accessing JAXB mappings


You will have to try it out to know.

In the worst case, one can
1. get the dom tree from the jaxb tree, using marshal
2. set/change the values on the dom node after getting the node by applying the xpath.
3. unmarshal the created dom tree to the jaxb tree, throwing away the earlier jaxb tree.

--sony



>
> From: "Moravec Jan" <Jan.Moravec_at_ips-ag.cz>
> Date: 2004/08/30 Mon AM 03:06:59 EDT
> To: <users_at_jaxb.dev.java.net>
> Subject: RE: Re: Accessing JAXB mappings
>
> This, although interesting, would not work in my case as I would need to be able set values in the content tree, not only query the content tree. I assume the changes you make to the DOM instance, as sketched below, are not reflected back in the original content tree. It would be pretty cool if they were though ;)
>
> Thank you,
> Jan
>
> -----Original Message-----
> From: santony_at_bellsouth.net [mailto:santony_at_bellsouth.net]
> Sent: Saturday, August 28, 2004 7:02 AM
> To: users_at_jaxb.dev.java.net
> Subject: Re: Re: Accessing JAXB mappings
>
>
>
> > Though I cannot remember the exact syntax, I remember getting the Dom node from the jaxb object.
> >
> This is what I was alluding to earlier
>
>
>
> //create a marshaller
> JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
> Marshaller m = jc.createMarshaller();
>
>
>
> //create a new document
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> DocumentBuilder db = dbf.newDocumentBuilder();
> Document doc = db.newDocument();
>
> //obj is the jaxb object
> m.marshal( obj, doc );
>
>
> Node nod = doc.getDocumentElement() ;
>
>
> //apply the xpath on the node
> Document doc = nod.getOwnerDocument() ;
> XPathEvaluator evaluator = new XPathEvaluatorImpl( document ) ;
> Element nsRoot = document.getDocumentElement() ;
> XPathNSResolver resolver = evaluator.createNSResolver( nsRoot ) ;
>
> XPathResult result = (XPathResult)evaluator.evaluate( "normalize-space(" + xpath + ")", document, resolver, XPathResult.STRING_TYPE, null ) ;
>
> Note that all APIs used are standardized and portable.
>
> --sony
>
>
> ---------------------------------------------------------------------
> 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
>
>


---------------------------------------------------------------------
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