users@jaxb.java.net

Re: Too many target nodes (Xpath)

From: Roger Parkinson <roger.parkinson35_at_gmail.com>
Date: Sun, 01 May 2011 12:24:03 +1200
The separate file was the clue I needed, thanks.
This is the xjb file I ended up using:

<?xml version="1.0"?>
<jaxb:bindings version="2.1"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:annox="http://annox.dev.java.net"
               >
                  
    <jaxb:bindings schemaLocation="sandbox.xsd" node="/xsd:schema">
        <jaxb:bindings node="//xsd:complexType" multiple="true" required="false">
            <annox:annotate>
                <annox:annotate annox:class="org.hibernate.annotations.Cache" include="all" usage="NONSTRICT_READ_WRITE" region="RuntimeCatalogueCache"/>
            </annox:annotate>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

This results in all my generated java classes having:
@Cache(include = "all", region = "RuntimeCatalogueCache", usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

I expected it to need jaxb 2.2.3 but I slipped it into another project that was already using 2.2 and that worked fine.

Regards
Roger

On 27/04/11 03:24, Pavel Bucek wrote:
Do you use schema validation? If so, can you tun it off and try again? Or place these bindings into separate file..

Pavel

On 4/21/11 1:17 AM, Roger Parkinson wrote:
Sure (I actually tried that first). I get a similar error:
      [xjc] build id of XJC is 2.2.3-hudson-jaxb-ri-2.2-70-
        ....
      [xjc] [ERROR] cvc-complex-type.3.2.2: Attribute 'required' is not allowed to appear in element 'jaxb:bindings'.
      [xjc]   line 23 of file:/home/roger/workspace/madura-objects.google/new.xsd
      [xjc] [ERROR] cvc-complex-type.3.2.2: Attribute 'multiple' is not allowed to appear in element 'jaxb:bindings'.
      [xjc]   line 23 of file:/home/roger/workspace/madura-objects.google/new.xsd

(I added the version report there just so you know I really am running 2.2.3)
Thanks
Roger

On 20/04/11 23:46, Pavel Bucek wrote:
can you please try: <jaxb:bindings node="//xsd:complexType" multiple="true" required="false"> ? (remove jaxb prefix from attributes).

Pavel

On 4/20/11 11:36 AM, Roger Parkinson wrote:
What version of jaxb? I tried 2.2.3 and it told me
Attribute 'jaxb:required' is not allowed to appear in element 'jaxb:bindings'.
This is what I tried:

    <jaxb:bindings node="//xsd:complexType" jaxb:multiple="true" jaxb:required="false">
        <annox:annotate>
            <annox:annotate
                annox:class="org.hibernate.search.annotations.Field" annox:name="item" />
        </annox:annotate>
    </jaxb:bindings>

and I got:

     [xjc] [ERROR] XPath evaluation of "//xsd:complexType" results in too many (105) target nodes
      [xjc]   line 23 of file:/home/roger/workspace/madura-objects.google/new.xsd
      [xjc] [ERROR] cvc-complex-type.3.2.2: Attribute 'jaxb:required' is not allowed to appear in element 'jaxb:bindings'.
      [xjc]   line 23 of file:/home/roger/workspace/madura-objects.google/new.xsd
      [xjc] [ERROR] cvc-complex-type.3.2.2: Attribute 'jaxb:multiple' is not allowed to appear in element 'jaxb:bindings'.
      [xjc]   line 23 of file:/home/roger/workspace/madura-objects.google/new.xsd

But it would be good to get this working
Regards
Roger

On 20/04/11 19:32, Pavel Bucek wrote:
hello,

btw, you can try something like this:

<jxb:bindings node="..." multiple="true" required="false">
        ...
</jxb:bindings>


multiple allows you to select more than one target and required disables the need to match at least one element.

fyi these properties are non-documented (and experimental), but it could work for you :)

Pavel


On 4/19/11 10:55 AM, Roger Parkinson wrote:
Thanks, Lexi.

I'll go for the plugin approach. I'm going to need a plugin for this thing anyway so it's just a bit more to add to it.
I've done a couple of them before (http://code.google.com/p/madura-objects/) and they're a nice combination of powerful and easy.

Roger

On 19/04/11 19:20, Aleksei Valikov wrote:
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@jaxb.java.net ML.

Bye,
/lexi


--
Roger Parkinson
Mob +64 21 508 792
Twitter
Blog
Home Page
Fiction


--
Roger Parkinson
Mob +64 21 508 792
Twitter
Blog
Home Page
Fiction


--
Roger Parkinson
Mob +64 21 508 792
Twitter
Blog
Home Page
Fiction


--
Roger Parkinson
Mob +64 21 508 792
Twitter
Blog
Home Page
Fiction

picture
(image/png attachment: 01-part)

picture
(image/png attachment: 02-part)

picture
(image/png attachment: 03-part)

Roger_Parkinson.png
(image/png attachment: Roger_Parkinson.png)