users@jaxb.java.net

Re: XPath expressions in external binding declarations

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 26 Feb 2003 07:53:53 -0800

> With the implementation of the external binding declaration based on
> XPath, I thought "that is cool, I can do my multiple name conflict
> customizations (like rename Class to ClassName) in one single step".
> However it appears an XPath expression may only resolve to one node:
>
> <bindings node="//xsd:attribute[@name='class']">
> <property name="className"/>
> </bindings>
>
> Is there a reasons for this, for it would be nice to apply a
> transformation on multiple nodes at once. I can see you can have some
> precedence problems, but nothing that can't be solved I guess.

Thanks for the feedback.

As far as I can tell, the only reason is to prevent people from
accidentally writing XPath exps that match things that are not expected.
We found internally that many people (including me!) write incorrect
XPath, so I felt that it's safer to block multiple matching.

For example, one typical example is to write an XPath like

    //xsd:element[@name='foo']

where it matches not only a global foo declaration, which is intended,
but also some other local foo declarations.

But what you explained sounds legitimate and is very interesting to me.
I wonder how other people feel.

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com