Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schemaLocation="*" leads to issue in applicated binding #1788

Open
laurentschoelens opened this issue Feb 15, 2024 · 0 comments
Open

schemaLocation="*" leads to issue in applicated binding #1788

laurentschoelens opened this issue Feb 15, 2024 · 0 comments

Comments

@laurentschoelens
Copy link
Contributor

Context

I've got 3 XSD + 1 binding file (bindings.xjb) which contains the following :

<jaxb:bindings schemaLocation="*">
  <jaxb:schemaBindings>
    <jaxb:nameXmlTransform>
      <jaxb:elementName prefix="My" suffix="Dto"/>
      <jaxb:typeName prefix="My" suffix="Dto"/>
    </jaxb:nameXmlTransform>
  </jaxb:schemaBindings>
</jaxb:bindings>

Behavior

When I run the xjc with this, I got some error related to schemaBindings not being applied to anything (in french below) :

com.sun.istack.SAXParseException2: La personnalisation "jaxb:schemaBindings" n'est associée à aucun élément de schéma.

If I do it in debug mode, I see that I go inside this part of the com.sun.tools.xjc.reader.internalizer.Internalizer#buildTargetNodeMap function

if(schemaLocation.equals("*")) {
    for(String systemId : forest.listSystemIDs()) {
        result.computeIfAbsent(bindings, k -> new ArrayList<>());
        result.get(bindings).add(forest.get(systemId).getDocumentElement());

        Element[] children = DOMUtils.getChildElements(bindings, Const.JAXB_NSURI, "bindings");
        for (Element value : children)
            buildTargetNodeMap(value, forest.get(systemId).getDocumentElement(), inheritedSCD, result, scdResult);
    }
    return;
}

Problem

The problem is listSystemIDs() returns my 3 XSD + my binding file, in which this binding will not be applied...

Analysis

If I remove the call to result.get(bindings).add(forest.get(systemId).getDocumentElement()); for the systemId of binding file, generation is OK with expected behavior : generated elements are prefixed with My and ends with Dto as defined in binding file)

Is it normal that we treat the binding file as one of elements of bindings to be applied ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant