RE: [xsl] A whitespace question, but probably not the same as the other one s

Subject: RE: [xsl] A whitespace question, but probably not the same as the other one s
From: "Nice, Kerry A. (LNG-SHEP)" <Kerry.Nice@xxxxxxxxxxxxxx>
Date: Thu, 7 Jun 2001 11:43:16 -0600
Well, the problem is that I'm ending up with "acceptedRice's" instead of
"accepted Rice's" due to the page breaks in the XML.  The output of the
stylesheet puts line feeds there, but when I look at the result in Word (the
output is an RTF file), it ignores those and runs the words together.  I'll
try a simpler example.  

I can fix this one with the normalize-space():
<xsl:template match="cite4thiscase">
{\ul\cf9 <xsl:value-of select="normalize-space(.)"/>\par }

<lnv:CITE segformat="$T"><cite4thiscase><?DBLOAD
Alas. LEXIS 50</cite4thiscase></lnv:CITE>

Without the normalize-space(), I end up with 2001Alas. LEXIS 50, which is
wrong.  But I can fix that one with the way the XSL is above.  So far, so

Another one, the XML (like I said, I didn't design it, I just take what they
send me):
<lnv:COUNSEL>Robert A. Sparks, Fairbanks, for Appellant.<nl/><fb/><nl/>Mark
E. Ashburn, Ashburn &amp; Mason, Anchorage, for Appellees.  </lnv:COUNSEL>

Some of the XSL:
<xsl:template match="lnv:COUNSEL">
\par <xsl:text disable-output-escaping="yes">&lt;I&gt;</xsl:text> 

<xsl:template match="nl">
\par<xsl:text xml:space="preserve"> </xsl:text>

<xsl:template match="fb">
<xsl:text xml:space="preserve"> </xsl:text>

The output:
\par <I>Robert A. Sparks, Fairbanks, for Appellant.

E. Ashburn, Ashburn & Mason, Anchorage, for Appellees.  

The result when I view it will be "MarkE. Ashburn, Ashburn & Mason,
Anchorage, for Appellees."

Maybe the problem is more basic here.  I think the problem is the text is
not being handled, it is just being dumped out as it comes to it.  I've
<xsl:template match="lnv:COUNSEL">
\par <xsl:text disable-output-escaping="yes">&lt;I&gt;</xsl:text> 
<xsl:value-of select="normalize-space(.)"/>
<!-- <xsl:apply-templates/> -->

and I get:
\par <I> Robert A. Sparks, Fairbanks, for Appellant.Mark E. Ashburn, Ashburn
& Mason, Anchorage, for Appellees.

the "Mark E." is right, but it never calls the <nl> and <fb> so I am missing
the "\par \par" between "Appellant." and "Mark"

Does this all make sense?  It is driving me crazy.  How do I get the
whitespace right and at the same time all the weird random embedded nodes
(the nl and fb) get handled too?  I saw the samples to replace the line
feeds with carriage returns and I suspect that something like that will fix
things, but in light of all the strange stuff embedded all over the place, I
wasn't sure how to implement that.

I almost wonder if I wouldn't be better off just replacing all those stupid
<nl>, <fb>, etc nodes with the real text.  I have to do some processing and
insert things into the DOM that I apply the stylesheet to before hand
anyways.  If I can't figure this one out in the next day or so, I'm just
going to do that when I have the DOM in my Java program before I call Xalan.


-----Original Message-----
From: Mike Brown [mailto:mike@xxxxxxxx]
Sent: Thursday, June 07, 2001 10:37 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] A whitespace question, but probably not the same as
the other one s

Nice, Kerry A. (LNG-SHEP) wrote:
> Ok, I've looked through the faq and can't figure this one out.  I have
> nodes that I handle directly, so putting normalize-space into a value-of
> fixes the problem like:
> <xsl:if test="@typestyle='un'">
>   {\ul <xsl:value-of select="normalize-space(.)"/>}
> </xsl:if>
> Except I have a bunch of screwy XML (I didn't design it, I just take what
> process gets), that I had to handle with this template match="*" node that
> helpful person on this list suggested previously.  Basically, there are
> <nl/> tags scattered randomly throughout the document.  I hope this is
> enough information.  The end product is a RTF document.
> The basic problem is for nodes like <p>, I can't figure out where to put a
> normalize-space, so I end up with output like:
> ... accepted
> Rice's  ...
> which ends up as:
> ... acceptedRice's ...
> when you look at the resulting document in Word.

You still haven't said what the problem is, or what you're really trying 
to accomplish.

I suspect what you're really trying to do is replace linefeed characters
with something else? Hard to tell exactly without seeing the actual input 
and the desired output.

   - Mike
mike j. brown, software engineer at  |  xml/xslt: in denver, colorado, USA    |  personal:

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread