Solved

XSLT problem with carriage return or line find characters??

Posted on 2004-10-09
1
376 Views
Last Modified: 2013-12-03
Basically, I have a VB .Net application in which I create a XML file which is transformed into a '.html' file using a XSL file based on data from several textboxes in the VB .Net app, one of the textboxes is a multi-line textbox.
Here is the data.xml file:

<?xml version="1.0" standalone="yes"?>
<dataroot>
  <Contacts>
    <Firstname>Steve</Firstname>
    <LastName>Thomas</LastName>
    <Address>1234 W. main St.</Address>
    <MobilePhone>312-555-2342</MobilePhone>
    <Notes>this should return
control characters
as they appear
</Notes>
    <HomePhone>321-555-2341</HomePhone>
  </Contacts>
</dataroot>

As you can see from the 'Notes' tag above, this data was inputed from a multi-line textbox and a return character was used after each line of text.

Here is the data.xsl file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
  <head>
  <title>Information</title>
   </head>      
  <body>
  <h2>Information</h2>
 
<xsl:for-each select="dataroot/Contacts">
<p>
  <xsl:value-of select="Firstname" />
</p>
<p>
  <xsl:value-of select="LastName" />
</p>  
<p>
 <xsl:value-of select="Address" />
</p>
<p>
  <xsl:value-of select="MobilePhone" />
</p>
<p>
  <xsl:value-of select="Notes" />
</p>
<p>
  <xsl:value-of select="HomePhone" />
  </p>
</xsl:for-each>

  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>

Here is the data.html file:

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-16">
    <title>Information</title>
  </head>
  <body>
    <h2>Information</h2>
    <p>Steve</p>
    <p>Thomas</p>
    <p>1234 W. main St.</p>
    <p>312-555-2342</p>
    <p>this should return control characters as they appear</p>
    <p>321-555-2341</p>
  </body>
</html>

The user hits return after every line of text in that multi-line textbox, but the XSL file ignores the carriage return characters.
So, I'd like to know how to change the XSL file so, it would replace every carriage return or line-feed character with a '<br>'. The HTML should look exactly like the way it does in the multi-line textbox. I'm a newbie on using XML and XSL.

Thanks
0
Comment
Question by:rkckjk
1 Comment
 
LVL 8

Accepted Solution

by:
a_twixt_in_the_tale earned 250 total points
ID: 12274120
<pre style="font-family:Times New Roman;font-size:14">
  <xsl:value-of select="Notes" />
</pre>

Depending on the default style-sheet settings u mite have in ur browser change the pre style

:)
Don
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question