Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create an increment variable in XSLT

Posted on 2010-09-23
5
Medium Priority
?
1,032 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

772 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