开发者

How to select a local name in a node test

开发者 https://www.devze.com 2023-02-14 21:53 出处:网络
I am trying to Digitally Sign a node businessEntity.I am using Xpath in my tranform to refer to this node.

I am trying to Digitally Sign a node businessEntity. I am using Xpath in my tranform to refer to this node.

My Xpath expression is :

ancestor-or-self::ns1:businessEntity[
   @businessKey = 'uddi:testSignedProviderlastime'
] and not(ancestor-or-self::ns1:businessService)
  and not(ancestor-or-self::ds:Signature)

I want to remove the dependency for the namespace prefix ns1. Is there a way I can do that? Or is there a way I can specify the namespace URI in my expression.

I have already tried replacing the namespace prefix ns1 with a , but got an error for using "" prefix. Any help in modifying this expression is appreciated.

Thanks, Sonia

Following is the xml, I am applying this transform too:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <ns1:save_business xmlns:ns1="urn:uddi-org:api_v3">
        <ns1:authInfo>something
        </ns1:authInfo>
        <ns1:businessEntity businessKey="uddi:testSignedProviderlastime" xmlns:ns1="urn:uddi-org:api_v3">
            <ns1:name>testSignedProviderlastime</ns1:name>
            <ns1:description>Not Provided</ns1:description>
            <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                开发者_如何学编程<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
                    <ds:Reference URI="" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        <ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
                            <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                                <ds:XPath xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ns1="urn:uddi-org:api_v3">ancestor-or-self::ns1:businessEntity[@businessKey='uddi:testSignedProviderlastime'] and not (ancestor-or-self::ns1:businessService) and not (ancestor-or-self::ds:Signature)</ds:XPath>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
                        <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">something</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                something
                </ds:SignatureValue>
                <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        <ds:X509Certificate xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        something
                        </ds:X509Certificate>
                    </ds:X509Data>
                    <ds:KeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        <ds:RSAKeyValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                            <ds:Modulus xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                            something
                            </ds:Modulus>
                            <ds:Exponent xmlns:ds="http://www.w3.org/2000/09/xmldsig#">AQAB</ds:Exponent>
                        </ds:RSAKeyValue>
                    </ds:KeyValue>
                </ds:KeyInfo>
            </ds:Signature>
        </ns1:businessEntity>
    </ns1:save_business>
</soapenv:Body>


I guess you want this:

ancestor-or-self::*[local-name() = 'businessEntity']

Or a more precise:

ancestor-or-self::*
    [local-name() = 'businessEntity' and namespace-uri() = 'urn:uddi-org:api_v3']
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号