如何解决JAXB XJC代码生成-Marshaller生成的xml中缺少“ schemaLocation”
试试这个:
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://my.namespace my.schema.xsd");
解决方法
我使用XJC工具为XSD架构生成Java类。当我使用JAXB Marshaller将类编组为XML有效负载时,我在输出XML中缺少“
schemaLocation”参数,但在xsd文件中声明了此参数。如何在输出XML中强制执行“ schemaLocation”参数?
以下是用于代码生成的xsd模式文件的开头:
<?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>
问候
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。