[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Making Link in text
Senthilukvelaan wrote, On 2008-09-12 09:41:
Have a difficulty in producing the expected output. Any pointer would help. Input 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
-- 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|