Xslt XSL:查找当前不在元素中的文本并换行?
给定以下片段:Xslt XSL:查找当前不在元素中的文本并换行?,xslt,xpath,xslt-1.0,Xslt,Xpath,Xslt 1.0,给定以下片段: <recipe> get a bowl <ingredient>flour</ingredient> <ingredient>milk</ingredient> mix it all together! </recipe> 您可以定义一个与文本节点匹配的模板,该节点是配方的直接子节点: <xsl:template match="recipe/text()"> <acti
<recipe>
get a bowl
<ingredient>flour</ingredient>
<ingredient>milk</ingredient>
mix it all together!
</recipe>
您可以定义一个与文本节点匹配的模板,该节点是
配方的直接子节点
:
<xsl:template match="recipe/text()">
<action><xsl:value-of select="normalize-space()" /></action>
</xsl:template>
那么结果会是这样的
<recipe>
<action>
get a bowl
</action>
<ingredient>flour</ingredient>
<ingredient>milk</ingredient>
<action>
mix it all together!
</action>
</recipe>
拿碗
面粉
牛奶
混合在一起!
您可以定义一个模板,该模板匹配作为配方的直接子级的文本节点:
<xsl:template match="recipe/text()">
<action><xsl:value-of select="normalize-space()" /></action>
</xsl:template>
那么结果会是这样的
<recipe>
<action>
get a bowl
</action>
<ingredient>flour</ingredient>
<ingredient>milk</ingredient>
<action>
mix it all together!
</action>
</recipe>
拿碗
面粉
牛奶
混合在一起!
<recipe>
<action>
get a bowl
</action>
<ingredient>flour</ingredient>
<ingredient>milk</ingredient>
<action>
mix it all together!
</action>
</recipe>