[英]XPath evaluation in JAXB binding file results in empty target node
I try to change xsd element name via external jaxb binding file but for some reason global binding does not work and Xpath can't find the element 我尝试通过外部jaxb绑定文件更改xsd元素名称,但由于某些原因全局绑定不起作用,并且Xpath找不到该元素
Schema I want to change: 我要更改的架构:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.sitels.ru/FORIS/IL/DomainModel" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.sitels.ru/FORIS/IL/DomainModel">
<xs:complexType name="BaseDictionary">
<xs:sequence>
<xs:element minOccurs="0" name="Code" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="DateFrom" nillable="true" type="xs:dateTime"/>
<xs:element minOccurs="0" name="DateTo" nillable="true" type="xs:dateTime"/>
<xs:element minOccurs="0" name="Id" nillable="true" type="tns:UniqueIdentifier"/>
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="BaseDictionary" nillable="true" type="tns:BaseDictionary"/>
<xs:complexType name="UniqueIdentifier">
<xs:sequence>
<xs:element minOccurs="0" name="EntityId" type="xs:long"/>
<xs:element minOccurs="0" name="ForisId" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="UniqueIdentifier" nillable="true" type="tns:UniqueIdentifier"/>
</xs:schema>
Jaxb binding file: Jaxb绑定文件:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2000/10/XMLSchema-instance"
xs:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="DomainModel.xsd" node="//xs:schema//xs:element[@name='BaseDictionary']">
<jaxb:class name="DomainBaseDictionary" />
</jaxb:bindings>
</jaxb:bindings>
I get XPath evaluation of "//xs:schema//xs:element[@name='BaseDictionary']" results in empty target node when trying to compile 尝试编译时,我得到“ // xs:schema // xs:element [@ name ='BaseDictionary']”的XPath评估结果为空目标节点
The xs: namespace prefix referes to different namespaces in the two documents. xs:名称空间前缀引用两个文档中的不同名称空间。 In your xsd you have:
在您的xsd中,您有:
xmlns:xs="http://www.w3.org/2001/XMLSchema"
In your binding file you have: 在绑定文件中,您具有:
xmlns:xs="http://www.w3.org/2000/10/XMLSchema-instance"
So xs:schema != xs:schema. 所以xs:schema!= xs:schema。 Either fix the namespaces, or write the xpath namespace neutral (
//*[local-name() = 'schema']/*[local-name()='element' and @name='BaseDirectory']
) 修复名称空间,或将xpath名称空间写为中性(
//*[local-name() = 'schema']/*[local-name()='element' and @name='BaseDirectory']
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.