最后我得到了下面的解决方案。
因为我希望在同一个模式上有两个名称空间,以便理解对主题的读取,所以
import
在我的XSD上是必要的。我最初的想法是设置不同的命名空间,但我只能为
PublishXYZFullModifyUsingXYZFullDesc
并将命名空间设置为
XYZFullDesc
忽略(不为空,视为无效),使用
ref
.
主要的XSD:
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:po="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
targetNamespace="http://www.oracle.com/retail/abcd/integration/services/XYZFullPublishingService/v1"
elementFormDefault="qualified">
<s:import schemaLocation="po.xsd"
namespace="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1" />
<s:element name="publishXYZFullModifyUsingXYZFullDesc">
<s:complexType>
<s:sequence>
<s:element ref="po:XYZFullDesc"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
导入的po.xsd:
<?xml version="1.0" encoding="utf-16" ?>
<s:schema targetNamespace="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
elementFormDefault="qualified">
<s:element name="XYZFullDesc" type="XYZFullDesc"/>
<s:complexType name="XYZFullDesc">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="order_no" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>
生成的Java存根:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"xyzFullDesc"
})
@XmlRootElement(name = "publishXYZFullModifyUsingXYZFullDesc", namespace = "http://www.oracle.com/retail/abcd/integration/services/XYZFullPublishingService/v1")
public class PublishXYZFullModifyUsingXYZFullDesc {
@XmlElement(name = "XYZFullDesc", required = true) // no namespace, but works for me
protected XYZFullDesc xyzFullDesc;
}