xml - how to show only two items in xslt? -


could yu please tell me how show first 2 element xslt ? here code http://xsltransform.net/ehvyzmp/6

<?xml version="1.0" encoding="utf-8" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0" xmlns:exsl="http://exslt.org/common"  extension-element-prefixes="exsl">     <xsl:output method="html" doctype-public="xslt-compat" omit-xml-declaration="yes" encoding="utf-8" indent="yes" />      <xsl:template match="a">        <hmtl>         <head>           <title>new version!</title>         </head>           <xsl:apply-templates select="t"/>       </hmtl>     </xsl:template>  <xsl:template match="t[@live='2']"> <xsl:value-of select="@b"/>  </xsl:template> </xsl:transform> 

expected output : 12

if want select first 2 t elements have live attribute set "2", put logic in xsl:apply-templates rather template match

<xsl:apply-templates select="t[@live='2'][position() &lt; = 2]"/> 

try xslt

<xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0" xmlns:exsl="http://exslt.org/common"  extension-element-prefixes="exsl">     <xsl:output method="html" doctype-public="xslt-compat" omit-xml-declaration="yes" encoding="utf-8" indent="yes" />      <xsl:template match="a">        <hmtl>         <head>           <title>new version!</title>         </head>           <xsl:apply-templates select="t[@live='2'][position() &lt; = 2]"/>       </hmtl>     </xsl:template>  <xsl:template match="t"> <xsl:value-of select="@b"/>  </xsl:template> </xsl:transform> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -