【问题标题】:Getting error extracting xml element from clob column从clob列中提取xml元素时出错
【发布时间】:2016-07-05 01:15:39
【问题描述】:

获取空值我试图获取 xml 元素但无法从项目中提取值以及来自
"<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://edd.att.com/cnmeddservice" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="ns0 xs fn"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <emailRequest xmlns="http://egs.att.com/EGSService"> <xsl:attribute name="project" namespace="" select="'MYWORLD'"/> <xsl:attribute name="region" namespace="" select="'RNSALL'"/> <xsl:attribute name="letterType" namespace="" select="'BBUDO100'"/> <xsl:attribute name="customerType" namespace="" select="'C'"/> <xsl:for-each select="ns0:bbuRequest"> <xsl:attribute name="language" namespace="" select="fn:string(@language)"/> </xsl:for-each> <retryIndicator> <xsl:sequence select="'N'"/> </retryIndicator> <ban> <xsl:sequence select="'9999999999'"/> </ban> <header> <xsl:for-each select="ns0:bbuRequest/ns0:destinations/ns0:emailAddress1"> <to> <xsl:sequence select="fn:string(.)"/> </to> </xsl:for-each> <xsl:for-each select="ns0:bbuRequest/ns0:destinations/ns0:emailAddress2"> <to> <xsl:sequence select="fn:string(.)"/> </to> </xsl:for-each> <from> <xsl:sequence select="'att'"/> </from> </header> <body> <templateData> <xsl:for-each select="ns0:bbuRequest"> <dataField> <xsl:attribute name="name"> <xsl:value-of select="'thresholddate'"/> </xsl:attribute> <xsl:choose> <xsl:when test="string((string-length(string(ns0:thresholdDate)) > 10)) = 'true'"> <xsl:value-of select="substring(string(ns0:thresholdDate), 0, 11)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="string(ns0:thresholdDate)"/> </xsl:otherwise> </xsl:choose> </dataField> </xsl:for-each> </templateData> </body> </emailRequest> </xsl:template> </xsl:stylesheet>"

select  EXTRACT(xmltype(column),
                             '//from') from table
                             where rownum <5


select XMLTYPE(xslt).EXTRACT('//emailRequest/@project','xmlns:xsl="http://www.w3.org/1999/XSL/Transform"').GETSTRINGVAL(),xslt  from edd_egs_config
where rownum <2

上面尝试过,但没有成功

【问题讨论】:

    标签: xml xslt plsql


    【解决方案1】:

    您应该告诉 Oracle 使用的两个命名空间:

    SELECT utl_i18n.unescape_reference(XMLTYPE (xslt).EXTRACT ('//from/xsl:sequence/@select', 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://egs.att.com/EGSService"').GETSTRINGVAL (), xslt
      FROM edd_egs_config
     WHERE ROWNUM < 5
    

    并在第二个中更改路径和命名空间:

    SELECT utl_i18n.unescape_reference(XMLTYPE (xslt).EXTRACT ('//emailRequest/xsl:attribute[@name="project"]/@select',  'xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://egs.att.com/EGSService"').GETSTRINGVAL (), xslt
      FROM edd_egs_config
     WHERE ROWNUM < 2
    

    【讨论】:

    • 感谢您的回复。
    • 项目的价值应该只是 MYWorld 但如果我使用第二个查询然后它给我 w3.org/1999/XSL/Transform" name="project" namespace=" " select="'MYWORLD'"/> 以及 from 的值应该只是 ATT 但查询给出整个字符串
    • @Neha 查询已更改。您在值中有文字。不应该是“ATT”和“MYWORLD”
    • 我已将第一个查询更新为选择 EXTRACT(xmltype(xslt), '//from/xsl:sequence/@select','xmlns:xsl="w3.org/1999/XSL/Transform" xmlns="@ 987654323@) 来自 edd_egs_config 并获得“‘att’”如何获取 att 并摆脱其他所有内容
    • @Neha 查看查询。他们被改变了。
    猜你喜欢
    • 2012-07-16
    • 2019-07-29
    • 1970-01-01
    • 2015-09-08
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多