我正在尝试对节点businessEntity进行数字签名。我在转换中使用Xpath来引用此节点。
我的Xpath表达式是:
ancestor-or-self::ns1:businessEntity[
@businessKey = 'uddi:testSignedProviderlastime'
] and not(ancestor-or-self::ns1:businessService)
and not(ancestor-or-self::ds:Signature)
我想删除名称空间前缀ns1的依赖项。有没有办法可以做到这一点?或者有没有办法在表达式中指定名称空间URI。
我已经尝试用替换名称空间前缀ns1,但是使用“”前缀时出错了。 任何有关修改此表达式的帮助都表示赞赏。
谢谢, 索尼娅
以下是xml,我也应用了这个转换:
<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>
答案 0 :(得分:4)
我想你想要这个:
ancestor-or-self::*[local-name() = 'businessEntity']
或更精确:
ancestor-or-self::*
[local-name() = 'businessEntity' and namespace-uri() = 'urn:uddi-org:api_v3']