Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSLT/XPath:Treat<;标签>;作为普通字符串,而不是节点_Xslt_Xpath - Fatal编程技术网

XSLT/XPath:Treat<;标签>;作为普通字符串,而不是节点

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=

我有一个XML:

<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开始工作时,标签早已消失了

但是您当然可以将元素节点作为一个整体复制,而不仅仅是提取其字符串值。只需使用
代替

可能重复的