www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Phrases
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web & Internet
XML
xmlagg
xmlattributes
xmladdattribute
xmlappendchildren
xmlconcat
xmlelement
xmlforest
xmlinsertafter
xmlinsertbefore
xmlreplace
xmltype.xmltype
xmltype.createnonsch...
xmltype.createschema...
xmltype.createxml
xmltype.existsnode
xmltype.extract
xmltype.getclobval
xmltype.getnamespace
xmltype.getnumval
xmltype.getrooteleme...
xmltype.getschemaurl
xmltype.getstringval
xmltype.isfragment
xmltype.isschemabase...
xmltype.isschemavali...
xmltype.isschemavali...
xmltype.schemavalida...
xmltype.setschemaval...
xmltype.toobject
xmltype.transform
xmlupdate
xper navigation
createxml
isentity
serialize_to_utf8_xm...
tidy_html
tidy_list_errors
updatexml
xml_add_system_path
xml_auto
xml_auto_dtd
xml_auto_schema
xml_create_tables_fr...
xml_cut
xml_doc_output_optio...
xml_get_system_paths
xml_load_mapping_sch...
xml_load_schema_decl
xml_namespace_scope
xml_persistent
xml_set_ns_decl
xml_template
xml_tree
xml_tree_doc
xml_tree_doc_media_t...
xml_uri_get
xml_validate_dtd
xml_validate_schema
xml_view_dtd
xml_view_schema
xmlsql_update
xpath_eval
xper_cut
xper_doc
xper_locate_words
xpf_extension
xpf_extension_remove
xquery_eval
xslt
xslt_format_number
xslt_sheet
xslt_stale
xte_head
xte_node
xte_node_from_nodebl...
xte_nodebld_acc
xte_nodebld_final
xte_nodebld_init
xtree_doc
XPATH & XQUERY

Functions Index

xml_validate_schema

returns a string with list of errors detected by DTD and XML Schema validator on reading given XML document.
xml_validate_schema (in document varchar, in parser_mode integer, in base_uri varchar, in content_encoding varchar, in content_language varchar, in dtd_validator_config varchar);
Description

This parses the argument, which is expected to be an XML fragment (possibly with syntax errors, violations of validity conditions etc.) and returns a human-readable list of errors as a string. If there is a "schemaLocation" attribute in root element, XML Schema declaration will be loaded and partial schema validation will be performed. If this attribute does not exist and the Validation option below is not set to DISABLED, then an error will be returned: ('FATAL : Schema declaration is not loaded').

The XML Schema validation routines are tightly coupled with DTD validator. If the document contains both Schema and DTD information then both validations are made in the same time in order to provide as accurate diagnostics as possible. However, it is impossible to check whether the declared DTD matches or contradicts to the declared Schema, so the parser performs two independent validations to every item of source data. E.g. if DTD contradicts to the schema in description of some particular element and data in the document does not contain this element then no errors is reported; but if sun an element occurs in the document then either DTD validator or Schema validator will log an error.

Parameters
document – XML or HTML document to check
parser_mode – 0 or 1; 0 - XML parser mode 1 - HTML parser mode
base_uri – in HTML parser mode change all absolute references to relative from given base_uri (http://<host>:<port>/<path>)
content_encoding – string with content encoding type of <document>; valid are 'ASCII', 'ISO', 'UTF8', 'ISO8859-1', 'LATIN-1' etc., defaults are 'UTF-8' for XML mode and 'LATIN-1' for HTML mode
content_language – string with language tag of content of <document>; valid names are listed in IETF RFC 1766, default is 'x-any' (it means 'mix of words from various human languages)
dtd_validator_config – configuration string of the validator, default is empty string meaning that DTD validator should be fully disabled and only critical errors should be reported. It is very probable that this is not the best choice for your application, so please refer Configuration Options of the DTD Validator to find out how to let validator to do better job.
Return Types

Human readable list of errors if applicable as a varchar.

Validating XML Against a DTD
declare _result varchar;  
_result := xml_validate_schema (
  _text, 0, 'http://localhost.localdomain/xmlrepository', 'UTF-8', 'x-any',
  'Validation=SGML FsaBadWs=IGNORE BuildStandalone=ENABLE MaxErrors=100');

if (_res = '') _res := 'NO ERRORS DETECTED';