Sign In/My Account | View Cart  
advertisement

Article:
 Controlling Whitespace, Part 1
Subject: Insert a
in HTML
Date: 2007-01-29 04:32:38
From: clonn

Hi, I'm new to XSLT and I'm trying to transform an XML into HTML using XSL.
The problem is I want to preserve my linebreaks as typed in the XML, as the previous comment in this thread.


Here's a sample of the stylesheet:


<?xml version="1.0" encoding="UTF-8"?><!-- DWXMLSource="../myXML.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 de transición//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Document</title>
</head>
<body>



<xsl:value-of select="text" />



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



And this is the XML


<text>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.


Morbi vestibulum, magna vel rutrum malesuada, nunc odio cursus nibh.
</text>



The result is:


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vestibulum, magna vel rutrum malesuada, nunc odio cursus nibh.



I've tryed many ways, including your examples, but it doesn't work. Any ideas?


Thanks in advance.


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Oldest First
  • Insert a
    in HTML

    2007-01-29 08:22:00 Bob DuCharme [Reply]

    I can't think of anything to tell you outside of what's in the article. (I won't have a chance to try your example for a while.)


    Bob


Sponsored By: