Erik Ostermueller wrote:
> Have you looked at JXPath?
> http://jakarta.apache.org/commons/jxpath/
Thanks for bringing this concept to our attention.
Please note that JAXB currently provides a schema-derived
view of the XML content that is closer to JavaBean like than
DOM like. Thus, as the JXPath user guide states, don't expect
any visible help from JAXB v1.0 in distinguishing whether
a JavaBean property corresponds with an attribute or
a child element. Obviously, the JAXB implementation knows
how to map the JavaBean property to the appropriate
XML infoset attribute/child element for validation and
marshalling, but the implementation only uses this
information at this time to implement the validation
and marshalling behavior at this time.
JXPath over JavaBean should work fine in JAXB v1.0.
It would be interesting in the future to consider finer grain integration
that would allow JXPath to *know* the XML infoset relationships
of the JAXB schema-derived interfaces/properties and allow
xml-relevant XPath over JAXB schema-derived classes. On first hunch,
the JXPathIntorspector might allow for such an integration point
in the JXPath side. However, JAXB v1.0 does not provide a public API for
exposing the schema-derived properties relations to the XML infoset so that
would not be possible against the existing specification in a portable fashion.
-Joe Fialli, Sun Microsystems
>
> > -----Original Message-----
> > From: James Sheridan [mailto:james.sheridan_at_fraysen.com]
> > Sent: Monday, February 24, 2003 2:13 PM
> > To: JAXB-INTEREST_at_JAVA.SUN.COM
> > Subject: [JAXB-INTEREST] XPath and JAXB
> >
> >
> > Hi,
> >
> > I am new to JAXB and am finding it extremely useful.
> > However I have a
> > problem. While in my code I don't want to have to parse
> > or otherwise be
> > aware of the underlying XML (this is why I'm using
> > JAXB) I do have to
> > find some elements using XPath expressions. From what I
> > can see from
> > code generated by JAXB there is no XPath navigation API
> > included. I
> > realise I could probably go the DOM+XPathAPI route but
> > due to resource
> > constraints (very large number of documents to manage)
> > this approach
> > (especially the DOM bit) is too heavyweight.
> > My ideal would be JAXB to roll those nice Java classes
> > and hide the XML
> > and a related JAXB XPath API (I suppose this could use
> > reflection to
> > navigate the JAXB-generated classes, though there may
> > be better ways).
> > Anyway, does anyone know if JAXB supports or is
> > planning to support an
> > XPath API ?
> >
> > Many thanks in advance,
> > James
> >
--