使用xslt 1显示X个节点数
我有一些xml看起来有点像这样:使用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></
<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() < 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() < 4]"/>
</xsl:template>
<xsl:template match="myGroup/*">
<xsl:value-of select="."/>
</xsl:template>