You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Linda Derezinski <li...@interfacecontrol.com> on 2000/05/16 23:00:45 UTC

multiple text nodes

I am trying to produce HTML output and preserve the line breaks inside of
text nodes.  Is there some why to force a text node for each line?

If the XML file looks like this:
<root>
   <elementnode>
          This is a multiple line text node
               it
           has a couple of lines in it
    </elementnode>
</root>

and the XSL looks like …
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:preserve-space elements=" elementnode"/>
… stuff omitted …
    <xsl:for-each select="./DESC_TAG/text()">
       <P><xsl:value-of select="."/></P>
    </xsl:for-each>

My goal is to preserve the line breaks in the output.

Is there an easier way to do this?

Linda Derezinski
Interface & Control Systems



RE: multiple text nodes

Posted by Jeff Cutler-Stamm <jc...@thinkshare.com>.
RE: Servlet Xalan performance (Get vs Post)See:
http://www.w3.org/TR/1998/REC-xml-19980210#sec-white-space

for a discussion of whitespace handling in XML. Depending on the method you
use to feed your XML to Xalan, you might need to specify the
xml:space="preserve" attribute on <elementnode> in the source document. The
line breaks in your example would not be considered significant whitespace
by the parser and would probably be flattened in a DOM representation
without the proper xml:space attribute.

regards,
Jeff Cutler-Stamm
  -----Original Message-----
  From: Linda Derezinski [mailto:linda@interfacecontrol.com]
  Sent: Tuesday, May 16, 2000 2:01 PM
  To: xalan-dev@xml.apache.org
  Subject: multiple text nodes


  I am trying to produce HTML output and preserve the line breaks inside of
text nodes.  Is there some why to force a text node for each line?



  If the XML file looks like this:

  <root>

     <elementnode>

            This is a multiple line text node

                 it

             has a couple of lines in it

      </elementnode>

  </root>



  and the XSL looks like …

  <?xml version="1.0"?>

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

    <xsl:preserve-space elements=" elementnode"/>

  … stuff omitted …

      <xsl:for-each select="./DESC_TAG/text()">

         <P><xsl:value-of select="."/></P>

      </xsl:for-each>



  My goal is to preserve the line breaks in the output.



  Is there an easier way to do this?




  Linda Derezinski

  Interface & Control Systems