Плагин Maven Xjc/Jaxb не может анализировать простой файл Xsd

Я использую плагин org.jvnet и пытаюсь преобразовать файл xsd в Объект с аннотацией Java Jaxb для использования при маршаллинге и демаршаллинге. Однако возникает ошибка при попытке скомпилировать простой файл Xsd для использования.

Я думаю, что я делаю простую синтаксическую ошибку, второй взгляд был бы очень признателен. Если есть какие-либо подробности, которые я должен предоставить, пожалуйста, дайте мне знать. Все соответствующие файлы и сообщения включены ниже.

Сообщение об ошибке:

[ERROR] Error while parsing schema(s).Location [ file:/C:/.../project/asdfasdf/src/main/resources/RandomObjectSchema.
xsd{6,46}].

org.xml.sax.SAXParseException; systemId:
  file:/C:/.../project/asdfasdf/src/main/resources/RandomObjectSchema.xsd;
    lineNumber: 6; columnNumber: 46; src-resolve.4.2: Error resolving component 'xsd:int'.
    It was detected that 'xsd:int' is in namespace 'http://www.w3c.org/2001/XMLSchema',
    but components from this namespace are not referenceable from schema document
    'file:/C:/.../project/asdfasdf/src/main/resources/RandomObjectSchema.xsd'.
    If this is the incorrect namespace, perhaps the prefix of 'xsd:int' needs to be changed.
    If this is the correct namespace, then an appropriate 'import' tag should be added to 
    'file:/C:/.../project/asdfasdf/src/main/resources/RandomObjectSchema.xsd'.




        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX
ParseException(ErrorHandlerWrapper.java:203)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Err
orHandlerWrapper.java:134)

Файл.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3c.org/2001/XMLSchema" targetNamespace="http://asdf.com/asdf">
    <xsd:element name="RandomObject">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="value" type="xsd:int"></xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>asdf</groupId>
  <artifactId>asdfasdf</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>asdfasdf</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.13.1</version>
            <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
        </plugin>
    </plugins>
  </build>

</project>

person RD_WF    schedule 08.03.2018    source источник


Ответы (1)


У вас ошибка в пространстве имен xsd.

У вас есть:

http://www.w3c.org/2001/XMLSchema

Должен быть:

http://www.w3.org/2001/XMLSchema

(www.w3c.org vs. www.w3.org)

Журнал ошибок довольно подробно об этом:

[ERROR] s4s-elt-schema-ns: The namespace of element 'schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
  line 2 of file:/.../test.xsd
person lexicore    schedule 09.03.2018