I'm using the Xerces Java parser to validate XML instances againts XSD schemas.
In case of error (constraint violation), I need to provide information back to the user about the problem such as :
- value provided by the user,
- constraint violated,
- list of the facets of the object (min, max, nb of fractional digits, ...) and in addition, if possible, some (non native) attributes of the element.

Example :

Here is a complex type describing the properties an element must match :

<xsd:complexType name="hciRADIUS_ACC_THRES_T">
        <xsd:simpleContent>
                <xsd:restriction base="FloatDef_T">
                        <xsd:maxInclusive value="99.9"/>
                        <xsd:minInclusive value="1.0"/>
                        <xsd:fractionDigits value="1"/>
                        <xsd:attribute ref="label" fixed="Radius Acc Thres"/>
                        <xsd:attribute ref="continous" fixed="true"/>
                        <xsd:attribute name="precision" type="xsd:decimal" fixed="0.1"/>
                </xsd:restriction>
        </xsd:simpleContent>
</xsd:complexType>

Here is the corresponding element :

<xsd:element name="hciRADIUS_ACC_THRES" type="hciRADIUS_ACC_THRES_T">

When receiving the element "hciRADIUS_ACC_THRES" in an XML instance with value 120.33 for example :

<hciRADIUS_ACC_THRES>120.33</hciRADIUS_ACC_THRES>

I would like to retrieve information about the properties of the element type in order to send an error message back to the user, message which could be formatted as follow :

Radius Acc Thres error[info contained in attribute "label"] : value 120.33
Possible values : from 1.0[info contained in "minInclusive" facet] to 99.9[info contained in "maxInclusive" facet], number of fractional digits is 1[info contained in "fractionDigits" facet]...

My question are :
- Is it possible to do that using Xerces Java ? -> can anybody send me some code examples or tell me where to find them ?
- Should I use DOM Level 3 API ? PSVI ?

Thank you all

Reply via email to