JAXB XJC代码生成 - 由Marshaller生成的xml中缺少“schemaLocation”
问题描述:
I使用XJC工具为我的XSD模式生成Java类。当我使用JAXB Marshaller将类组装到XML有效负载中时,我在输出XML中缺少“schemaLocation”参数,但我在xsd文件中声明了此参数。如何在输出XML中实施“schemaLocation”参数?JAXB XJC代码生成 - 由Marshaller生成的xml中缺少“schemaLocation”
下面是我的XSD架构文件用于代码生成的beggining:
<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="xsdns" xmlns:messages="http://www.exampleURI.com/Schema1" xmlns:datatypes="http://www.exampleURI.com/Schema1" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="http://www.exampleURI.com/Schema1 ./messages.xsd" targetNamespace="http://www.exampleURI.com/Schema1" elementFormDefault="unqualified" version="true">
<xs:include schemaLocation="datatypes.xsd"/>
<xs:complexType name="execute-system-command-struct">
<xs:annotation>
<xs:documentation>The request for system command execution.</xs:documentation>
</xs:annotation>
<xs:sequence/>
<xs:attribute name="action" type="datatypes:system-action-kind-enum" use="required">
<xs:annotation>
<xs:documentation>The action that the Voice System has to proceed.</xs:documentation>
</xs:annotation>
</xs:attribute>
问候
答
试试这个:
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://my.namespace my.schema.xsd");
你能不能给由正在生成的XML的例子JAXB,以及与你有什么不同*想要它产生? – skaffman 2010-01-29 10:49:44
已经通过xcut回答。谢谢 – cubesoft 2010-02-01 12:42:45