【问题标题】:Error when converting an XSD to its classes with JAXB使用 JAXB 将 XSD 转换为其类时出错
【发布时间】:2009-12-21 05:06:34
【问题描述】:

这是我第一次尝试将 JAXB 用于任何事情,但我遇到了问题。

当我收到此错误时,我正在尝试使用 JAXB 的 XJC 工具将 XSD 文件转换为 Java 类文件:

parsing a schema...  
[ERROR] The prefix "msdata" for attribute "msdata:ColumnName" associated with an element type "xs:simpleContent" is not bound.  
line 10 of file:/home/jeremy/TypeDefs.xsd
Failed to parse a schema.

架构文件中的第 10 行内容如下:

<xs:simpleContent msdata:ColumnName="paramText" msdata:Ordinal="1">

你可以看到整个事情here

编辑:原来 XSD 文件缺少 msdata 的命名空间声明。只需添加 xmlns:msdata="http://schemas.microsoft.com/2003/07/msdata.xsd" 即可解决问题。

【问题讨论】:

    标签: java xsd jaxb


    【解决方案1】:

    您需要映射 msdata 命名空间前缀。喜欢

    <xs:schema targetNamespace="http://maps.trimet.org/maps/model/xml" 
        xmlns="http://maps.trimet.org/maps/model/xml"
        ....
        xmlns:msdata="http://yournamespace.com/foo">
    

    【讨论】:

    • 谢谢,我在你回答的时候就知道了,但你是对的,所以......接受!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    • 2019-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多