Topic
2 replies Latest Post - ‏2012-02-23T15:45:28Z by VV4H_mario_fernandes
VV4H_mario_fernandes
43 Posts
ACCEPTED ANSWER

Pinned topic xmlvalidate

‏2012-02-22T19:29:31Z |
How can I use xmlvalidate on the result xml_client column in the query below.

select xml_client from KASPER.XML_CLIENT
where
XMLEXISTS('$d/kasperSchema/TDSClient/kasperClient/client' passing xml_client as "d")
Updated on 2012-02-23T15:45:28Z at 2012-02-23T15:45:28Z by VV4H_mario_fernandes
  • MatthiasNicola
    MatthiasNicola
    321 Posts
    ACCEPTED ANSWER

    Re: xmlvalidate

    ‏2012-02-22T20:07:01Z  in response to VV4H_mario_fernandes
    Here is an example:

    
    SELECT XMLVALIDATE(xml_client ACCORDING TO XMLSCHEMA ID kasper.myxmlschema) FROM KASPER.XML_CLIENT WHERE XMLEXISTS(
    '$d/kasperSchema/TDSClient/kasperClient/client' passing xml_client as 
    "d")
    


    Note that this query fails at runtime as soon as one document is retrieved that is not valid for the specified schema.

    If a query retrieves multiple documents and you need to validate them all, you can write a stored procedure that loops over the result set of the document, validates one document at a time, and uses an exception handler do deal with the documents that fail the validation.

    Let me know if you need help with coding such a procedure. I might be able to dig up an example if I have time.

    Matthias


    Matthias Nicola
    http://www.tinyurl.com/pureXML
    http://nativexmldatabase.com/
  • VV4H_mario_fernandes
    43 Posts
    ACCEPTED ANSWER

    Re: xmlvalidate

    ‏2012-02-23T15:45:28Z  in response to VV4H_mario_fernandes
    Thanks a lot Matthias