JAXB XJCコード生成 - マーシャラーによって生成されたXMLで行方不明「のschemaLocation」

StackOverflow https://stackoverflow.com/questions/2161350

  •  23-09-2019
  •  | 
  •  

質問

私のXSDスキーマのためのJavaクラスを生成するためのI使用XJCツール。私は、XMLペイロードにマーシャリングクラスにJAXBマーシャラーを使用する場合、私は、出力XMLで「のschemaLocation」パラメータが欠落していますが、私は、XSDファイルのこのパラメータを宣言します。どのように出力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");
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top