DBXML函数学习-----XMLSERIALIZE()

1)函数的作用:
    You use SQL/XML standard function XMLSerialize to obtain a string or LOB
representation of XML data.

2)函数语法结构:
    看图:

   
   
    语法说明:
        value_expr:Argument value_expr is evaluated, and the resulting XMLType instance is serialized
to produce the content of the created string or LOB. If present 1 , the specified
datatype must be one of the following (the default data type is CLOB):
            VARCHAR2(N), where N is the size in bytes (limit 4000)
            CLOB
            BLOB
           
        DOCUMENT OR CONTENT: If you specify DOCUMENT, then the result of evaluating value_expr must be a
well-formed document. In particular, it must have a single root. If the result is not a
well-formed document, then an error is raised. If you specify CONTENT, however, then
the result of value_expr is not checked for being well-formed.
        ENCODING: The ENCODING clause specifies the character encoding for XML data that is serialized
as a BLOB instance. xml_encoding_spec is an XML encoding declaration
(encoding="..."). If datatype is BLOB and you specify an ENCODING clause, then
the output is encoded as specified, and xml_encoding_spec is added to the prolog
to indicate the BLOB encoding. If you specify an ENCODING clause with a datatype
other than BLOB, then an error is raised.
        HIDE DEFAULTS and SHOW DEFAULTS: HIDE DEFAULTS and SHOW DEFAULTS apply only to XML schema-based data. If you
specify SHOW DEFAULTS and the input data is missing any optional elements or
attributes for which the XML schema defines default values, then those elements or
attributes are included in the output with their default values. If you specify HIDE
DEFAULTS, then no such elements or attributes are included in the output. HIDE
DEFAULTS is the default behavior.

3) 例子:
    a) SELECT XMLSerialize(DOCUMENT XMLType('<poid>143598</poid>') AS CLOB)
  AS xmlserialize_doc FROM DUAL;
 
  b) select xmlserialize(DOCUMENT xmltype('<?xml version="1.0" encoding="ISO-8859-15"?><rss version="2.0"><channel><title>Test</title></channel></rss>')) from dual;
 
  c) SQL>   select XMLSerialize
                  2         (
                  3           CONTENT
                  4           XMLElement
                  5           (
                  6             "XMLDetails",
                  7             XMLElement("Source",'ORACLE'),
                  8             XMLElement("Destination",'WEBSERVICE'),
                  9             XMLElement
                 10             (
                 11               "OrderRef",
                 12               XMLElement
                 13               (
                 14                 "OrderNo",
                 15                 XMLAttributes('1234' as "Id"),
                 16                 'xyz'
                 17               ),
                 18               XMLElement("OrderDate",'7169')
                 19             ),
                 20             XMLElement("MessageType",'Success')
                 21           )
                 22           as CLOB indent size = 2
                 23         )
                 24    from dual
                 25  /


4) 参考资料列表:
    a) PDF:Oracle XML DB Developer's Guide 11g R2
    b) http://download.oracle.com/javadb/10.5.3.0/ref/rreffuncxmlserialize.html
    c) http://www.oradev.com/xml_functions.jsp
    d) http://forums.oracle.com/forums/thread.jspa?threadID=775817
    e) http://forums.oracle.com/forums/thread.jspa?messageID=2303661&#2303661
    f) http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0511melnyk/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值