mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
105 stars 76 forks source link

'xmldsig-core-schema.xsd' build does not work with 2.5.0 BUT it works with 2.4 on Windows #157

Open zappee opened 4 years ago

zappee commented 4 years ago

I am working with an XSD where I imported the standard ds:Signature element.

The xjcgoal works fine on Unix but it does not work on Windows. The version I use: 2.5.0

Error on Windows: Failed to instantiate [...xml.XmlValidator]: Factory method 'xmlValidatorService' threw exception; nested exception is org.xml.sax.SAXParseException; systemId: file:/....xsd; lineNumber: 27; columnNumber: 65; src-resolve: Cannot resolve the name 'ds:Signature' to a(n) 'element declaration' component.

But the same source code works fine with version 2.4 on Unix and Windows as well.

Plugin configuration:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>${version.jaxb2-maven-plugin}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <xjbSources>
                        <xjbSource>src/main/resources/schema/binding</xjbSource>
                    </xjbSources>
                    <sources>
                        <source>src/main/resources/schema/swisslinking/....xsd</source>
                    </sources>
                    <packageName>...</packageName>
                    <clearOutputDir>true</clearOutputDir>
                </configuration>
            </plugin>

XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:..."
            xmlns:typens="urn:..."
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
            xmlns="urn:..."
            version="0.2">

    <xsd:import schemaLocation="./...-commons.xsd" namespace="urn:..." />
    <xsd:import schemaLocation="./xmldsig-core-schema.xsd" namespace="http://www.w3.org/2000/09/xmldsig#" />

    <xsd:element name="Message">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="messageId" type="xsd:string" />
                <xsd:choice>
                     ....
                </xsd:choice>
                <xsd:element ref="ds:Signature" minOccurs="0" />
            </xsd:sequence>
            <xsd:attribute name="Id" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>