【发布时间】:2019-03-22 04:21:03
【问题描述】:
我尝试使用 xades4j 库对 UBL2.1 Invoice 进行数字签名。
UBL定义xpath转换为:
count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)
并引用 Tranform ALgorithm XPath 1.0: http://www.w3.org/TR/1999/REC-xpath-19991116
当我用 xades4j 定义引用时,它看起来像这样:
DataObjectDesc ref1 = new DataObjectReference("")
.withTransform(new XPathTransform(xpathValue).withNamespace(xpathNamespacePrefix, xpathNamespace))
.withDataObjectFormat(new DataObjectFormatProperty("application/xml", "UTF-8").withDescription("xml dokumenta"));
我得到了 Excetion,在 xpath 中使用的函数 here() 是未知的。 Xpath 1.0 中未定义函数 here()。但在示例 od UBL 签名的 xml 文件中,有:
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
<ds:XPath xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2">
count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)
</ds:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>nLVnpwiT7Va0bsPgf14kso83NS8l+/usrd/a5l5ybeY=</ds:DigestValue>
</ds:Reference>
函数 here() 在 XML-Signature XPath Filter 2.0 中定义:https://www.w3.org/TR/xmldsig-filter2/
我可以使用 xades4j 库通过 using function here() 进行参考变换吗???
最好的问候, 约西普
【问题讨论】: