Solved

How to create an increment variable in XSLT

Posted on 2010-09-23
5
1,003 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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