Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create an increment variable in XSLT

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 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