0

我们正在尝试获取 ns2:Token 数据。下面的 SQL 不起作用。

SELECT xml.* FROM xxce_test xx,
                       XMLTable(XMLNamespaces(DEFAULT 'http://www.xcec.com/AgileCard/xsd/12'),'/soapenv:Envelope/soapenv:Body/ns3:CardRefTokenAddRs/ns2:TokenizedData/'
                            passing xx.xml_data
                                columns
                                    merchantId VARCHAR2(125)  PATH 'ns2:Token'
                                    ) xml

xxce_test 表数据(2列):

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns3:CardRefTokenAddRs xmlns="http://www.xcec.com/AgileCard/xsd/12" xmlns:ns2="http://www.xcec.com/AgileCard/xsd/12" xmlns:ns3="http://www.xcec.com/AgileCard/wsdl/TokenizeCardsSvc-v1.0">
        <Status>
            <StatusCode>0</StatusCode>
            <Severity>INFO</Severity>
            <StatusDesc>Success</StatusDesc>
        </Status>

        <RqUID>unique id</RqUID>
        <ResponseContext>
            <Language>EN-US</Language>
            <ServerDt>2013-04-01T12:04:12.523-04:00</ServerDt>
        </ResponseContext>
        <ns2:TokenizedData>
            <ns2:TokenCorrelationId>1</ns2:TokenCorrelationId>
            <ns2:Token>1234567890</ns2:Token>
            <ns2:LuhnValidated>NotValidated</ns2:LuhnValidated>
            </ns2:TokenizedData>
        </ns3:CardRefTokenAddRs>
    </soapenv:Body>
</soapenv:Envelope>

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns3:CardRefTokenAddRs xmlns="http://www.xcec.com/AgileCard/xsd/12" xmlns:ns2="http://www.xcec.com/AgileCard/xsd/12" xmlns:ns3="http://www.xcec.com/AgileCard/wsdl/TokenizeCardsSvc-v1.0">
            <Status>
                <StatusCode>0</StatusCode>
                <Severity>INFO</Severity>
                <StatusDesc>Success</StatusDesc>
                </Status>
            <RqUID>unique id</RqUID>
            <ResponseContext>
                <Language>EN-US</Language>
                <ServerDt>2013-04-01T12:03:22.307-04:00</ServerDt>
            </ResponseContext>
            <ns2:TokenizedData>
                <ns2:TokenCorrelationId>1</ns2:TokenCorrelationId>
                <ns2:Token>0987654321</ns2:Token>
                <ns2:LuhnValidated>NotValidated</ns2:LuhnValidated>
            </ns2:TokenizedData>
        </ns3:CardRefTokenAddRs>
    </soapenv:Body>
</soapenv:Envelope>
4

1 回答 1

1

你的 XPath 是错误的,你还没有声明所有的命名空间。

select /*+ cursor_sharing_exact */
 xml.*
  from xxce_test xx,
       xmltable(
         xmlnamespaces(default 'http://www.xcec.com/AgileCard/xsd/12',
                       'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
                       'http://www.xcec.com/AgileCard/xsd/12' as "ns2",
                       'http://www.xcec.com/AgileCard/wsdl/TokenizeCardsSvc-v1.0' as "ns3"),
                '/soapenv:Envelope/soapenv:Body/ns3:CardRefTokenAddRs/ns2:TokenizedData'
                passing xx.xml_data 
                columns 
                  merchantid varchar2(125) path 'ns2:Token') xml

小提琴示例:http ://sqlfiddle.com/#!4/b512f/1

于 2013-04-03T09:02:36.723 回答