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

Preserving White Space in Immediate following-sibling

Subject: Preserving White Space in Immediate following-sibling
From: "Joe Heidenreich" <HeidenreichJ@xxxxxxxx>
Date: Mon, 27 Jun 2005 14:24:33 -0400
paragraphs in xml
I'm having a problem preserving white-space between two elements that
immediately follow each other. For example, I can have the following two
paragraphs in XML:

<p>Sentence 1.<xref ref-type="bibr" rid="b1">1</xref> Sentence 2. <xref
ref-type="bibr" rid="b2">2</xref> Sentence 3.</p>
<p>Sentence 1.<xref ref-type="bibr" rid="b1">1</xref> <xref
ref-type="fig" rid="F1">Figure 1</xref> continuation of Sentence 2 which
started with a reference.</p>

The first one will be translated correctly, but the second one ignores
the white space between the two xref tags so that the output is:
"Sentence 1.1Figure 1 continuation of Sentence 2 which started with a
reference."

I tried remedying my problem with the following XSLT:

<xsl:template match="xref">
  <xsl:if test="@ref-type = 'bibr'">
   <sup><a href="#{@rid}"><xsl:value-of select="."/></a></sup>
  </xsl:if>
  <xsl:if test="@ref-type = 'fig'">
   <a href="#{@rid}"><xsl:value-of select="."/></a>
  </xsl:if>
  <xsl:if test="following-sibling::*[1][self::xref]">&#xA0;</xsl:if>
 </xsl:template>

Which fixed my second paragraph, but altered my first paragraph by
adding an extra space after the first xref. I'm not exactly sure why the
white space in the second paragraph is being ignored initially. Is there
a way to write my code to see if there is any text in-between the xref
tags and if not add the space?


Joe Heidenreich
Programmer
heidenreichj@xxxxxxxx

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.