Solved

How to create an increment variable in XSLT

Posted on 2010-09-23
5
973 Views
Last Modified: 2013-12-14
Hi

Attached please find the XML and XSLT file. In the XSLT file i need to concatenate an increment number such as

<xsl:attribute name = "geonode_id" >@geonode_1<xsl:attribute>

<xsl:attribute name = "geonode_id" >@geonode_2<xsl:attribute

etc.

How can i get increment value. Also currently when i run this XSLT i get the exception
" Cannot have a DOCTYPE decleration outside of a prolog"

Any help will be greatly appreciated

Thanks
storeloc.xsl
store-load.xml
0
Comment
Question by:royalcyber
  • 4
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
for the DTD you need to set a serialisation expressed in the xsl:output element
<xsl:output doctype-system="storeload.dtd"/>



<xsl:template match= "/" >

	<xsl:element name = "import" >

		<xsl:apply-templates/>

	</xsl:element>

</xsl:template>

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
Comment Utility
In XSLT you don't create a "increment variable"
since variable don't vary in XSLT (they are like constants)

You use the properties of the nodes to count nodes
	<xsl:element name = "GEONODE" >

		<xsl:attribute name = "geonode_id" >

			<xsl:text>@geonode_</xsl:text>

			<xsl:value-of select="count(preceding-sibling::GEONODE) + 1"/>

		</xsl:attribute>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
if all you need to do for an element is lowercasing the attribute names, there is a better way, tell me and I will show you
0
 

Author Closing Comment

by:royalcyber
Comment Utility
didn't resolve my problem
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
well, I gave you all teh explanation I could give based on your input.
You could have asked for a clarification
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
video playback resume on webpages 2 60
I starting with php 12 90
CSS HELP 6 73
Cordova Camera plugin fails 2 5
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now