xslt: create link from name

F

Felix Natter

hi,

I have glossary-entries (<entry name="...">...</entry>) whose names
include 8bit-characters and spaces and each entry must be reachable by
(relative) html-links.

I want to avoid having to specify both a name and an id for linking
for each glossary term (if possible), so I'd like to generate links
(urls) from the names with some kind of algorithm.

I need (at least) a function that creates a valid url from a name
(i.e. "x y" => "x%20y").

thanks,
 
M

Michael Hill

I think you may be looking for <xsl:element> and/or <xsl:attribute> . look
at them.

Mike
 
F

Felix Natter

Michael Hill said:
I think you may be looking for <xsl:element> and/or <xsl:attribute> . look
at them.

No, I'm looking for a function/algorithm/idea to convert i.e.
"this Topic" to "this%20topic" or similar. Without this function
I'd have to do this:

<entry name="Formular zurücksetzen" id="formularzuruecksetzen">
</entry>
<entry name="Faktura" id="faktura">
</entry>
...
and have some redundancy (@id) which is what I try to avoid. A
function like "url(@name)" (which would "urlify" @name, " "=>%20 etc.)
would be sufficient (if there's no better solution).

thanks in advance,
 
F

FC

I suppose that's the purpose of generate-id() function.
Have a look at it and see if it suits your needs.

Bye,
Flavio
 
F

Felix Natter

FC said:
I suppose that's the purpose of generate-id() function.
Have a look at it and see if it suits your needs.

It won't work because it is not required that the ids
stay the same across stylesheet invocations (and for a glossary
the name-anchors need to stay the same)

From XSLT by Doug Tidwell:
"[...] All of tomorrow's calls to generate-id() will generate the same ID
but that ID might not be the one generated today."
 
F

Felix Natter

Felix Natter said:
No, I'm looking for a function/algorithm/idea to convert i.e.
"this Topic" to "this%20topic" or similar. Without this function
I'd have to do this:

<entry name="Formular zurücksetzen" id="formularzuruecksetzen">
</entry>
<entry name="Faktura" id="faktura">
</entry>
...
and have some redundancy (@id) which is what I try to avoid. A
function like "url(@name)" (which would "urlify" @name, " "=>%20 etc.)
would be sufficient (if there's no better solution).

I found an extension which does this: encode-uri
(http://www.exslt.org/str/)
 

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

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top