Solved

How to create an increment variable in XSLT

Posted on 2010-09-23
5
987 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
ID: 33751487
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
ID: 33751520
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
ID: 33751522
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
ID: 34234309
didn't resolve my problem
0
 
LVL 60

Expert Comment

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

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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