Reputation: 11
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
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:
<?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
Upvotes: 1
Views: 2745
Reputation: 5568
The xs: namespace prefix referes to different namespaces in the two documents. In your xsd you have:
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. Either fix the namespaces, or write the xpath namespace neutral ( //*[local-name() = 'schema']/*[local-name()='element' and @name='BaseDirectory']
)
Upvotes: 2