I'm trying to create a CSV "text" output file for a XML to CSV
transformation, but I can't seem to get the file to be a "plain" text
document to handle by the browser.

The error message I receive is:
org.apache.xalan.xslt.XSLProcessorException:
        Warning: can't output text before document element!  Ignoring...
        at org.xml.sax.SAXException.<init>(SAXException.java:45)

The only thing that seems to work to avoid the message is to "wrap" the
desired output information with some open and close "tag" (I used
<out>...</out> in my example code here):

INXML.XML:
--------------------------------------------
<?xml version="1.0"?>

<?cocoon-process type="xslt"?>
<?xml-stylesheet type="text/xsl" href="outcsv.xsl"?>

<page>
    <datenow>9-18-2001</datenow>
    <pagetitle>Employees Working Report</pagetitle>
    <header>Working Report</header>
    <footer>End of report</footer>

    <esql:connection>
        [ ... stuff removed ... ]
    <employee>
        <lastname><esql:get-string column="last_name"/></lastname>
        <firstname><esql:get-string column="first_name"/></firstname>
        <deptdesc><esql:get-string column="emp_dept_desc"/></deptdesc>
        <locationname><esql:get-string
column="location_name"/></locationname>
        <schstart><esql:get-string
column="schedule_shift_start"/></schstart>
        <actualstart><esql:get-string column="shift_start"/></actualstart>
        <schend><esql:get-string column="schedule_shift_end"/></schend>
        <schmins><esql:get-string column="minutes_scheduled"/></schmins>
    </employee>
        [ ... stuff removed ... ]
    </esql:connection>
</page>
--------------------------------------------

OUTCSV.XSL:
--------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    version="1.0">

  <xsl:output method="text"
    encoding="ISO-8859-1"/>

  <xsl:strip-space elements="*"/>

  <xsl:template match="page">
    <out>
    <xsl:value-of select="pagetitle"/>
    <xsl:value-of select="header"/>
    </out>
  </xsl:template>

</xsl:stylesheet>
--------------------------------------------

But when I add the <out>,</out> tags, the output includes this line as the
first line of output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd";>
I want a plain "text" document.  Not one that the browser (IE5.5 -- is that
the problem??) thinks is an "HTML" document.

I posted this on an XSLT mailing list, and received the reply:
  "I suspect this is a Cocoon problem. I seem to recall Cocoon supplies
   its own ContentHandler to handle Xalan output, it looks as if this
   is not able to handle plain text output."

Anyone know how to remedy this?

Mark


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to