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