简体   繁体   中英

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.

I'm trying to use JAXB's XJC tool to convert an XSD file into Java class files when I get this error:

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:

<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. Simply adding xmlns:msdata="http://schemas.microsoft.com/2003/07/msdata.xsd" fixed the problem.

You need to have the msdata namespace prefix mapped. 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">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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