# 22. Virtuoso Functions Guide - xml_doc_output_option

Chapter Contents | Prev | Next
Keyword Search:
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
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 Server & 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_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_doc_output_option

varchar xml_doc_output_option (in xml_entity any, in option_name varchar, [in option_value varchar]);
Description

This function reads or updates the specified XSLT output option value of the given xml_entity.

The function updates the option if parameter option_value is provided, otherwise it returns the current value of the option without any side effects.

Supported options are 'method', 'version', 'encoding', 'omit-xml-declaration', 'standalone', 'doctype-public', 'doctype-system', 'indent' and 'media-type', but do not support'cdata-section-elements'. When the entity is serialized, the effect is very similar to the effect of the same option specified in xsl:output element of an XSLT that created the entity.

Note that output options are properties of the whole document, not properties of some particular node in the document, so the effect of the update is document-wide. Please also note that the effect of 'preamble' options 'omit-xml-declaration', 'standalone', 'doctype-public' and 'doctype-system' is visible only when the root entity of the document is serialized, not any descendant entity. Even the serialization of top-level element of the document is not affected by these settings. The XML preamble is serialized only if the document is composed by an XSLT processor or 'doctype-system' is set or at least one of two boolean properties 'omit-xml-declaration' and 'standalone' is set to 'yes'.

According to the DTD rules, 'doctype-public' has no effect on serialization if 'doctype-system' is not set.

Parameters
xml_entity – An XML entity such as that returned by the xslt() function.
option_name – A name of output option to in question.
option_value – A new value of output option. This is a string or NULL (that reset option to default). Allowed values of boolean properties 'omit-xml-declaration' and 'standalone' are 'yes' and 'no', as it is in XSLT 1.0.
Return Types

The function returns a string that is a value of the option or NULL if the option is not set.

Errors

This function can generate the following errors:

22023 SR003 Function xml_doc_output_option needs an XML entity as argument 1, not an arg of type <type_name> (<type>)

Examples
Assessing the SYSTEM DTD location

    create function test_output_option (
      in cnt any, in opt_name any, in opt_value any)
    {
      declare xt, ses any;
      declare oldval, newval varchar;
      xt := xtree_doc (cnt, 2, '', 'UTF-8');
      oldval := xml_doc_output_option (xt, opt_name);
      xml_doc_output_option (xt, opt_name, opt_value);
      newval := xml_doc_output_option (xt, opt_name);
      return concat (
        sprintf ('Old value of "%s" is "%s"\nNew value is "%s"\nThe result:\n',
           opt_name,
           cast (oldval as varchar),
           cast (newval as varchar) ),
        serialize_to_UTF8_xml (xt) );
    }

    select test_output_option (
      '<div xmlns="http://www.w3.org/1999/xhtml">Hello</div>',
      'doctype-system', 'http://www.example.com/xhtml.dtd')
    callret
    VARCHAR
    _______________________________________________________________________________

    Old value of "doctype-system" is "(NULL)"
    New value is "http://www.example.com/xhtml.dtd"
    The result:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE http://www.w3.org/1999/xhtml:div
      SYSTEM "http://www.example.com/xhtml.dtd">
    <n0:div xmlns:n0="http://www.w3.org/1999/xhtml">Hello</n0:div>

    1 Rows. -- 1 msec.

See Also

xtree_doc()