You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Carsten Ziegeler <cz...@sundn.de> on 2000/10/30 15:16:26 UTC

[C2]: Browser Selector Bug

Looking into the recent cvs source of C2, I saw that the BrowserSelectorFactory does not use it's configuration any more and is therefore very useless. Is this intended or has it only disappeared due to the Avalon/Xalan2 port? (If the second is true, should I reintegrate it?)

But what is even worse, I can't use any selector. If I write
....
	<map:select type="browser">
		<map:when test="mozilla"> 
			<map:transform src="mozilla.xsl"/>
		</map:when> 
		<map:otherwise>
			<map:transform src="other.xsl"/>
		</map:otherwise>
	</map:select>
.....
I get the following exception:

java.lang.NullPointerException
	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:917)
	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
	at org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator.generateCode(LogicsheetCodeGenerator.java:118)
	at org.apache.cocoon.components.language.markup.AbstractMarkupLanguage.generateCode(AbstractMarkupLanguage.java:296)
	at org.apache.cocoon.components.language.generator.ProgramGeneratorImpl.load(ProgramGeneratorImpl.java:193)
	at org.apache.cocoon.sitemap.Handler.run(Handler.java:152)
	at java.lang.Thread.run(Thread.java:484)

Is there anything wrong?

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================


Re: Browser Selector Bug

Posted by Berin Loritsch <bl...@infoplanning.com>.
----- Original Message ----- 
From: "Giacomo Pati" <Gi...@pwr.ch>
To: <co...@xml.apache.org>
Sent: Monday, October 30, 2000 1:32 PM
Subject: Re: Browser Selector Bug


> On Mon, Oct 30, 2000 at 03:41:18PM +0100, Carsten Ziegeler wrote:
> > Sorry, the first email wasn't finished when my mailer decided to mail it....(AI is everywhere)
> > 
> > > Berin Loritsch [mailto:bloritsch@infoplanning.com]
> > > 
> > > The selector pattern needs to be tested and debugged.
> > > Can you give me a sitemap that uses the selector pattern?
> > > Something really simple, and I can try to do something
> > > with it--since I am probably the one who broke it.
> > > 
> > OK, here is an example which worked weeks ago:

Ok.  I'm stumped.  I have the latest version from Cocoon, and as long as we don't have the
<map:when test="..."> construct, the sitemap compiles and builds.  When it fails, it is within
the Xerces parser, and in conjunction with XMLFilter objects.


Re: Browser Selector Bug

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Mon, Oct 30, 2000 at 03:41:18PM +0100, Carsten Ziegeler wrote:
> Sorry, the first email wasn't finished when my mailer decided to mail it....(AI is everywhere)
> 
> > Berin Loritsch [mailto:bloritsch@infoplanning.com]
> > 
> > The selector pattern needs to be tested and debugged.
> > Can you give me a sitemap that uses the selector pattern?
> > Something really simple, and I can try to do something
> > with it--since I am probably the one who broke it.
> > 
> OK, here is an example which worked weeks ago:
> 
>   <map:match pattern="hello.html">
>       <map:generate src="docs/samples/hello-page.xml"/>
> 	<map:select type="browser">
> 		<map:when test="explorer">
> 			<map:transform src="stylesheets/page/IE-html.xsl"/>
> 		</map:when>
> 		<map:when test="netscape">
> 			<map:transform src="stylesheets/page/NS-html.xsl"/>
> 		</map:when>
> 		<map:otherwise>
> 			<map:transform src="stylesheets/page/Unknown-html.xsl"/>
> 		</map:otherwise>
> 	</map:select>  
>       <map:transform src="stylesheets/page/simple-page2html.xsl"/>
>       <map:serialize type="html"/>
>    </map:match>

You don't even need to use different stylesheets for a test. Use the 
same <map:transform> for every <map:when> and <map:otherwise>.

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1  856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1  856 2201
Hintereichenstrasse 7                     Mobil: +41 (0)78 759 7703
CH-8166 Niederweningen                    Mailto:Giacomo.Pati@pwr.ch
                                          Web:   http://www.pwr.ch

Re: [C2]: Patch for XSL Caching of the XalanTransformer

Posted by Paul Russell <pa...@luminas.co.uk>.
On Tue, Nov 07, 2000 at 05:06:22PM +0100, Carsten Ziegeler wrote:
> finally I had time for it: Attached is a patch for the
> XalanTransformer for file caching of XSL files. The caching
> mechanism simply looks if the stylesheet in question is a
> local file. 
> If it is a local file, the stylesheet is cached together with
> the current system time. So when this stylesheet is retrieved
> out of the cache the next time, the caching time can be
> compared with the last modified time of the file.  If the
> stylesheet is not a local file it is always cached, as it was
> the current behaviour. In my opinion such stylesheets should
> never be cached, but that might be another patch...

Looks sane from here. I'd rather we were caching an inner class
than an array though, to be honest. Don't think it'd be a speed
penalty, and it'd certainly be easier to read...

We also need to develop some central object caching architecture
for Cocoon. Is this in Avalon yet?

Paul
-- 
Paul Russell                               <pa...@luminas.co.uk>
Technical Director,                   http://www.luminas.co.uk
Luminas Ltd.

[C2]: Patch for XSL Caching of the XalanTransformer

Posted by Carsten Ziegeler <cz...@sundn.de>.
Hi,

finally I had time for it: Attached is a patch for the XalanTransformer for file caching of XSL files. The caching mechanism simply looks if the stylesheet in question is a local file. 

If it is a local file, the stylesheet is cached together with the current system time. So when this stylesheet is retrieved out of the cache the next time, the caching time can be compared with the last modified time of the file.
If the stylesheet is not a local file it is always cached, as it was the current behaviour. In my opinion such stylesheets should never be cached, but that might be another patch...


Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================

Re: [C2]: XalanTransformer and Caching

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Mon, Oct 30, 2000 at 04:12:13PM +0100, Carsten Ziegeler wrote:
> The recent version (current cvs of C2) of the XalanTransformer caches every stylesheet. As this improves performance and is very useful for production sites this is very annoying for development circles.
> 
> Are there any plans for improving the caching mechanism? Or for a flag which turns caching on/off?
> 
> I can implement a caching mechanism which works for local files (the simple modified since approach), but how a distant files handled?

Would be cool for a start :)

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1  856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1  856 2201
Hintereichenstrasse 7                     Mobil: +41 (0)78 759 7703
CH-8166 Niederweningen                    Mailto:Giacomo.Pati@pwr.ch
                                          Web:   http://www.pwr.ch

Re: [C2]: Patch for XalanTransformer and Caching

Posted by Stefano Mazzocchi <st...@apache.org>.
Carsten Ziegeler wrote:
> 
> > Stefano Mazzocchi wrote:
> >
> > > Or for a flag which turns caching on/off?
> >
> > yep.
> >
> Included is a patch for the XalanTransformer which allows turning on/off the cache using a configuration in the sitemap:
> 
> <map:transformer name="xslt" src="org.apache.cocoon.transformation.XalanTransformer">
>         <use-cache map:value="true"/>  <!-- true: turns on cache, false: off -->
> </map:transformer>
> 
> The default is "true", so without a configuration the transformer has the same behaviour than before.
> 
> > my solution would be:
> >
> > 1) if you use external entities, forget it, the cache will not be able
> > to reload
> Shoudn't this never be cached?

no, this will be cached as if the entity was included "inside" the
document... if you touch the external file it doesn't work.

Yes, I know you could use some SAX events to go around this, but this is
also to force you using XInclude instead of external entities that
require a DTD (and DTDs are bad!!)

> > 2) if you use the XPath document() fuction forget it as well, the cache
> > won't be able to tell if it needs to reload.
> So no caching either, correct?

No, again, it's up to the Transformer implementation to do this, but I
won't concentrate my efforts on providing such touching methods for the
document() function (that, again, you should *NOT* be using!!!)
 
-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------



[C2]: Patch for XalanTransformer and Caching

Posted by Carsten Ziegeler <cz...@sundn.de>.
> Stefano Mazzocchi wrote:
> 
> > Or for a flag which turns caching on/off?
> 
> yep.
>  
Included is a patch for the XalanTransformer which allows turning on/off the cache using a configuration in the sitemap:

<map:transformer name="xslt" src="org.apache.cocoon.transformation.XalanTransformer"> 
	<use-cache map:value="true"/>  <!-- true: turns on cache, false: off -->
</map:transformer>

The default is "true", so without a configuration the transformer has the same behaviour than before.

> my solution would be:
> 
> 1) if you use external entities, forget it, the cache will not be able
> to reload
Shoudn't this never be cached?
> 2) if you use the XPath document() fuction forget it as well, the cache
> won't be able to tell if it needs to reload.
So no caching either, correct?

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================

Re: [C2]: XalanTransformer and Caching

Posted by Stefano Mazzocchi <st...@apache.org>.
Carsten Ziegeler wrote:
> 
> The recent version (current cvs of C2) of the XalanTransformer caches every stylesheet. As this improves performance and is very useful for production sites this is very annoying for development circles.
> 
> Are there any plans for improving the caching mechanism?

You bet. :)

> Or for a flag which turns caching on/off?

yep.
 
> I can implement a caching mechanism which works for local files (the simple modified since approach), but how a distant files handled?

my solution would be:

1) if you use external entities, forget it, the cache will not be able
to reload
2) if you use the XPath document() fuction forget it as well, the cache
won't be able to tell if it needs to reload.
3) the cache will reload only on XInclude-type inclusion.

Comments welcome.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------



[C2]: XalanTransformer and Caching

Posted by Carsten Ziegeler <cz...@sundn.de>.
The recent version (current cvs of C2) of the XalanTransformer caches every stylesheet. As this improves performance and is very useful for production sites this is very annoying for development circles.

Are there any plans for improving the caching mechanism? Or for a flag which turns caching on/off?

I can implement a caching mechanism which works for local files (the simple modified since approach), but how a distant files handled?

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================


AW: Browser Selector Bug

Posted by Carsten Ziegeler <cz...@sundn.de>.
Sorry, the first email wasn't finished when my mailer decided to mail it....(AI is everywhere)

> Berin Loritsch [mailto:bloritsch@infoplanning.com]
> 
> The selector pattern needs to be tested and debugged.
> Can you give me a sitemap that uses the selector pattern?
> Something really simple, and I can try to do something
> with it--since I am probably the one who broke it.
> 
OK, here is an example which worked weeks ago:

  <map:match pattern="hello.html">
      <map:generate src="docs/samples/hello-page.xml"/>
	<map:select type="browser">
		<map:when test="explorer">
			<map:transform src="stylesheets/page/IE-html.xsl"/>
		</map:when>
		<map:when test="netscape">
			<map:transform src="stylesheets/page/NS-html.xsl"/>
		</map:when>
		<map:otherwise>
			<map:transform src="stylesheets/page/Unknown-html.xsl"/>
		</map:otherwise>
	</map:select>  
      <map:transform src="stylesheets/page/simple-page2html.xsl"/>
      <map:serialize type="html"/>
   </map:match>

It uses the hello exmaple from cocoon and the stylesheets attached. As I can't test it by now I hope everything is included correctly. If not, give me a hint.

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de 
================================================================


AW: Browser Selector Bug

Posted by Carsten Ziegeler <cz...@sundn.de>.
> Berin Loritsch [mailto:bloritsch@infoplanning.com]
> 
> The selector pattern needs to be tested and debugged.
> Can you give me a sitemap that uses the selector pattern?
> Something really simple, and I can try to do something
> with it--since I am probably the one who broke it.
> 
OK, here is an example which worked weeks ago:

> ----- Original Message -----
> From: "Carsten Ziegeler" <cz...@sundn.de>
> To: <co...@xml.apache.org>
> Sent: Monday, October 30, 2000 9:16 AM
> Subject: [C2]: Browser Selector Bug
> 
> 
> Looking into the recent cvs source of C2, I saw that the 
> BrowserSelectorFactory does not use it's configuration any more and is
> therefore very useless. Is this intended or has it only 
> disappeared due to the Avalon/Xalan2 port? (If the second is 
> true, should I
> reintegrate it?)
> 
> But what is even worse, I can't use any selector. If I write
> ....
> <map:select type="browser">
> <map:when test="mozilla">
> <map:transform src="mozilla.xsl"/>
> </map:when>
> <map:otherwise>
> <map:transform src="other.xsl"/>
> </map:otherwise>
> </map:select>
> .....
> I get the following exception:
> 
> java.lang.NullPointerException
> at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:917)
> at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
> at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
> at 
> org.apache.cocoon.components.language.markup.LogicsheetCodeGenerat
> or.generateCode(LogicsheetCodeGenerator.java:118)
> at 
> org.apache.cocoon.components.language.markup.AbstractMarkupLanguag
> e.generateCode(AbstractMarkupLanguage.java:296)
> at 
> org.apache.cocoon.components.language.generator.ProgramGeneratorIm
> pl.load(ProgramGeneratorImpl.java:193)
> at org.apache.cocoon.sitemap.Handler.run(Handler.java:152)
> at java.lang.Thread.run(Thread.java:484)
> 
> Is there anything wrong?
> 
> Regards
> Carsten Ziegeler
> 
> Open Source Group              sunShine - Lighting up e:Business
> ================================================================
> Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
> www.sundn.de                           mailto:cziegeler@sundn.de
> ================================================================
> 

Re: Browser Selector Bug

Posted by Berin Loritsch <bl...@infoplanning.com>.
The selector pattern needs to be tested and debugged.
Can you give me a sitemap that uses the selector pattern?
Something really simple, and I can try to do something
with it--since I am probably the one who broke it.

----- Original Message -----
From: "Carsten Ziegeler" <cz...@sundn.de>
To: <co...@xml.apache.org>
Sent: Monday, October 30, 2000 9:16 AM
Subject: [C2]: Browser Selector Bug


Looking into the recent cvs source of C2, I saw that the BrowserSelectorFactory does not use it's configuration any more and is
therefore very useless. Is this intended or has it only disappeared due to the Avalon/Xalan2 port? (If the second is true, should I
reintegrate it?)

But what is even worse, I can't use any selector. If I write
....
<map:select type="browser">
<map:when test="mozilla">
<map:transform src="mozilla.xsl"/>
</map:when>
<map:otherwise>
<map:transform src="other.xsl"/>
</map:otherwise>
</map:select>
.....
I get the following exception:

java.lang.NullPointerException
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:917)
at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
at org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator.generateCode(LogicsheetCodeGenerator.java:118)
at org.apache.cocoon.components.language.markup.AbstractMarkupLanguage.generateCode(AbstractMarkupLanguage.java:296)
at org.apache.cocoon.components.language.generator.ProgramGeneratorImpl.load(ProgramGeneratorImpl.java:193)
at org.apache.cocoon.sitemap.Handler.run(Handler.java:152)
at java.lang.Thread.run(Thread.java:484)

Is there anything wrong?

Regards
Carsten Ziegeler

Open Source Group              sunShine - Lighting up e:Business
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                           mailto:cziegeler@sundn.de
================================================================


Re: [C2]: Browser Selector Bug

Posted by Giacomo Pati <Gi...@pwr.ch>.
On Mon, Oct 30, 2000 at 03:16:26PM +0100, Carsten Ziegeler wrote:
> Looking into the recent cvs source of C2, I saw that the BrowserSelectorFactory does not use it's configuration any more and is therefore very useless. Is this intended or has it only disappeared due to the Avalon/Xalan2 port? (If the second is true, should I reintegrate it?)
> 
> But what is even worse, I can't use any selector. If I write
> ....
> 	<map:select type="browser">
> 		<map:when test="mozilla"> 
> 			<map:transform src="mozilla.xsl"/>
> 		</map:when> 
> 		<map:otherwise>
> 			<map:transform src="other.xsl"/>
> 		</map:otherwise>
> 	</map:select>
> .....
> I get the following exception:
> 
> java.lang.NullPointerException
> 	at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:917)
> 	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
> 	at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:371)
> 	at org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator.generateCode(LogicsheetCodeGenerator.java:118)
> 	at org.apache.cocoon.components.language.markup.AbstractMarkupLanguage.generateCode(AbstractMarkupLanguage.java:296)
> 	at org.apache.cocoon.components.language.generator.ProgramGeneratorImpl.load(ProgramGeneratorImpl.java:193)
> 	at org.apache.cocoon.sitemap.Handler.run(Handler.java:152)
> 	at java.lang.Thread.run(Thread.java:484)

This is the point where I'm now without an idea what to do next. 
You won't get that error when you test your sitemap with the 
sitemap.xsl on the command line (using org.apache.xalan.xslt.Process). 
Is there anybody more familiar with Xerces/Xalan who can help here?
 
Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1  856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1  856 2201
Hintereichenstrasse 7                     Mobil: +41 (0)78 759 7703
CH-8166 Niederweningen                    Mailto:Giacomo.Pati@pwr.ch
                                          Web:   http://www.pwr.ch