[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problems generating a link in HTML output
Hi Doug, The problem was that you were getting the text value of the <para> (using <xsl:value-of select="."/>) _and_ applying the link template. Text has a built in template, and from what I can tell, there is not a lot of sophisticated processing going on, so just using the generic <xsl:apply-templates /> (meaning any template that will fit) will produce your desired output. Also, note the shortcut in the <link> template; "{@href}" accomplishes the same thing by inserting the text value of the attribute. <xsl:template match="concept"> <xsl:apply-templates /> </xsl:template> <xsl:template match="para"> <p> <xsl:apply-templates /> </p> </xsl:template> <xsl:template match="link"> <a href="{@href}"> <xsl:value-of select="."/> </a> </xsl:template> HTH, John -----Original Message----- From: Doug Metcalfe-White [mailto:doug_metcalfe-white@xxxxxxxxxxxx] Sent: Tuesday, June 11, 2002 2:27 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Problems generating a link in HTML output Hi all, I am attempting to generate HTML from an XML source. Needless to say, links will be an important part of the output. While I can generate the links, I am getting a strange formatting to the inline links. For example, my desired output is: <p>The first rule of flying is that your number of take-offs should always equal your number of <a href="landing.html">landings</a>.</p> What I am getting is: <p>The first rule of flying is that your number of take-offs should always equal your number of landings.<a href="landing.html">landings</a></p> The XML source is: <concept> <para>The first rule of flying is that your number of take-offs should always equal your number of <link href="landing.html">landings</link>.</para> </concept> The file validates, so I'm only including an example of the troublesome bit. The XSLT file looks like this: <xsl:template match="concept"> <xsl:apply-templates select="concept_title"/> <xsl:for-each select="para"> <p><xsl:value-of select="."/> <xsl:apply-templates select="link"/> </p> </xsl:for-each> <xsl:apply-templates select="list"/> <xsl:apply-templates select="table"/> </xsl:template> <!-- The following generates exactly what I want.--> <xsl:template match="link"> <a> <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="."/> </a> </xsl:template> The problem seems to be with the lines transforming the <para> element. I have tried a couple of different approaches and this one has gotten me closest to my desired output. I can't figure out how to change them to get what I want. I have only begun to scratch the surface of XSLT and XPath so it won't surprise me it the answer is found in some function I'm unfamiliar with. Your advice and ideas are greatly appreciated. I am processing the files using Instant Saxon 6.4.4. Thanks, Doug Metcalfe-White XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|