绑定中的JAXB空节点 [英] JAXB empty node in bindings

查看:186
本文介绍了绑定中的JAXB空节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JAXB 无法解析此示例的绑定:

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>

bindings.xml (片段) :

<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>

生成Java文件时出错:

When generating the Java files the error is:

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

我在俯瞰什么?

谢谢。

Udo。

推荐答案

我认为:

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

应该是这样:

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

你有一个属性,XPath适用于一个元素。

You have an attribute, XPath applies to an element.

这篇关于绑定中的JAXB空节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆