Custom error messages when XSD validation fails?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Artie

    Custom error messages when XSD validation fails?

    Hi,

    Is there any way to tell an XSD Schema that you want custom error
    codes for particular validation failures in an XML document?

    To show what I mean, here's an example:

    XSD excerpt

    <xs:element name = "EmployeeID ">
    <xs:simpleTyp e>
    <xs:restricti on base = "xs:string" >
    <xs:length value = "3"/>
    <xs:pattern value = "[0-9]{3}"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>

    XML excerpt

    <EmployeeID>123 4</EmployeeID>

    When the XML fails to validate against its XSD element, I want, say,
    error code 1000 to be returned from the validator - can this be done
    easily?

    (I'm thinking along the lines of having an element like
    <xs:customError Code = 1000along side each restriction.)

    Any help very much appreciated

    Artie

  • Martin Honnen

    #2
    Re: Custom error messages when XSD validation fails?

    Artie wrote:
    When the XML fails to validate against its XSD element, I want, say,
    error code 1000 to be returned from the validator - can this be done
    easily?
    >
    (I'm thinking along the lines of having an element like
    <xs:customError Code = 1000along side each restriction.)
    I don't think the schema language has any construct to define custom
    error messages. Nor have I have heard that a particular schema validator
    supports that. You might want to ask on a mailing list or forum or
    newsgroup for the particular schema validator you use or want to use.


    --

    Martin Honnen

    Comment

    Working...