Example: storing parsed XML documents in the file system  Example: specifying the 'xmlerror=message’ option in xmlextract

Appendix C: XML Services and External File System Access

Example: 'xmlerror' option capabilities with External File Access

An external (O/S) file system may contain a variety of data formats, and may contain both valid and invalid XML documents. You can use the xmlerror option of the xmlextract and xmltest functions to specify error actions for documents that are not valid XML.For example, a File Access directory structure may contain picture.jpg and nonxmldoc.txt files along with bookstore1.xml and bookstore.2.xml files:

select filename from xmlxfsTab
filename
-----------------------------------------
picture.jpg 
bookstore.1.xml 
bookstore.2.xml
nonxmldoc.txt

(4 rows affected)

The following code sample shows an XML query on both XML and non-XML data:

select filename , xmlextract("//book/title",content)
from xmlxfsTab
--------------
Msg 14702, Level 16, State 0:
Line 1:
XMLEXTRACT(): XML parser fatal error <<An exception occurred!
Type:TranscodingException,
Message:An invalid multi-byte source text sequence was
encountered>> at line 1, offset 1.




Copyright © 2005. Sybase Inc. All rights reserved. Example: specifying the 'xmlerror=message’ option in xmlextract

View this book as PDF