简体   繁体   English

使用JAXB将XSD转换为其类时出错

[英]Error when converting an XSD to its classes with JAXB

This is the first time I've ever tried to use JAXB for anything at all and I'm running into a problem. 这是我第一次尝试对所有内容都使用JAXB,但遇到了问题。

I'm trying to use JAXB's XJC tool to convert an XSD file into Java class files when I get this error: 当出现此错误时,我正在尝试使用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.

Line 10 in the schema file reads: 模式文件中的第10行读取:

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

and you can see the whole thing here . 你可以在这里看到整个事情。

edit : It turns out the XSD file was missing the namespace declaration for msdata. 编辑 :原来XSD文件缺少msdata的名称空间声明。 Simply adding xmlns:msdata="http://schemas.microsoft.com/2003/07/msdata.xsd" fixed the problem. 只需添加xmlns:msdata="http://schemas.microsoft.com/2003/07/msdata.xsd"解决此问题。

You need to have the msdata namespace prefix mapped. 您需要映射msdata命名空间前缀。 Like 喜欢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM