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

  • Edgar flores

    Edgar flores

    7 HAZİRAN 2006
  • GFX Tutorials

    GFX Tutorial

    12 AĞUSTOS 2013
  • STITCHLESS TV how to sew your own style tutorials

    STITCHLESS T

    9 HAZİRAN 2011