0
在转换文档时,我需要在'地图'中查找某些节点内容,然后写入这些值。xslt 1.0根据地图重写节点的值
我在转换中嵌入了我的'映射'。
<xsl:variable name="inlinedmap">
<kat id="stuff">value</kat>
<!-- ... -->
</xsl:variable>
<xsl:variable name="map" select="document('')/xsl:stylesheet/xsl:variable[@name='inlinedmap']" />
<xsl:template match="/">
<xsl:for-each select="/*/foo">
<!-- 'bar' contents should equal to contents of 'kat' -->
<xsl:variable name="g" select="$map/key[.=bar]"/>
<xsl:choose>
<xsl:when test="$g != ''">
<xsl:value-of select="$g/@id"/>
</xsl:when>
<xsl:otherwise>
ERROR
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
我总是收到错误值。 我无法将地图值放入属性中,因为它们包含会被转义的字母。
我该如何让它工作?
试了一下,什么都没有改变 – 2012-01-13 16:49:40
@ŁukaszGruner:这是知识性“看着窗外,它仍在下雨”。您尚未提供源XML文档。你也没有提供完整的转换。更不用说通缉的结果了......如果人们无法复制你的问题,那可能只是你想象中的产物!请编辑并改进您的问题。另外,请多加尊重少数勇敢的人,他们可能会敢于猜测你的意思。 – 2012-01-14 04:11:44
正常工作,主要问题(答案中解释的东西除外)是我的地图编码 – 2012-01-18 11:14:54