xslt: create link from name

Discussion in 'XML' started by Felix Natter, Jul 29, 2003.

  1. Felix Natter

    Felix Natter Guest

    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,

    --
    Felix Natter
    Felix Natter, Jul 29, 2003
    #1
    1. Advertising

  2. Felix Natter

    Michael Hill Guest

    Re: create link from name

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

    Mike

    "Felix Natter" <> wrote in message
    news:...
    > 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,
    >
    > --
    > Felix Natter
    Michael Hill, Jul 30, 2003
    #2
    1. Advertising

  3. Felix Natter

    Felix Natter Guest

    Re: create link from name

    "Michael Hill" <> writes:

    > 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,

    > "Felix Natter" <> wrote in message
    > news:...
    > > 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,
    > >
    > > --
    > > Felix Natter

    >
    >


    --
    Felix Natter
    Felix Natter, Jul 30, 2003
    #3
  4. Felix Natter

    FC Guest

    Re: create link from name

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

    Bye,
    Flavio
    FC, Jul 30, 2003
    #4
  5. Felix Natter

    Felix Natter Guest

    Re: create link from name

    "FC" <> writes:

    > 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."

    --
    Felix Natter
    Felix Natter, Jul 30, 2003
    #5
  6. Felix Natter

    Felix Natter Guest

    Re: create link from name

    Felix Natter <> writes:

    > "Michael Hill" <> writes:
    >
    > > 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).


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

    --
    Felix Natter
    Felix Natter, Jul 30, 2003
    #6
  7. Felix Natter

    Felix Natter Guest

    Re: create link from name

    Felix Natter <> writes:

    > Felix Natter <> writes:
    >
    > > "Michael Hill" <> writes:
    > >
    > > > 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).

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


    Is there a better solution? It's a bit tedious to use
    i.e. #Formular%20zur%C3%BCcksetzen as a link.

    thanks,

    --
    Felix Natter
    Felix Natter, Jul 30, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    798
    Kevin Spencer
    May 17, 2005
  2. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    809
    Roedy Green
    Jan 2, 2006
  3. Moonbeam66
    Replies:
    2
    Views:
    423
    Moonbeam66
    Jun 7, 2005
  4. Bodi
    Replies:
    1
    Views:
    272
    Lasse Reichstein Nielsen
    Nov 18, 2003
  5. pavi
    Replies:
    0
    Views:
    1,323
Loading...

Share This Page