JAXB empty node in bindings

半腔热情 提交于 2020-01-14 10:40:52

问题


JAXB can't parse the bindings for this example:

<xs:element name="classA" type="classA" substitutionGroup="classSubA"/>

<xs:complexType name="complexClassA" mixed="true">

<xs:attribute name="attA">
    <xs:annotation>
        <xs:appinfo>
            <moProperty value="classA:attA"/>
            <label value="Attribute A" default="true"/>
            <externAccess value="readWrite"/>
            <description value="NO COMMENTS"/>
        </xs:appinfo>
    </xs:annotation>
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:enumeration value="off"/>
            <xs:enumeration value="on"/>
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>

And the bindings.xml (fragment):

<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
    <jxb:bindings schemaLocation="schema/mySchema.xsd">
        <jxb:bindings node="//xs:complexType[@name='complexClassA']">
            <jxb:bindings node=".//xs:element[@name='attA']">
                <jxb:property name="att" />
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

When generating the Java files the error is:

com.sun.istack.SAXParseException2: XPath evaluation of ".//xs:element[@name='attA']" results in empty target node

What I'm overlooking?

Thank you.

Udo.


回答1:


I think this:

<jxb:bindings node=".//xs:element[@name='attA']">

Should be this:

<jxb:bindings node=".//xs:attribute[@name='attA']">

You have an attribute, XPath applies to an element.



来源:https://stackoverflow.com/questions/6845989/jaxb-empty-node-in-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!