[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Senthilukvelaan wrote, On 2008-09-12 09:41:
The following does the transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
You seem to have a vague idea of how the XSLT processor works. Further, it is better to make the LINK and LINK_TEXT subelements of a common element such as LINKINFO element. For example, replace
with
Then, we can replace the ugly and not so robust templates for LINK and LINK_TEXT (template 3, 4 and 5) with
Note that I would choose different names for LINKINFO and LINK. For example, LINKINFO => LINK and LINK => REF
/Jonas
Re: [xsl] Making Link in text
Subject: Re: [xsl] Making Link in text From: Jonas Mellin <jonas.mellin@xxxxxx> Date: Fri, 12 Sep 2008 11:33:36 +0200 |
Senthilukvelaan wrote, On 2008-09-12 09:41:
Have a difficulty in producing the expected output. Any pointer would help. Input
<P>Please click <LINK>http://www.google.com</LINK> <LINK_TEXT> Google </LINK_TEXT> on the link below or copy and paste the address onto your web browser's address window. Once you're on the web page, | you will be instructed </P>
xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:template match="P"> <P> <xsl:call-template name="markup"> <xsl:with-param name="content" select="." /> <xsl:with-param name="link" select="//LINK" /> <xsl:with-param name="text" select="//LINK_TEXT" /> </xsl:call-template> </P> </xsl:template> </body> </html> </xsl:template>
<xsl:template match="P" name="markup" > <xsl:param name="link" /> <xsl:param name="text" /> <a href="{$link}"> <xsl:value-of select="$text" /> </a> </xsl:template>
</xsl:stylesheet>
The following does the transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="*"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template>
<xsl:template match="LINK"> <a><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute> <xsl:apply-templates select="following::LINK_TEXT[1]" mode="inLink"/> </a> </xsl:template>
<xsl:template match="LINK_TEXT" mode="inLink"> <xsl:value-of select="."/> </xsl:template>
<xsl:template match="LINK_TEXT"> </xsl:template>
</xsl:stylesheet>
You seem to have a vague idea of how the XSLT processor works. Further, it is better to make the LINK and LINK_TEXT subelements of a common element such as LINKINFO element. For example, replace
<LINK>http://www.google.com</LINK> <LINK_TEXT> Google </LINK_TEXT>
with
<LINKINFO> <LINK>http://www.google.com</LINK> <LINK_TEXT> Google </LINK_TEXT> </LINKINFO>
Then, we can replace the ugly and not so robust templates for LINK and LINK_TEXT (template 3, 4 and 5) with
<xsl:template match="LINKINFO"> <a><xsl:attribute name="href"><xsl:value-of select="LINK"/></xsl:attribute> <xsl:value-of select="LINK_TEXT"/> </a> </xsl:template>
Note that I would choose different names for LINKINFO and LINK. For example, LINKINFO => LINK and LINK => REF
/Jonas
Desired output.
<html> <body> <P>Please click <a href="http://www.google.com"> Google </a> on the link below or copy and paste the address onto your web browser's address window. Once you're on the web page, | you will be instructed </P> </body> </html>
Thanks, S
-- Carpe Diem! === Jonas Mellin, Assistant Professor in Computer Science School of Humanities and Informatics, Building E-2 University of Skvvde, P.O. Box 408, SE-541 28 Skvvde, Sweden Phone: +46 500 448321, Fax: +46 500 448399 Email: jonas.mellin@xxxxxx, URL: http://www.his.se/melj
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Making Link in text, Senthilukvelaan | Thread | Re: [xsl] Making Link in text, Senthilukvelaan |
[xsl] Making Link in text, Senthilukvelaan | Date | Re: [xsl] How to get page range wit, Wendell Piez |
Month |
Keywords