xsl-list
[Top] [All Lists]

Re: [xsl] Replace new lines by <br> and double quote with special char: Problem retaining HTML tags

2006-09-08 08:06:55


I have tried David's code. But the output is required in a particular
format since the output is the input for another application

In my reply I said

You just need to fill in the replace template and templates for any
elements that you need to process by somthing other than copy.

which in this case means adding a template for elem
something like this

  <xsl:template match="elem">
   <xsl:text>&#10;Elem Id, News Details&#10;</xsl:text> 
   <xsl:value-of select="@id"/>
   <xsl:text>, "</xsl:text>
   <xsl:apply-templates select="text/*"/>
   <xsl:text>"</xsl:text>
  </xsl:template>

and a template for the replace, something like this (which isnt the
replace you wanted but fits on one line so does as an example)

  <xsl:template  name="transformXMLString">
   <xsl:param name="StringToTransform" select="."/>
   <xsl:value-of select="translate($StringToTransform,'&#10;&quot;','@!')"/>
  </xsl:template>

Then it appears that you want the line breaks in all elements (eg
<pre>). changing, not just those below <p> so change
  <xsl:template match="p//text()">
to
  <xsl:template match="text()">
so thattemplate matches all text nodes.

Then the code that I posted before on the input that you just posted
produces the following which looks fairly close to what you want to me:

 saxon grumble.xml grumble.xsl

Elem Id, News Details
1234, "<p>    This is some data </p><p>     </p><p>    This is some special 
characters &lt;AHLN.AS&gt; </p><p>    A group of students have gone to picnic. 
</p><p>     </p><PRE>    ** This is another special tag@     @ @  </PRE>"

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>