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
使用xslt 1显示X个节点数_Xslt_Xslt 1.0 - Fatal编程技术网

使用xslt 1显示X个节点数

使用xslt 1显示X个节点数,xslt,xslt-1.0,Xslt,Xslt 1.0,我有一些xml看起来有点像这样: <myGroup> <something>Stuff</something> <anotherThing>More Stuff</anotherThing> <thisThing></thisThing> <andAnother>Good stuff</andAnother> <howAboutThis></

我有一些xml看起来有点像这样:

<myGroup>
   <something>Stuff</something>
   <anotherThing>More Stuff</anotherThing>
   <thisThing></thisThing>
   <andAnother>Good stuff</andAnother>
   <howAboutThis></howAboutThis>
   <andOneMore>Tell me the good things</andOneMore>
   <lastOne>That come into your mind about your mother</lastOne
<myGroup>

东西
更多的东西
好东西
告诉我好事

你脑海中浮现的关于你母亲的情况将这种情况置于一个谓词中:

<xsl:template match="myGroup">
  <xsl:apply-templates select="(something | anotherthing | howAboutThis | lastOne)[normalize-space()][position() &lt; 4]"/>
</xsl:template>

<xsl:template match="myGroup/*">
  <xsl:value-of select="."/>
</xsl:template>

不错。谢谢你的帮助。
<xsl:template match="myGroup">
  <xsl:apply-templates select="(something | anotherthing | howAboutThis | lastOne)[normalize-space()][position() &lt; 4]"/>
</xsl:template>

<xsl:template match="myGroup/*">
  <xsl:value-of select="."/>
</xsl:template>