XSLT/XPath:Treat<;标签>;作为普通字符串,而不是节点
我有一个XML:XSLT/XPath:Treat<;标签>;作为普通字符串,而不是节点,xslt,xpath,Xslt,Xpath,我有一个XML: <foo> <bar>some text</bar> </foo> 。但是有什么我能做的吗 <bar>some text</bar> 一些文本 ??因此,将其视为条形标记只是普通字符串。您可以使用Copy HTML <foo> <bar>some text</bar> </foo> <xsl:stylesheet version=
<foo>
<bar>some text</bar>
</foo>
。但是有什么我能做的吗
<bar>some text</bar>
一些文本
??因此,将其视为条形标记只是普通字符串。您可以使用
Copy
HTML
<foo>
<bar>some text</bar>
</foo>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="bar">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
一些文本
XSL
<foo>
<bar>some text</bar>
</foo>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="bar">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
输出
<bar>some text</bar>
一些文本
您可以使用复制
HTML
<foo>
<bar>some text</bar>
</foo>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="bar">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
一些文本
XSL
<foo>
<bar>some text</bar>
</foo>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="bar">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
输出
<bar>some text</bar>
一些文本
当然,没有办法将
视为字符串,因为XSLT看到XML解析器的输出,它是一个节点树:当XSLT开始工作时,标记早已消失
但是您当然可以将元素节点作为一个整体复制,而不仅仅是提取其字符串值。简单地用
代替好吧,当然没有办法把
当作字符串,因为XSLT看到XML解析器的输出,它是一个节点树:当XSLT开始工作时,标签早已消失了
但是您当然可以将元素节点作为一个整体复制,而不仅仅是提取其字符串值。只需使用
代替
可能重复的