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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I preserve white space?

Status
Not open for further replies.

sbbrown9924

Technical User
Mar 7, 2003
80
US
I have a web site that uses dynamic data from a proprietary xml-based content management system called concourse. I can find no documentation for it (its hosted free by a guy that's a friend of a friend of a friend).

Anyways, I extract data with mysql into layers and tables. These are not retaining white spaces, tabs, and line breaks. I've been to the wsc site but can't quite understand how to write the commands that will preserve white-spaces.

Can someone give me an example of how to do this that I might get an idea from? That would be most appreciated. Thanks.

--------------------------------------------

Below is an example of a sample page with all but one query stripped out of it. It is the <get-column id=&quot;description&quot;> field I want to preserve white space with. This content management system stores all the <head> information into a file called template.xhtml is merged with the file below and the xml data to form a complete web page.


<?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?>
<cqd database=&quot;xxxxxx&quot; user=&quot;xxxxx&quot; password=&quot;xxxxxx&quot;>
<body text=&quot;#666666&quot;>
<div id=&quot;DetailsText&quot; style=&quot;position:absolute; left:185px; top:50px; width:240px; height:290px; z-index:42; overflow:visible&quot; class=&quot;NavBar2&quot;>
<query id=&quot;DetailsText&quot;>
SELECT events2.event_id, events2.description
FROM events2
WHERE events2.event_id=926;
</query>
<row-results> <b>Details:</b><br/>
<get-column id=&quot;description&quot;> </row-results>
</div>
<div id=&quot;tanbox&quot; style=&quot;position:absolute; left:6px
top:10px; width:189px; height:430px; z-index:1&quot;>

<img src=&quot;../images/LoginBackground.gif&quot; width=&quot;187&quot;
height=&quot;430&quot;/>
</div

<div id=&quot;bluebox&quot; style=&quot;position:absolute; left:146px; top:40px; width:260px; height:415px; z-index:5&quot;>

<img src=&quot;../images/BackgroundShapes/BackgroundBox5.gif&quot; width=&quot;260&quot; height=&quot;395&quot;/
</div>

<div id=&quot;yellowbox&quot; style=&quot;position:absolute; left:366px; top:40px; width:222px; height:301px; z-index:4&quot;>

<img src=&quot;../images/BackgroundShapes/BackgroundBox3.gif&quot; width=&quot;222&quot; height=&quot;300&quot;/>
</div>

<div id=&quot;imagebox1&quot; align=&quot;left&quot; style=&quot;position:absolute; left:420; top:270px; width:150px; height:120px; z-index:10&quot;>

<query id=&quot;Image&quot;>
SELECT events2.img_id1 FROM events2
WHERE events2.event_id=926;
</query>
<row-results>
<a href=&quot;../images/Photos/$(events2.img_id1)&quot; target=&quot;_parent&quot;>
<img src=&quot;../images/Photos/$(events2.img_id1)&quot; width=&quot;130&quot; border=&quot;3&quot;/>
</a>
</row-results </div>
</body>
</cqd>

 
Without the actual xsl it's left to guesswork how the formatting takes place and where the xml:space=&quot;preserve&quot; should go.

Here's an example I used to output some text and breaking lines. If there's a link coming, it will not be broken, but a whitespace is added and it continues on the same line.

<?xml version=&quot;1.0&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;whitespace.xsl&quot;?>
<p>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br><a>some link</a></br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
</p>

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>
<html>
<head><title>Preserve whitespace</title></head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match=&quot;br&quot;>
<xsl:choose>
<xsl:when test=&quot;a&quot; xml:space=&quot;preserve&quot;> <xsl:value-of select=&quot;.&quot;/></xsl:when>
<xsl:eek:therwise><br/><xsl:value-of select=&quot;.&quot;/></xsl:eek:therwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

If you want to get a job done, ask a busy person. (Sherry Conway Appel - American writer)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top