You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Robert van Loenhout <r....@greenvalley.nl> on 2004/06/17 16:33:42 UTC
spontaneous carriage returns
Hi,
does anyone know why my Xalan outputs many carriage returns in the output when transforming to html?
transformer.transform(new DOMSource(doc),
new StreamResult(writer));
return writer.toString();
If an attribute contains abc
def
the output contains abc

def
I don't want any new carriage returns.
Thanks for any help.
Robert.
Re: spontaneous carriage returns
Posted by Robert van Loenhout <r....@greenvalley.nl>.
This is the output of a Xalan environment test in the application that creates the ouput file:
**********************
#---- BEGIN writeEnvironmentReport($Revision: 1.26 $): Useful stuff found: ----
version.DOM.draftlevel=2.0fd
java.class.path=D:\lib\j2sdk1.4.2_03\jre\lib\charsets.jar;D:\lib\j2sdk1.4.2_03\jre\lib\jce.jar;D:\lib\j2sdk1.4.2_03\jre\lib\jsse.jar;D:\lib\j2sdk1.4.2_03\jre\lib\plugin.jar;D:\lib\j2sdk1.4.2_03\jre\lib\rt.jar;D:\lib\j2sdk1.4.2_03\jre\lib\sunrsasign.jar;D:\lib\j2sdk1.4.2_03\jre\lib\ext\dnsns.jar;D:\lib\j2sdk1.4.2_03\jre\lib\ext\ldapsec.jar;D:\lib\j2sdk1.4.2_03\jre\lib\ext\localedata.jar;D:\lib\j2sdk1.4.2_03\jre\lib\ext\sunjce_provider.jar;G:\XalanTest\classes;D:\lib\xalan-j_2_6_0\bin\xalan.jar;D:\lib\xerces-2_6_2\xercesImpl.jar;D:\lib\xerces-2_6_2\xmlParserAPIs.jar;C:\winapps\IntelliJ-IDEA-4.0\lib\idea_rt.jar
version.JAXP=1.1 or higher
java.ext.dirs=D:\lib\j2sdk1.4.2_03\jre\lib\ext
#---- BEGIN Listing XML-related jars in: foundclasses.sun.boot.class.path ----
xalan.jar-path=D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xalan.jar
xercesImpl.jar-apparent.version=xercesImpl.jar from Xerces-J-bin.2.6.2
xercesImpl.jar-path=D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xercesImpl.jar
xml-apis.jar-apparent.version=xml-apis.jar from tck-jaxp-1_2_0 branch of xml-commons, tag: xml-commons-external_1_2_01
xml-apis.jar-path=D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xml-apis.jar
#----- END Listing XML-related jars in: foundclasses.sun.boot.class.path -----
version.xerces2=Xerces-J 2.6.2
version.xerces1=not-present
version.xalan2_2=Xalan Java 2.6.0
version.xalan1=not-present
version.ant=not-present
java.version=1.4.2_03
version.DOM=2.0
version.crimson=present-unknown-version
sun.boot.class.path=D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xalan.jar;D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xercesImpl.jar;D:\lib\j2sdk1.4.2_03\jre\lib\endorsed\xml-apis.jar;D:\lib\j2sdk1.4.2_03\jre\lib\rt.jar;D:\lib\j2sdk1.4.2_03\jre\lib\i18n.jar;D:\lib\j2sdk1.4.2_03\jre\lib\sunrsasign.jar;D:\lib\j2sdk1.4.2_03\jre\lib\jsse.jar;D:\lib\j2sdk1.4.2_03\jre\lib\jce.jar;D:\lib\j2sdk1.4.2_03\jre\lib\charsets.jar;D:\lib\j2sdk1.4.2_03\jre\classes
#---- BEGIN Listing XML-related jars in: foundclasses.java.class.path ----
xalan.jar-path=D:\lib\xalan-j_2_6_0\bin\xalan.jar
xercesImpl.jar-apparent.version=xercesImpl.jar from Xerces-J-bin.2.6.2
xercesImpl.jar-path=D:\lib\xerces-2_6_2\xercesImpl.jar
#----- END Listing XML-related jars in: foundclasses.java.class.path -----
version.SAX=2.0
version.xalan2x=Xalan Java 2.6.0
#----- END writeEnvironmentReport: Useful properties found: -----
# YAHOO! Your environment seems to be OK.
**********************
This is the XSL file:
**********************
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"
doctype-system="http://www.w3.org/TR/REC-html40/loose.dtd"
doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:template match="root">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div>
<xsl:attribute name="id">
<xsl:value-of select="@test"/>
</xsl:attribute>
<xsl:value-of select="@test"/>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
**********************
This is the method that creates the output
**********************
public static void test() throws TransformerException, IOException
{
Document doc = new DocumentImpl();
Element root = doc.createElement("root");
root.setAttribute("test","line1\nline2");
doc.appendChild(root);
TransformerFactory tFactory = TransformerFactory.newInstance();
File xslFile = new File("c:\\test.xsl");
Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
File outputFile = new File("c:\\test.html");
FileWriter writer = new FileWriter(outputFile);
transformer.transform(new DOMSource(doc), new StreamResult(writer));
writer.close();
}
**********************
The result output will contain OD OA in the contents of the div tag. And 0D 0D 0A in the id attribute value.
---- Original Message ----
From: Joanne Tong
To: Robert van Loenhout
Cc: xalan-j-users@xml.apache.org
Sent: Thursday, June 17, 2004 7:02 PM
Subject: Re: spontaneous carriage returns
> Can you try again with the latest Xalan version?
>
> If the output is the same, please post an environment report and a sample
> testcase.
>
> http://xml.apache.org/xalan-j/faq.html#faq-N1005D
>
> thanks.
>
> Joanne Tong
>
>
>
> "Robert van Loenhout" <r....@greenvalley.nl>
> 06/17/2004 10:33 AM To<xa...@xml.apache.org>
> cc
> Subjectspontaneous carriage returns
>
>
>
>
>
>
>
> Hi,
>
> does anyone know why my Xalan outputs many carriage returns in the output
> when transforming to html?
>
> transformer.transform(new DOMSource(doc),
> new StreamResult(writer));
> return writer.toString();
> If an attribute contains abc
def
> the output contains abc

def
>
> I don't want any new carriage returns.
>
> Thanks for any help.
> Robert.
Re: spontaneous carriage returns
Posted by Joanne Tong <jo...@ca.ibm.com>.
Can you try again with the latest Xalan version?
If the output is the same, please post an environment report and a sample
testcase.
http://xml.apache.org/xalan-j/faq.html#faq-N1005D
thanks.
Joanne Tong
"Robert van Loenhout" <r....@greenvalley.nl>
06/17/2004 10:33 AM
To
<xa...@xml.apache.org>
cc
Subject
spontaneous carriage returns
Hi,
does anyone know why my Xalan outputs many carriage returns in the output
when transforming to html?
transformer.transform(new DOMSource(doc),
new StreamResult(writer));
return writer.toString();
If an attribute contains abc
def
the output contains abc

def
I don't want any new carriage returns.
Thanks for any help.
Robert.