[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: How to add a variable/changeable hyperlink
Subject: RE: How to add a variable/changeable hyperlink <a href=" http:\\W WW....> around a text in XSL?
From: "Koh, Justin (Intern)" <kohj@xxxxxxxx>
Date: Tue, 16 Mar 1999 10:11:01 -0800
|
I am not proficient with using template. In fact, I am using MSXSL to
convert the xml to html.
Is there an equivalent way to translate
> Filename: <a href="{filename}"><xsl:value-of select="filename"/></a>
>
Is the <xsl:value-f select /> the same as <select-elements> tag?
Does MSXSL recognize templates?
Justin Koh
Software Delivery and Integration Excellence Program (SDIE)
Weyerhaeuser PC2-234
(253) 924-4563
kohj@xxxxxxxx
> ----------
> From: John E. Simpson[SMTP:simpson@xxxxxxxxxxx]
> Reply To: xsl-list@xxxxxxxxxxxxxxxx
> Sent: Monday, March 15, 1999 7:54 PM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: RE: How to add a variable/changeable hyperlink <a href="
> http:\\WWW....> around a text in XSL?
>
> At 02:19 PM 3/15/99 -0800, Koh, Justin (Intern) wrote:
> >Well let's say that the XML document is something like this
> >
> ><profile number="1">
> > <data>.....</data>
> > <filename>datacycle.html</filename>
> ></profile>
> >
> ><profile number="2">
> > <data>.....</data>
> > <filename>dataframe.html</filename>
> ></profile>
>
> I added a <doc> container element, so the XML looks like this:
>
> <doc>
> <profile number="1">
> <data>blahblah1</data>
> <filename>datacycle.html</filename>
> </profile>
> <profile number="2">
> <data>blahblah2</data>
> <filename>dataframe.html</filename>
> </profile>
> </doc>
>
> (You'd replace the <doc>s with whatever your own containing parent element
> might be.)
>
> Then I used this XSL:
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/TR/WD-xsl"
> xmlns="http://www.w3.org/TR/REC-html40"
> result-ns="">
> <xsl:template match="doc">
> <html><body><ul>
> <xsl:for-each select="profile">
> <li>Profile #<xsl:value-of select="@number"/>
> <br/>
> Data: <xsl:value-of select="data"/>
> <br/>
> Filename: <a href="{filename}"><xsl:value-of
> select="filename"/></a>
> </li>
> </xsl:for-each>
> </ul>
> </body></html>
> </xsl:template>
> </xsl:stylesheet>
>
> The operative portion of that is the line beginning "Filename:"; it plugs
> the value of the filename element into both the href attribute AND the
> content of the <a> tag. (Note that the occurrence of filename in the href
> attribute is set off by curly braces, not simple parens.) I ran it through
> XT-win using this command line:
> xt testurl.xml testurl.xsl testurl.html
>
> The HTML generated is:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <body>
> <ul>
> <li>Profile #1<br>
> Data: blahblah1<br>
> Filename: <a href="datacycle.html">datacycle.html</a>
> </li>
> <li>Profile #2<br>
> Data: blahblah2<br>
> Filename: <a href="dataframe.html">dataframe.html</a>
> </li>
> </ul>
> </body>
> </html>
>
> Which displays like this:
>
> o Profile #1
> Data: blahblah1
> Filename: datacycle.html
> o Profile #2
> Data: blahblah2
> Filename: dataframe.html
>
> (substituting lowercase "o" chars for the bullets that actually appear).
> Both "datacycle.html" and "dataframe.html" appear as highlighted
> hyperlinks.
>
> I imagine the same would work with IE5, as long as you include the doctype
> declaration and so on in the document. The important thing though is that
> you can get the filename to appear both as the value of an href= attribute
> and as the content of the <a> element.
>
> Btw, if you need to prefix the filename with a protocol, server, etc.,
> make
> the XSL look like this:
>
> <a href="http://server/path/{filename}"><xsl:value-of
> select="filename"/></a>
>
> ==========================================================
> John E. Simpson | The secret of eternal youth
> simpson@xxxxxxxxxxx | is arrested development.
> http://www.flixml.org | -- Alice Roosevelt Longworth
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list