我想要print属性,并给它加上一些值。
输入:
<figure id="fig_1">
<dis>text</dis>
</figure>我的输出:
<image ref="fig_1"
comment="text the
 "/>尝试过的代码:
<xsl:template match="dis[parent::figure]">
<xsl:variable name="fig_name" select="parent::fig/@id"/>
<image ref="{$fig_name}">
<xsl:attribute name="comment">
<xsl:value-of select="text()"/>
</xsl:attribute>
</tps:image>
</xsl:template>我想删除所有的
。我该怎么做呢。
发布于 2019-06-20 15:14:32
使用normalize space ()函数删除不必要的空格。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="long-desc[parent::fig]">
<xsl:variable name="fig_name" select="parent::fig/@id"/>
<image ref="{$fig_name}">
<xsl:attribute name="comment">
<xsl:value-of select="normalize-space(text())"/>
</xsl:attribute>
</image>
</xsl:template>
</xsl:stylesheet>https://stackoverflow.com/questions/56680653
复制相似问题