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

Not renaming xsd and namespace not added to generated XSD #268

Open
Ecstasy1857 opened this issue Aug 15, 2023 · 0 comments
Open

Not renaming xsd and namespace not added to generated XSD #268

Ecstasy1857 opened this issue Aug 15, 2023 · 0 comments

Comments

@Ecstasy1857
Copy link

I am trying to generate xsd out of java objects that are annotated with jaxb annotations. When executing the schemagen its generating xsd but it doesnt rename it and no namespace exists. During maven install execution, I see an warning from the plugin

[INFO] XSD post-processing: Renaming and converting XSDs.
[WARNING] SimpleNamespaceResolver contained no localNamespaceURI; aborting rename.

while debugging the jaxb2-maven plugin code, its trying to search namespace in the generated xml and I don't see that either. So namespace given in java classes are not translating to XSDs. Here is pom.xml and java classes and generated xsds for reference

pom.xml

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>schemagen</id>
            <goals>
                <goal>schemagen</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <sources>
                    <source>
                        ${project.basedir}\src\main\java\com\example\o\tools\overridesscanner\xsd\beans\</source>
                </sources>
                <quiet>true</quiet>
                <sources>
                    <source>
                        ${project.basedir}\src\main\java\com\example\o\tools\overridesscanner\xsd\beans\Release.java</source>
                    <source>
                        ${project.basedir}\src\main\java\com\example\o\tools\overridesscanner\xsd\beans\Root.java</source>
                </sources>
                <transformSchemas>
                    <transformSchema>
                        <uri>http://www.example.com/2023/08/31/releases</uri>
                        <toPrefix>some</toPrefix>
                        <toFile>some_schema.xsd</toFile>
                    </transformSchema>
                </transformSchemas>
                <outputDirectory>${project.basedir}\src\main\resources\schemas</outputDirectory>
                <clearOutputDir>true</clearOutputDir>
            </configuration>
        </execution>
    </executions>
</plugin>

generated xsd with schema1.xsd name

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">

    <xs:complexType name="release">
        <xs:sequence>
            <xs:element minOccurs="0" name="parentReleaseName" type="xs:string" />
            <xs:element minOccurs="0" name="parentReleasePath" type="xs:string" />
            <xs:element minOccurs="0" name="releaseName" type="xs:string" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="root">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="releases" nillable="true"
                type="release" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

package-info.java class

@XmlSchema(namespace = "http://www.example.com/2023/08/31/releases", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
		@XmlNs(prefix = "", namespaceURI = "http://www.example.com/2023/08/31/releases") })
package com.accenture.ohio.tools.overridesscanner.xsd.beans;

import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;

java classes with annotations


@XmlRootElement(name = "root", namespace = "http://www.example.com/2023/08/31/releases")
@XmlType(namespace = "http://www.example.com/2023/08/31/releases")
@XmlAccessorType(XmlAccessType.FIELD)
public class Root {

    public List<Release> getReleases() {
        return releases;
    }

    public void setReleases(List<Release> releases) {
        this.releases = releases;
    }

    private List<Release> releases;

}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://www.example.com/2023/08/31/releases")
public class Release {

    @XmlElement(name = "releaseName")
    private String releaseName;
    @XmlElement(name = "parentReleaseName")
    private String parentReleaseName;
    @XmlElement(name = "parentReleasePath")
    private String parentReleasePath;

    public String getReleaseName() {
        return releaseName;
    }

    public void setReleaseName(String releaseName) {
        this.releaseName = releaseName;
    }

    public String getParentReleaseName() {
        return parentReleaseName;
    }

    public void setParentReleaseName(String parentReleaseName) {
        this.parentReleaseName = parentReleaseName;
    }

    public String getParentReleasePath() {
        return parentReleasePath;
    }

    public void setParentReleasePath(String parentReleasePath) {
        this.parentReleasePath = parentReleasePath;
    }

}
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