XJC : Creating Stub for XBRL schemas

237 views Asked by At

After a few hours now, I am unable to create the Java stubs for several xrbl XSD's. There seems to be a problem with the legacy files. Then, every time you try to customize the xjc outputs:

[ERROR] XPath evaluation of "schema" results in empty target node
line 4 of file:/C:/Users/Carlos%20Conti/Desktop/ipp/2008/bindings.xml

After this, theory says that I must write a customization in the form of an external bindings.xml file where I resolve the conflict, but I am not being able to overcome that. I am currently stuck at the point where XPath isn't able to find the most basic node in the referenced file inside the customization file.

Here is the customization file:

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <jxb:bindings schemaLocation="http://www.xbrl.org/2003/xl-2003-12-31.xsd" node="schema">
    <jxb:bindings node="//complexType[@name='locatorType']//sequence/element[@ref='xl:title']">
      <jxb:property ref="xlink:title" />
    </jxb:bindings>
  </jxb:bindings>
</jxb:bindings>

When I include this as the external customization, an additional error is output:

[ERROR] XPath evaluation of "schema" results in empty target node
line 4 of file:/C:/Users/Carlos%20Conti/Desktop/ipp/2008/bindings.xml

The file I am trying to build java classes from is quite big. Sorry, but I cannot link it either. The main problem though comes from an imported xsd inside that file (xl-2003-12-31.xsd), which can be found here:

So this should be enough information to solve the problem.

I am pretty sure it is a tiny detail I am omitting, but I am not being able to get through.

Any advise is greatly welcome.

1

There are 1 answers

0
Ghislain Fourny On

It looks to me like there is something wrong with namespaces.

The XPath expression:

//complexType[@name='locatorType']//sequence/element[@ref='xl:title']

has empty prefixes everywhere, but no default namespace seems to be in scope. Hence, unless XJC provides and documents a default namespace, this means that the above XPath expression will return an empty sequence. Indeed, XML Schema elements are in the XML Schema namespace. You can see also this in XBRL's XLink schema (the link provided) because, even though it does not use prefixes, it does have a default namespace binding:

xmlns="http://www.w3.org/2001/XMLSchema"

Since the root element in the customization file binds this namespace to the xsd prefix, this XPath expression may work better:

//xsd:complexType[@name='locatorType']//xsd:sequence/xsd:element[@ref='xl:title']

The same applies on the line above: node="schema" should probably be replaced with node="xsd:schema".

The most important thing to remember is that prefixes (or the absence thereof) do not matter, only the namespaces matter:

  • A prefix bound to two difference namespaces in two different files will not match against itself.
  • Two prefixes bound to the same namespace, however, will match.