Subject: RE: How to add a variable/changeable hyperlink <a href=" http:\\WWW....> around a text in XSL? From: "John E. Simpson" <simpson@xxxxxxxxxxx> Date: Mon, 15 Mar 1999 22:54:19 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: How to add a variable/changeabl, Koh, Justin (Intern) | Thread | RE: How to add a variable/changeabl, Koh, Justin (Intern) |
RE: How to add a variable/changeabl, Koh, Justin (Intern) | Date | Re: Problems with LotusXSL., Scott Boag/CAM/Lotus |
Month |