Need XSL list of XML links

Discussion in 'XML' started by Donald Firesmith, Jan 15, 2005.

  1. How do I use XSL to generate and XHTML list of hyperlinks stored in XML?

    My XML contains links of examples of the form:

    <examples>
    <example>
    <link url="aURL">some text</link>
    <info>some more text</info>
    </example>
    <example>
    <link url="aURL">some text</link>
    <info>some more text</info>
    </example>
    </examples>

    My XSL looks like this:

    <ul>
    <xsl:for-each select="examples/example">
    <li><a href="<xsl:value-of select="@url"/>">
    <xsl:value-of select="." disable-output-escaping="yes"/>
    <xsl:value-of select="info"/>
    </a></li>
    </xsl:for-each>
    </ul>

    I can't seem to get this to work. The url parameter won't fit in the
    link. Can anyone show me the proper XSL code for this? Also what
    should the XSL code look like if info is optional?

    Thanks.

    Don
    Donald Firesmith, Jan 15, 2005
    #1
    1. Advertising

  2. Donald Firesmith

    Joris Gillis Guest

    Joris Gillis, Jan 15, 2005
    #2
    1. Advertising

  3. Joris Gillis wrote:
    >> <li><a href="<xsl:value-of select="@url"/>">

    >
    > Make that <li<a href="{@url}">
    >
    >
    > regards,

    Joris
    Thanks. That works.
    Don
    Donald Firesmith, Jan 15, 2005
    #3
  4. Donald Firesmith

    anonymous Guest

    Donald Firesmith wrote:
    > How do I use XSL to generate and XHTML list of hyperlinks stored in XML?
    >
    > My XML contains links of examples of the form:
    >
    > <examples>
    > <example>
    > <link url="aURL">some text</link>
    > <info>some more text</info>
    > </example>
    > <example>
    > <link url="aURL">some text</link>
    > <info>some more text</info>
    > </example>
    > </examples>
    >
    > My XSL looks like this:
    >
    > <ul>
    > <xsl:for-each select="examples/example">
    > <li><a href="<xsl:value-of select="@url"/>">
    > <xsl:value-of select="." disable-output-escaping="yes"/>
    > <xsl:value-of select="info"/>
    > </a></li>
    > </xsl:for-each>
    > </ul>
    >
    > I can't seem to get this to work. The url parameter won't fit in the
    > link. Can anyone show me the proper XSL code for this? Also what
    > should the XSL code look like if info is optional?
    >
    > Thanks.
    >
    > Don
    >


    Look into a construct like this:

    <a>
    <xsl:attribute name="href">
    <xsl:value-of select =....../>
    </xsl:attribute>
    Link text goes here
    </a>

    Where your @url stuff goes in the value-of section of the attribute.
    anonymous, Jan 16, 2005
    #4
    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. www.westerncartooncards.ca

    Exchange Links < Western Cartoon Cards > Exchange Links

    www.westerncartooncards.ca, Jul 12, 2004, in forum: HTML
    Replies:
    2
    Views:
    1,227
    Toby Inkster
    Jul 12, 2004
  2. schilde
    Replies:
    1
    Views:
    397
    Martin Honnen
    Feb 13, 2004
  3. Replies:
    1
    Views:
    3,595
    A. Bolmarcich
    May 27, 2005
  4. Replies:
    5
    Views:
    434
    reclusive monkey
    Jul 5, 2005
  5. Garrett Smith
    Replies:
    14
    Views:
    305
    David Mark
    May 26, 2009
Loading...

Share This Page