users@jaxb.java.net

Re: Too many target nodes (Xpath)

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 19 Apr 2011 09:20:44 +0200

Hi,

> I was trying to do this:
> <schema ....
> <xsd:annotation>
> <xsd:appinfo>
>     .....
>     <jaxb:bindings node="//xsd:complexType">
>         <annox:annotate>
>             <annox:annotate
> annox:class="org.hibernate.search.annotations.Field" annox:name="item" />
>         </annox:annotate>
>     </jaxb:bindings>
>
> ...
>
> The intention was to add an annotation onto every generated class.
> It looks promising but I get this:
>
>       [xjc] [ERROR] XPath evaluation of "//xsd:complexType" results in too
> many (105) target nodes
>       [xjc]   line 26 of
> file:/home/roger/workspace/madura-objects.google/new.xsd
>
> I gather this is a problem with XPath (well there's the error message). Is
> there a way around it?
> Eg specify the syntax differently etc?
> Probably a long shot but I figure you guys would have worked around it if
> anyone has.

XJC does not allow you to customize several nodes at once. So it's not
the XPath problem, it's XJC problem. XJC simply disallows this.

Options:
* File an RFE for JAXB RI, so that this feature is added to XJC.
* Write a JAXB plugin which allows adding customization elements to
several items at once.

The first one is the "official" way. With the second one you can
achieve much more flexibility. I find it quite cumbersome defining
customizations in schema or binding files. I always wanted something
like extra XML files which are just named accordingly.

I'm reposting to the users_at_jaxb.java.net ML.

Bye,
/lexi