xsl के अंदर काउंटर कैसे प्राप्त करें: प्रत्येक लूप जो संसाधित वर्तमान तत्व की संख्या को प्रतिबिंबित करेगा।एक्सएसएल के अंदर काउंटर: प्रत्येक लूप के लिए काउंटर
<books>
<book>
<title>The Unbearable Lightness of Being </title>
</book>
<book>
<title>Narcissus and Goldmund</title>
</book>
<book>
<title>Choke</title>
</book>
</books>
उदाहरण के लिए मेरे स्रोत एक्सएमएल है क्या मैं प्राप्त करना चाहते है:
<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 संशोधित करने के लिए:
<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>
तो सवाल यह क्या जगह में डाल करने के लिए है का ???। क्या कोई मानक कीवर्ड है या क्या मुझे बस एक चर घोषित करना होगा और इसे लूप के अंदर बढ़ा देना चाहिए?
सवाल यह है कि के रूप में बहुत लंबा मैं शायद एक पंक्ति या एक शब्द जवाब :)
विशेषता मान –
करने के लिए एक बंद करने वाला उद्धरण "जोड़ने की आवश्यकता है जब तक आप XSL की तरह एक फिल्टर जोड़ने के लिए यह सब ठीक है और बांका: यदि आपके XSL के अंदर:। के लिए-प्रत्येक तब स्थिति() बेकार है और आपको उचित काउंटर की आवश्यकता है। –
@ माइक स्टावरोव यह सवाल का हिस्सा नहीं था! – redsquare