SORU
18 EYLÜL 2008, PERŞEMBE


İçinde sayaç xsl:for-each döngüsü

Nasıl geçerli öğe sayısını yansıtacak xsl:for-each döngüsü işlenmiş. içinde bir sayaç almak için< / ^ br . Örneğin benim kaynak XML

<books>
    <book>
    	<title>The Unbearable Lightness of Being </title>
    </book>
    <book>
    	<title>Narcissus and Goldmund</title>
    </book>
    <book>
    	<title>Choke</title>
    </book>
</books>

Almak istediğim şey:

<newBooks>
    <newBook>
    	<countNo>1</countNo>
    	<title>The Unbearable Lightness of Being </title>
    </newBook>
    <newBook>
    	<countNo>2</countNo>
    	<title>Narcissus and Goldmund</title>
    </newBook>
    <newBook>
    	<countNo>3</countNo>
    	<title>Choke</title>
    </newBook>
</newBooks>

XSLT değiştirmek için:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    	<newBooks>
    		<xsl:for-each select="books/book">
    			<newBook>
    				<countNo>???</countNo>
    				<title>
    					<xsl:value-of select="title"/>
    				</title>
    			</newBook>
    		</xsl:for-each>
    	</newBooks>
    </xsl:template>
</xsl:stylesheet>

Soru yerine koymak nedir ???. Herhangi bir standart anahtar kelime var ya da sadece bir değişken bildirmek ve döngü içinde artırmak zorunda mıyım?

Soru çok uzun olduğu için muhtemelen bir satır veya bir kelime ile cevap:) bekliyorum

CEVAP
18 EYLÜL 2008, PERŞEMBE


position(). E. G.:

<countNo><xsl:value-of select="position()" /></countNo>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • campos9896

    campos9896

    24 Mart 2012
  • kimberly p

    kimberly p

    23 Ocak 2010
  • THE RED DRAGON

    THE RED DRAG

    6 ŞUBAT 2009