xsl-list
[Top] [All Lists]

Re: [xsl] Fwd: xml/xslt line break

2008-07-20 05:18:38
what I need to change is something from xsl I am reading using xpath -
I called it here :txtTargetTextforchange
can you help?

my xsl looks like that:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:import href="common.xslt"/>
<xsl:output method="html" indent="no"/>
=======================
.
.
.
.<xsl:template match="*" mode="Resp">
<table>
.
.
.<td>
<xsl:value-of select="./txtTargetTextforchange" />&#160;
</td>

.
.
.
===

On Sun, Jul 20, 2008 at 2:32 PM, Martin Honnen 
<Martin(_dot_)Honnen(_at_)gmx(_dot_)de> wrote:
Taly wrote:

I am using version 1.0 thats the problem.I saw a samplw in the web but
didn't work for me:
http://www.dpawson.co.uk/xsl/sect2/break.html#d3080e76
perhaps I donno ow to use call-template the way I should

It is not possible to guess where your attempts failed. You will need to
show us your XML input and your stylesheet trying to process that.
Perhaps this example helps, the XML is

<root>
 <foo>Line 1
Line 2
Line 3</foo>
</root>

the stylesheet, incorporating the template from the FAQ looks as follows:

 <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   version="1.0">

 <xsl:output method="html" indent="yes"/>

 <xsl:template match="/root">
   <html>
     <head>
       <title>Example</title>
     </head>
     <body>
       <xsl:apply-templates/>
     </body>
   </html>
 </xsl:template>

<xsl:template name="substitute">
  <xsl:param name="string" />
  <xsl:param name="from" select="'&#xA;'" />
  <xsl:param name="to">
     <br />
  </xsl:param>
  <xsl:choose>
     <xsl:when test="contains($string, $from)">
        <xsl:value-of select="substring-before($string, $from)" />
        <xsl:copy-of select="$to" />
        <xsl:call-template name="substitute">
           <xsl:with-param name="string"
                           select="substring-after($string, $from)" />
           <xsl:with-param name="from" select="$from" />
           <xsl:with-param name="to" select="$to" />
        </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
        <xsl:value-of select="$string" />
     </xsl:otherwise>
  </xsl:choose>
</xsl:template>

 <xsl:template match="foo">
   <div>
     <xsl:call-template name="substitute">
       <xsl:with-param name="string" select="."/>
     </xsl:call-template>
   </div>
 </xsl:template>

</xsl:stylesheet>

the result then is

<html>
  <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

     <title>Example</title>
  </head>
  <body>

     <div>Line 1<br>Line 2<br>Line 3
     </div>

  </body>
</html>


--

       Martin Honnen
       http://JavaScript.FAQTs.com/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--