我可以改变" xsdlib.jar"异常消息?

时间:2016-06-24 07:22:00

标签: java xml xsd

我有一个.xsd文件,在此文件中包含标签绑定信息,如属性ID,类型,名称等。

当我导入与.xml相关的.xsd文件时,我收到了异常

Location: line 1618 07:18:36,465 ERROR [STDERR]javax.xml.bind.UnmarshalException:
  the length of the value is 11, but the required maximum is 10.

我的标签是

 <xs:element name="name" type="String10"/>

 <xs:simpleType name="String10">
        <xs:restriction base="xs:normalizedString">
            <xs:maxLength value="10"/>
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>`

我不想更改标记的大小,但我想更改错误消息格式,例如length of "size" is 11.而不是value

1 个答案:

答案 0 :(得分:0)

您可以在捕获它后使用UnmarshalException,并且可以使用所需的消息抛出新的UnmarshalException