Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is this not preserving white space

Status
Not open for further replies.

mountainbiker

Programmer
Aug 21, 2002
122
GB
XML (this seems to work when you have a space sandwiched between elements, e.g.,
[tt]</EmphasizedText> <EmphasizedText[/tt]):

[tt]
<doc>
<Para>
Here some <EmphasizedText emphasisType='b'>words</EmphasizedText> <EmphasizedText emphasisType='i'>are recursively
<EmphasizedText emphasisType='b'>
emphasized
</EmphasizedText>
</EmphasizedText>.
However, this word is not. This next word is <EmphasizedText>bold</EmphasizedText>. This word is <EmphasizedText emphasisType='u'>underlined</EmphasizedText>.
</Para>
</doc>
[/tt]

XML (this does not work):
[tt]
<doc>
<Para>
Here some <EmphasizedText emphasisType='b'>words</EmphasizedText> <EmphasizedText emphasisType='i'>are
recursively
<EmphasizedText emphasisType='b'>
emphasized
</EmphasizedText>
</EmphasizedText>.
However, this word is not. This next word is <EmphasizedText>bold</EmphasizedText>. This word is <EmphasizedText emphasisType='u'>underlined</EmphasizedText>.
</Para>
</doc>
[/tt]

XSL:
[tt]
<xsl:template match=&quot;doc&quot;>
<html>
<head>
<title>A Document</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match=&quot;Para&quot;>
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match=&quot;EmphasizedText&quot;>
<xsl:choose>
<xsl:when test=&quot;not(@emphasisType) or @emphasisType = 'b'&quot;>
<b><xsl:apply-templates/></b>
</xsl:when>
<xsl:when test=&quot;@emphasisType = 'i'&quot;>
<i><xsl:apply-templates/></i>
</xsl:when>
<xsl:when test=&quot;@emphasisType = 'u'&quot;>
<u><xsl:apply-templates/></u>
</xsl:when>
</xsl:choose>
</xsl:template>
[/tt]
 
Yes. I have also tried xsl:preserve-space--which works with some processors. This preserved the space sandwiched between the </EmphasizedText> <EmphasizedText. However, it also preserved the line feeds. In addition, if you move the space to the left or right (so it falls within the element) then it is also retained without xsl:preserve-space or other changes. None of these &quot;workarounds&quot; are really what I would like, but it maybe a limitation that has to be lived with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top