[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re[2]: Formatting hyperlinks and paragraphs

Subject: Re[2]: Formatting hyperlinks and paragraphs
From: Peter Simard <peter@xxxxxxxxxxxxxxx>
Date: Thu, 10 Jul 2003 10:19:14 -0400
formatting hyperlinks
Hello Jeni,

Thursday, July 10, 2003, 5:06:08 AM, you wrote:

JT> Hi Peter,

>> In a perfect world the stylesheet code below will take text from an
>> xml element, and:
>>
>> 1)  transform  text  that begins with 'http' into hyperlinks
>> 2) format the output to preserve line breaks.
>>
>> At the moment the code successfully formats the hyperlinks, but not
>> line breaks. Hopefully someone can point out my error?

JT> The problem in your stylesheet is that you add <br> elements as line
JT> breaks in your text, and then process the root node of the result tree
JT> fragment that you get, but you treat the root node as a string in the
JT> text2hyper template, which means that all the <br> elements get lost.

JT> You could change your stylesheet so that instead of passing the root
JT> node of the result tree fragment to the text2hyper template, you apply
JT> templates to it, in copy mode:

JT>   <xsl:apply-templates select="msxsl:node-set($temp)" mode="copy" />

JT> and have a template that copies the <br> elements:

JT> <xsl:template match="br" mode="copy">
JT>   <xsl:copy-of select="." />
JT> </xsl:template>

JT> and a template that matches the text nodes, and passes on their
JT> content to be marked up as hyperlinks by your text2hyper template:

JT> <xsl:template match="text()" mode="copy">
JT>   <xsl:call-template name="text2hyper">
JT>     <xsl:with-param name="strTemp" select="." />
JT>   </xsl:call-template>
JT> </xsl:template>

JT> Alternatively you could combine the two templates. For example, rather
JT> than just doing:

JT>   <xsl:value-of select="substring-before($string, $from)" />

JT> in the NewLine2Break template, you could call the text2hyper template
JT> on that substring:

JT>   <xsl:call-template name="text2hyper">
JT>     <xsl:with-param name="strTemp"
JT>                     select="substring-before($string, $from)" />
JT>   </xsl:call-template>

JT> Whether you want to do this probably depends on whether you'll ever
JT> want to use NewLine2Break *without* adding hyperlinks to the lines,
JT> and how bad you feel about using an extension function.

JT> Cheers,

JT> Jeni

JT> ---
JT> Jeni Tennison
JT> http://www.jenitennison.com/


JT>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Good Morning Jeni;

A  quick  thank you. I'm going to go with your suggestion of combining
the  templates  and avoid using an extension. This is provin more of a
challenge than I had anticipated though.

I'm sure I'll have more questions shortly.

Thanks,

Pete





-- 

Peter 
mailto:peter@xxxxxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.