You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Cindy Ballreich <ci...@ballreich.net> on 2001/03/12 23:08:03 UTC

more text/plain output

A couple of days ago Jonathan Fuerth suggested using XSP to change the
Content-Disposition header so that MSIE will accept text/plain output from
an XML source. I wrote an XSP file that does this and it appears to work -
at least with small amounts of XML. Using the XSP with my full XML file
(which isn't really all *that* big) gives the following error...

java.lang.ClassFormatError: Code of a method longer than 65535 bytes

I expect that I'm going about this all wrong. All I really want to do is
call response.setHeader and then copy the XML with new PIs pointing it to
the proper  XSL file. This is the XSP that I've written...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>
    <xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
    <xsl:processing-instruction
name="xml-stylesheet">href="catalog-text.xsl"
type="text/xsl"</xsl:processing-instruction>
    <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
      <page>
        <xsp:logic> 
          response.setHeader("Content-Disposition", "inline;
filename=kluge.txt");
        </xsp:logic>
        <xsl:apply-templates/>
      </page>
    </xsp:page>
  </xsl:template>
  <xsl:template match="@*|*|text">
    <xsl:copy-of select="."/>
  </xsl:template>
</xsl:stylesheet>

I'd really appreciate any pointers that would get me heading in the right
direction.

Cindy



---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: more text/plain output

Posted by Cindy Ballreich <ci...@ballreich.net>.
At 11:24 AM 3/13/01 +0300, Tagunov Anthony wrote:
>On Mon, 12 Mar 2001 14:08:03 -0800, Cindy Ballreich wrote:
>>
>>java.lang.ClassFormatError: Code of a method longer than 65535 bytes

>
>I guess the reason is the following: all you put into .xml file that has 
><?cocoon-process type="xsp"?>
>is compiled into one java method (look at the repository, if intrested!)
>
>So too much code can not go there!
>The solution for serving long files can be one of the following:
>1) use XInclude. So your main file will look like
><?cocoon-process type="xsp"?>
><?cocoon-process type="xinclude"?>
><?cocoon-process type="xslt"?>
><?xml-stylesheet href=".." type="text/xsl"?>
><xsp:page>
>  <page>
>     <xsp:logic>responce.setHeader..</xsp:logic>
>     <include xinclude:href="real-file.xml" xinclude:parse="xml"
xmlns:xinclude="..."/>
>  </page>
></xsp:page>
>
>This should work.

Thanks for the input. I tried what you suggested, but I still get the
error. I've never used xinclude before so I'm not sure if it's supposed to
create a copy of the file or just a reference to it. It appears to be
copying the content. I'm going to look into this some more since it sounds
promising.



---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: more text/plain output

Posted by Tagunov Anthony <at...@nnt.ru>.
>It would be great if there was a way to make a quick call out to an XSP
>file from the XSL that sets the PIs...
>       XSP
>        |
>XML -> XSL -> XSL -> output
>It appears that this isn't possible?

It does not. But doing things as simple as
inserting HTTP headers can be done via
a special processor.

Mabye it could look for some
<?cocoon-insert-header name="" value=""?>
directives (to speed up processing and
avoid scanning a whole, possibly lengthy doc)
or work in a taglib style (f.e. fetching out
<responce:set-header../> tags.

BTW in some cases it looks possible to "port"
a taglib to a processor, e.g. make processor
implementing things like <response:set-header
<request:get-parameter .. and so on..

This may be run without egaging XSP and
in any place of the processing chain.

So an option with this additional headers might
be an extra Cocoon processor.



---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: more text/plain output

Posted by Cindy Ballreich <ci...@ballreich.net>.
At 10:53 AM 3/13/01 -0500, Jonathan Fuerth wrote:
>On Mon, Mar 12, 2001 at 02:08:03PM -0800, Cindy Ballreich wrote:
>> (which isn't really all *that* big) gives the following error...
>> 
>> java.lang.ClassFormatError: Code of a method longer than 65535 bytes
>
>I think the FAQ mentions something about this.. it's some sort of
>inherent limitation of the classloader or some such thing.  I've never
>run into this problem myself, so I don't know much about it. :)
>
>>     <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>>       <page>
>>         <xsp:logic> 
>>           response.setHeader("Content-Disposition", "inline;
>> filename=kluge.txt");
>>         </xsp:logic>
>          [insert what's currently in the .xml at this point]          
>>       </page>
>>     </xsp:page>
>
>Try wrapping this chunk of code around your .xml file.  Stick what's
>currently in the body of your file into where I indicated.  Of course,
>you'll have to keep all the bookkeeping tags (references to
>stylesheets, the cocoon-process stuff, and the xml declaration) at the
>very top, above xsp:page.
>
>Of course, doing this will break content/logic/presentation
>separation.  You'll be sending what I'd consider to be presentation
>information straight from the body of your xml file (which was
>supposed to be used only for content). But I think you'll no longer
>run into that "method too large" exception.

During my testing this is one of the things that I tried. I first tried it
with the whole XML file and got the "Code of a method longer than 65535
bytes" error. I then tried a drastically shortened version of the file and
it worked. This is how I was able to determine that your suggestion to set
the Content-Disposition world work.

I'd really like to keep the logic and the data separate if possible. I'm
taking a "target" parameter in the URL that I'm using to direct the output
type by changing the PIs accordingly. This limits what I can do.

It would be great if there was a way to make a quick call out to an XSP
file from the XSL that sets the PIs...
       XSP
        |
XML -> XSL -> XSL -> output
It appears that this isn't possible?

Incidentally, set-header is part of the response taglib a version of which
is included with Cocoon 1.8.2. You can now do it like this...
<res:set-header name="Content-Disposition">inline;
filename=kluge.txt</res:set-header>

>
>Perhaps one of the Cocoon developers could give us a nudge in the
>right direction.. now that you've got it working, what's the best way
>to structure this logic?

Yes, please.


---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: more text/plain output

Posted by Jonathan Fuerth <fu...@sqlpower.ca>.
On Mon, Mar 12, 2001 at 02:08:03PM -0800, Cindy Ballreich wrote:
> (which isn't really all *that* big) gives the following error...
> 
> java.lang.ClassFormatError: Code of a method longer than 65535 bytes

I think the FAQ mentions something about this.. it's some sort of
inherent limitation of the classloader or some such thing.  I've never
run into this problem myself, so I don't know much about it. :)

>     <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>       <page>
>         <xsp:logic> 
>           response.setHeader("Content-Disposition", "inline;
> filename=kluge.txt");
>         </xsp:logic>
          [insert what's currently in the .xml at this point]          
>       </page>
>     </xsp:page>

Try wrapping this chunk of code around your .xml file.  Stick what's
currently in the body of your file into where I indicated.  Of course,
you'll have to keep all the bookkeeping tags (references to
stylesheets, the cocoon-process stuff, and the xml declaration) at the
very top, above xsp:page.

Of course, doing this will break content/logic/presentation
separation.  You'll be sending what I'd consider to be presentation
information straight from the body of your xml file (which was
supposed to be used only for content). But I think you'll no longer
run into that "method too large" exception.

Perhaps one of the Cocoon developers could give us a nudge in the
right direction.. now that you've got it working, what's the best way
to structure this logic?

---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: more text/plain output

Posted by Tagunov Anthony <at...@nnt.ru>.
On Mon, 12 Mar 2001 14:08:03 -0800, Cindy Ballreich wrote:

>
>A couple of days ago Jonathan Fuerth suggested using XSP to change the
>Content-Disposition header so that MSIE will accept text/plain output from
>an XML source. I wrote an XSP file that does this and it appears to work -
>at least with small amounts of XML. Using the XSP with my full XML file
>(which isn't really all *that* big) gives the following error...
>
>java.lang.ClassFormatError: Code of a method longer than 65535 bytes

I guess the reason is the following: all you put into .xml file that has 
<?cocoon-process type="xsp"?>
is compiled into one java method (look at the repository, if intrested!)

So too much code can not go there!
The solution for serving long files can be one of the following:
1) use XInclude. So your main file will look like
<?cocoon-process type="xsp"?>
<?cocoon-process type="xinclude"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href=".." type="text/xsl"?>
<xsp:page>
  <page>
     <xsp:logic>responce.setHeader..</xsp:logic>
     <include xinclude:href="real-file.xml" xinclude:parse="xml" xmlns:xinclude="..."/>
  </page>
</xsp:page>

This should work.

Are you using C1 or C2?

If you're using C1 then you gonna run in the following trouble:
-- if this page gets served from cache, then YOU WON'T HAVE
    YOU DESIRED HEADER!!
    (we here at www.nnt.ru tried to modify Page.java to store
     the headers, but the solution is far not elegent and in addition
     we fell behind the current cocoon version with our patched 
     files. The trouble is that you no longer can set headers with
     responce.setHeader(), you should do it via page.setHeader,
     but in an XSP page you can not get access to the Page
     object. So we could set our new headers only in 
     a processor. If i could find a way to do it in XSP then
     in the responce taglib we could update <responce:set-header/>
     (or whatever it is called there), but :-(((..)
So the only solution is to disable caching, that is _NOT_ put
<xsp:page>
<xsp:logic>boolean hasChanged(){ return true; }
boolean isCacheable(){ return true; }</xsp:logic>
but then, you know, it will run slowely, espcially
knowing that your files are large.

again we have developed some content aggregation
for C1 (xinclude-style), it has got caching: but again,
it is behind current versions of Cocoon and requires
heavy changes to many files..

>I expect that I'm going about this all wrong. All I really want to do is
>call response.setHeader and then copy the XML with new PIs pointing it to
>the proper  XSL file. This is the XSP that I've written...
>
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:template match="/">
>    <xsl:processing-instruction
>name="cocoon-process">type="xsp"</xsl:processing-instruction>
>    <xsl:processing-instruction
>name="cocoon-process">type="xslt"</xsl:processing-instruction>
>    <xsl:processing-instruction
>name="xml-stylesheet">href="catalog-text.xsl"
>type="text/xsl"</xsl:processing-instruction>
>    <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
>      <page>
>        <xsp:logic> 
>          response.setHeader("Content-Disposition", "inline;
>filename=kluge.txt");
>        </xsp:logic>
>        <xsl:apply-templates/>
>      </page>
>    </xsp:page>
>  </xsl:template>
>  <xsl:template match="@*|*|text">
>    <xsl:copy-of select="."/>
>  </xsl:template>
></xsl:stylesheet>
>
>I'd really appreciate any pointers that would get me heading in the right
>direction.
>
>Cindy
>
>
>
>---------------------------------------------------------------------
>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: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org>
>
>




---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>