users@jaxb.java.net

Re: XPath and External Binding Declarations.

From: Terence Song <terence.song_at_bristol.ac.uk>
Date: Mon, 25 Apr 2005 18:12:02 +0100

Message-ID: <EXECMAIL.1050425181202.E_at_EEN9121.bristol.ac.uk>
Priority: NORMAL
X-Mailer: Execmail for Win32 Version 5.0.1 Build (55)
MIME-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"

Hi,

Sorry about that. I did press send by mistake. Here's the complete thing...

I have a problem with external binding declarations. I have 4 schema files:

A.xsd
B.xsd
C.xsd
ABC.xsd

ABC.xsd uses <xs:include>s to include A.xsd and B.xsd, and <xs:redefine>s
attributeGroups in C.xsd with attributeGroups in A.xsd and B.xsd.

<xs:include schemaLocation="A.xsd" />
<xs:include schemaLocation="B.xsd" />
<xs:redefine schemaLocation="C.xsd">
  <xs:attributeGroup name="C.attrib">
    <xs:attributeGroup ref="C.attrib"/>
    <xs:attributeGroup ref="A.attrib"/>
  </xs:attributeGroup>

  <xs:attributeGroup name="C.attrib">
    <xs:attributeGroup ref="C.attrib"/>
    <xs:attributeGroup ref="B.attrib"/>
  </xs:attributeGroup>

</xs:redefine>

Now, If I compile schema="ABC.xsd" (using the XJC Ant task) without any
customization, everything seems fine. However, I would like to make "class" and
"property" binding customizations to the schemas A, B, and C. Using external
customization bindings, I would have to use XPath to reference the target
nodes.

According to Kohsuke Kawaguchi in a reply to a question regarding
"Customization and XPath Expressions," XPath works on XML documents as infoset,
it doesn't understand the concept of <xs:include>s. Additionally, the binding
declaration should reference the correct schema, e.g.,

<bindings schemaLocation="A.xsd">
</bindings>
<bindings schemaLocation="B.xsd">
</bindings>
<bindings schemaLocation="C.xsd">
</bindings>

My problem:

If I compile using schema="ABC.xsd" with the external binding customizations
applied to schemaLocation="ABC.xsd", I get "empty node set" errors, as
correctly pointed out by Kohsuke Kawaguchi. However, if I then specify separate
binding declarations for each schema as in the example above, and compile using
schema="ABC.xsd", I get errors saying something like "A.xsd is not in the list
of schemas to compile", etc. Should I then replace the schema="ABC.xsd" with
schema="A.xsd,B.xsd,C.xsd"? Will this generate the bindings correctly?

Please help.

Thanks in advance,

Terence

On Mon, 25 Apr 2005 10:09:30 -0700 Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
wrote:

> Terence Song wrote:
> > Hi,
> >
> > I have a problem with external binding declarations. I have 4 schema files:
> >
> > A.xsd
> > B.xsd
> > C.xsd
> > ABC.xsd
> >
> > ABC.xsd uses <xs:include>s to include A.xsd and B.xsd, and <xs:redefine>s
> > attributeGroups in C.xsd with attributeGroups in A.xsd and B.xsd.
> >
> > <xs:include schemaLocation="A.xsd" />
> > <xs:include schemaLocation="B.xsd" />
> > <xs:redefine schemaLocation="C.xsd">
> > <xs:attributeGroup name="C.attrib">
> > <xs:attributeGroup ref="C.attrib"/>
> > <xs:attributeGroup ref="A.attrib"/>
> > </xs:attributeGroup>
> >
> > <xs:attributeGroup name="C.attrib">
> > <xs:attributeGroup ref="C.attrib"/>
> > <xs:attributeGroup ref="B.attrib"/>
> > </xs:attributeGroup>
> >
> > </xs:redefine>
> >
> > Now, If I compile schema="ABC.xsd" (using the XJC Ant task) without any
> > customization, everything seems fine. However, I would like to make "class"
> and
> > "property" binding customizations to the schemas.
> >
> > According to Kohsuke Kawaguchi in a reply to a question regarding
> > "Customization and XPath Expressions," XPath works on XML documents as
> infoset,
> > it doesn't understand the concept of <xs:include>s.
>
> Did you hit enter too early?
>
> Tell me which portion of the schema you want to apply the customization.
> You can always point to any portion of any of the schema documents
> using XPath.
>
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com