Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/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 需要有关xsl转换的帮助-不需要的文本_Xslt - Fatal编程技术网

Xslt 需要有关xsl转换的帮助-不需要的文本

Xslt 需要有关xsl转换的帮助-不需要的文本,xslt,Xslt,我试图只匹配次要内容xml标记。但是它正在输出文本“/Main-cotnent在这里。”为什么它要从报头和Main-content标签输出文本 xmL: 这是一个常见问题。这是因为XSLT隐式地驱动了各种节点的处理 使用以下模板替代文本节点的内置模板: <xsl:template match="text()"/> 这种行为的一个原因是您的第一个模板匹配行 <xsl:template match="/system-data-structure"> 这是因为在第一个模板中

我试图只匹配次要内容xml标记。但是它正在输出文本“/Main-cotnent在这里。”为什么它要从报头和Main-content标签输出文本

xmL:


这是一个常见问题。这是因为XSLT隐式地驱动了各种节点的处理

使用以下模板替代文本节点的内置模板:

<xsl:template match="text()"/>

这种行为的一个原因是您的第一个模板匹配行

<xsl:template match="/system-data-structure">

这是因为在第一个模板中,您试图在根级别匹配
系统数据结构。但是,在xml示例中,
xml
是根级别。将匹配更改为
/xml/system data structure

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="utf-8"/>

  <xsl:template match="/xml/system-data-structure">  
    <xsl:apply-templates select="secondary-content" />
  </xsl:template>


  <xsl:template match="secondary-content">
    Found a learner!
  </xsl:template>

</xsl:stylesheet>

找到一个学习者!

内置模板正在那里工作,但使用您的建议无法解决问题。请参阅其他答案。
<xsl:template match="text()"/>
<xsl:template match="/system-data-structure">
<xsl:template match="/xml/system-data-structure">
Found a learner!  Found a learner! 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="utf-8"/>

  <xsl:template match="/xml/system-data-structure">  
    <xsl:apply-templates select="secondary-content" />
  </xsl:template>


  <xsl:template match="secondary-content">
    Found a learner!
  </xsl:template>

</xsl:stylesheet>