Example: 'xmlerror' option capabilities with External File Access  Example: parsing XML and non-XML documents with the 'xmlerror=message' option

Appendix C: XML Services and External File System Access

Example: specifying the 'xmlerror=message’ option in xmlextract

In this example, we specify the 'xmlerror= message' option in the xmlextract call. This will return the XML query results for XML documents that are valid XML, and return an XML error message element for documents that are not valid XML.

select filename , xmlextract("//book/title",content
     option 'xmlerror = message') from xmlxfsTab
filename
-------------------
picture.jpg
<xml_parse_error>An exception occurred! 
Type:TranscodingException, 
Message:An invalid multi-byte source text sequence was
encountered</xml_parse_error>

bookstore.1.xml
<title>Seven Years in Trenton</title>

bookstore.2.xml
<title>Modern Database Management</title>
nonxmldoc.txt
<xml_parse_error>Invalid document structure</xml_parse_error>

(4 rows affected)




Copyright © 2005. Sybase Inc. All rights reserved. Example: parsing XML and non-XML documents with the 'xmlerror=message' option

View this book as PDF