XSLT 更改格式为 <ns:foo> 的标记值

XSLT change value of tag with format <ns:foo>

我有以下标签和 ist 值:

<dc:source xmlns:dc="http://purl.org/dc/elements/1.1/"> CH-BAR#E53#1000/893#382#1</dc:source>

我想用这个改变它的值(CH-BAR ...):

<xsl:template match="dc:source/text()">
    <xsl:value-of select="$DocNumber"/>
  </xsl:template>

但是 xslt 抛出一个错误,因为 ":" ...

我可以在这里做什么?

干杯

您不能在不绑定到命名空间的情况下使用命名空间前缀 - 例如:

<xsl:template match="dc:source/text()" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <xsl:value-of select="..."/>
</xsl:template>

通常,您会在 xsl:stylesheet 根元素中声明所有必需的命名空间,从而使其对其所有后代可用。