首页 > 解决方案 > xsd 模式生成的类中的问题

问题描述

我有一个 xsd 架构。我由 Eclipse 插件 java 类(Generate-->JaxbClasses)生成。我生成的类在 xmlRootElement 注释上显示错误:@XmlRootElement(name = "CommonData"):

在这一行,我收到此错误

“无法在此上下文中使用命名空间 '' 和名称 'CommonData' 解析 XML 元素声明”。

其他生成的类也有同样的问题。

有什么建议吗?

谢谢。

<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"      elementFormDefault="unqualified" attributeFormDefault="unqualified">
    <xs:simpleType name="MsisdnInterrogatoType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="20"/>
            <xs:pattern value="([0-9])+"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="OperatoreType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="12"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="SceltaTipoTrafficoType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Y"/>
            <xs:enumeration value=" "/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="SubSysType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="10"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="QueryRiepilogoCosti">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="CommonData"/>
                <xs:element ref="QueryGroup"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="CommonData">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="SubSys" type="SubSysType"/>
                <xs:element name="Operatore" type="OperatoreType"/>
                <xs:element name="MsisdnInterrogato" type="MsisdnInterrogatoType"/>
                <xs:element name="DataInizio" type="xs:dateTime"/>
                <xs:element name="DataFine" type="xs:dateTime"/>
                <xs:element name="TutteLeTipologie" type="SceltaTipoTrafficoType" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="QueryGroup">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="WAP" type="SceltaTipoTrafficoType"/>
                <xs:element name="GPRS" type="SceltaTipoTrafficoType"/>
                <xs:element name="GPRSEstero" type="SceltaTipoTrafficoType"/>
                <xs:element name="WAPEvento" type="SceltaTipoTrafficoType"/>
                <xs:element name="GPRSEvento" type="SceltaTipoTrafficoType"/>
                <xs:element name="WLAN" type="SceltaTipoTrafficoType" minOccurs="0"/>
                <xs:element name="RCS" type="SceltaTipoTrafficoType"/>
                </xs:sequence>
        </xs:complexType>
    </xs:element>
    </xs:schema>'

标签: javaxmleclipsejaxb

解决方案


推荐阅读