This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

xalan vs. xalan-j output, xalan-j ignoring output directions?


Hey folks,

Got a problem that I think is related to possible differences in versions of
xalan.

This page:  http://www.hnw.com/internal/newsletter/newsletter_preview.jsp
uses an XML source document and an XSL stylesheet and says that the
transformer is:

Vendor: Apache Software Foundation
Vendor URL: http://xml.apache.org/xalan

The source of this page is not indented.

However, when I use the exact same XML and XSL files with a java program
(listed below) that uses this transformer...

Vendor:Apache Software Foundation
Vendor URL:http://xml.apache.org/xalan-j

... the output is indented and includes the xml declaration, even though I
have the <xsl:output method="html" indent="no" omit-xml-declaration="yes" />
statement in the stylesheet and I even made setOutputProperty statements in
the java code.  Any ideas how to make this go away?  If xalan-j version 2 is
the problem should I try to use a previous version instead and de-install
version 2?  The resulting HTML, when read by most email clients renders with
spaces between graphics that should be flush.  There are even differences in
how <xsl:text> tags are handled.

Here's the java code:

 public String getNewsletterContent(String xslURL) throws Exception {
  // do a transformation on the current newsletter content and return as
HTML
    // load JAXP transformer
    TransformerFactory factory = TransformerFactory.newInstance();
    // need to add possible parameter handline below
    Transformer transformer = factory.newTransformer( new
StreamSource(xslURL) );
    transformer.setOutputProperty("method","html");
    transformer.setOutputProperty("omit-xml-declaration","yes");
    transformer.setOutputProperty("indent","no");

    // style document using transformer
    DocumentSource source = new DocumentSource( getDocument() );
    DocumentResult result = new DocumentResult();
    transformer.transform( source, result );

    // take new document and write it to a string
    Document transformedDoc = result.getDocument();
    StringWriter buffer = new StringWriter();
    HTMLWriter writer = new HTMLWriter(buffer);
    writer.write(transformedDoc);
    String text = buffer.toString();
    writer.close();
    return text;
  }

Here's the _start_ of the XSL file:

<?xml version="1.0"?>

<xsl:stylesheet
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
       xmlns="http://www.w3.org/TR/REC-html40";
       version="1.0">
<xsl:output method="html" indent="no" omit-xml-declaration="yes" />

<xsl:param name="userID" select="'null'" />
<xsl:param name="newsletterID" select="'null'" />

<xsl:template match="/">


<HTML><HEAD><TITLE>hnw: This Week's HNW Wealth News</TITLE></HEAD>
<BODY text="#000000" link="#32456D" alink="#FF9900" bgcolor="#ffffff"
leftmargin="0" rightmargin="0" topmargin="0" marginheight="0"
marginwidth="0">

<p>Vendor: <xsl:value-of select="system-property('xsl:vendor')"/>
            <br/>Vendor URL:
              <xsl:value-of select="system-property('xsl:vendor-url')"/></p>

<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
 <TR valign="top" align="left">
  <TD bgcolor="#22489b" colspan="2"><A
href="http://www.hnw.com/index.jsp";><IMG height="68" alt="[hnw]"
src="http://www.hnw.com/images/head.logo.hnw.gif"; width="124"
border="0"/></A></TD></TR></TABLE>



Here's the _start_ of the resulting HTML:

<HTML xmlns="http://www.w3.org/TR/REC-html40";>
  <HEAD>
    <TITLE>hnw: This Week's HNW Wealth News</TITLE>
  </HEAD>
  <BODY marginwidth="0" marginheight="0" topmargin="0" rightmargin="0"
leftmargin="0" bgcolor="#ffffff" alink="#FF9900" link="#32456D"
text="#000000">
    <p>Vendor:Apache Software Foundation
      <br>Vendor URL:http://xml.apache.org/xalan-j
    </p>
    <TABLE border="0" width="100%" cellpadding="0" cellspacing="0">
      <TR align="left" valign="top">
        <TD colspan="2" bgcolor="#22489b">
          <A href="http://www.hnw.com/index.jsp";>
            <IMG border="0" width="124"
src="http://www.hnw.com/images/head.logo.hnw.gif"; alt="[hnw]" height="68">
          </A>
        </TD>
      </TR>
    </TABLE>





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]