0
我有一個傳入的XMl,我想要替換某個屬性的值,如果它有一個特定的值。 「算法」被「轉換」,這是在XML很多這樣的節點屬性的父元素替換XML中的屬性值
傳入XML:
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#pfx41d8ef22-e612-8c50-9960-1b16f15741b3">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>yJN6cXUwQxTmMEsPesBP2NkqYFI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pNewType" select="'myNewType'"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Transform/@Algorithm[.='http://www.w3.org/TR/2001/REC-xml-c14n-20010315']">
<xsl:attribute name="Algorithm">
<xsl:value-of select="'http://www.w3.org/2001/10/xml-exc-c14n#'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
能否請你讓我知道什麼是這個XSL的問題。
[在XSLT中使用名稱空間前綴匹配元素]可能的重複(https://stackoverflow.com/questions/5100724/matching-elements-with-namespace-prefix-in-xslt) – Filburt
您能否讓我知道。我們如何解決這個問題。 – user5458829
你*看過*鏈接的帖子和答案嗎? – Filburt