unique id

C

Cozmo

Hello all,

I try to add to an already existing xml document with arround 10000
items an unique id.

I tried already the example below from w3schools but it dosent fit my
requirements. I want an countable number. e.g. 0000001, afterwards
0000002 etc.
do you have an idea how to realize that? Thanks for your help.

Cozmo


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<html>
<body>
<h3>Artists:</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="#{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artist: <a name="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Title: <xsl:value-of select="title" />
<br />
Price: <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template></xsl:stylesheet>
 
C

Cozmo

Hello all,

I try to add to an already existing xml document with arround 10000
items an unique id.

I tried already the example below from w3schools but it dosent fit my
requirements. I want an countable number. e.g. 0000001, afterwards
0000002 etc.
do you have an idea how to realize that? Thanks for your help.

Cozmo

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
match="/">
<html>
<body>
<h3>Artists:</h3>
<ul>
<xsl:for-each select="catalog/cd">
<li>
<a href="#{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
</li>
</xsl:for-each>
</ul>
<hr />
<xsl:for-each select="catalog/cd">
Artist: <a name="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Title: <xsl:value-of select="title" />
<br />
Price: <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template></xsl:stylesheet>




Sorry. Previously was an inccorect copy and paste. I meant this
example:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput method="xml" omit-xml-declaration="yes"/>

<xsl:template match="chapter | sect1 | sect2">
<xsl:copy>
<xsl:attribute name="uid">
<xsl:value-of select="generate-id(.)"/>
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
 
M

Martin Honnen

Cozmo said:
I try to add to an already existing xml document with arround 10000
items an unique id.

I tried already the example below from w3schools but it dosent fit my
requirements. I want an countable number. e.g. 0000001, afterwards
0000002 etc.
do you have an idea how to realize that? Thanks for your help.

Look into xsl:number: http://www.w3.org/TR/xslt#number

If you need more help then please share the structure of your XML and
describe exactly which elements you want to number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top