Re: Cocoon Forms 2.1 - One of two fields required

2009-02-25 Thread Tobia Conforto

Merico Raffaele wrote:

Tobia Conforto wrote:
In Cocoon 2.1, Forms, how do I require the user to fill at least  
one out of two (or more) fields?
For example, I might have the 'phone' and 'mobile' fields. I want  
the user to fill at least one of them. Where should I put such a  
validator?


I use the following construct to do that: After all relevant form  
fields I add a form field (in my case id=form-validation) that is  
not displayed in the form but invokes a javascript validation  
function.


Thank you. Using a separate widget just to validate the collective  
requirements of other widgets does in fact work.


I'm wondering if it is the only solution. It doesn't seem very clean.

-Tobia

-
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org



Re: Cocoon Forms 2.1 - One of two fields required

2009-02-25 Thread Tobia Conforto

Wolfgang Ruelfing wrote:

Hello,
you can put the general form validation code straight into the form  
element


Thank you!  This is exactly what I was looking for.

I had tried to do something like this on my own, but I made an  
critical mistake: I set the validation error on the form itself,  
instead of one of its children, and it didn't work. Your solution  
works very well.


Here are a couple of improvements: I don't set the composite error  
if any of the fields already have a more basic error (because I don't  
want to override it with mine); and whenever the state of this  
composite validation error changes, I push both fields on to the  
user (otherwise I would get stale error icons on the browser, using  
Ajax.)  Can you please comment on my implementation?  Is there a  
simpler solution?



form xmlns=http://apache.org/cocoon/forms/1.0#definition;
on-create
  javascript

widget.setAttribute('phonemobile_valid', true);

  /javascript
/on-create
validation
  javascript![CDATA[

var phone = widget.lookupWidget('/phone'),
mobile = widget.lookupWidget('/mobile'),
old_valid = widget.getAttribute('phonemobile_valid'),
new_valid = true;

/* we require the user to enter his landline and/or mobile phone;
 * if both fields are without a valid value AND without a  
temporary,

 * invalid value, set an error on both
 */
if (! phone.getValue()  ! mobile.getValue()
 ! phone.getValidationError()
 ! mobile.getValidationError()) {
  var message = Please enter your landline and/or mobile phone;
  phone.setValidationError(new ValidationError(message, false));
  mobile.setValidationError(new ValidationError(message, false));
  new_valid = false;
}

/* if this composite validation state has changed since last time,
 * push both fields to the browser
 */
if (old_valid != new_valid) {
  widget.addWidgetUpdate(phone);
  widget.addWidgetUpdate(mobile);
}

widget.setAttribute('phonemobile_valid', new_valid);
return new_valid;

  ]]/javascript
/validation
widgets
  ...


-Tobia

-
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org



Cocoon Forms 2.1 - One of two fields required

2009-02-16 Thread Tobia Conforto

Hello

In Cocoon 2.1, Forms, how do I require the user to fill at least one  
out of two (or more) fields?


For example, I might have the 'phone' and 'mobile' fields. I want the  
user to fill at least one of them, possibly both, and I don't want the  
form to validate if they're both empty.


I've tried to add the validator to one or the other, but it seems the  
wrong place to put it (Cocoon forms have a strict hierarchical  
structure) and in fact the behaviour with ajax and browser-update is  
buggy.  I've tried to add the validator to the form widget itself, but  
then the error message is not picked up by the jx template, and the  
user is stuck without knowing what is wrong.


Where should I put such a validator?


Tobia

-
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org



Re: Failing Mysql JDBC connections

2008-06-20 Thread Tobia Conforto

I wrote:
As soon as this happens, all pages being worked on at the same time  
fail with such messages as:


SQLTransformer.Query: Failed to execute query [...]
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No  
operations allowed after connection closed.


For the record, this was caused by a deadlock problem, where many  
simultaneous requests would get a connection for their SQLTransformer,  
exhausting the connection pool, and then get stuck requesting more  
connections through an input module I wrote myself, before the  
SQLTransformers had a chance to return the connections to the pool.


I worked around the problem by uncapping the database connections:

pool-controller min=100 max=150 max-strict=false/

Now I'd like to know how to avoid the deadlock condition in the first  
place, with capped connections, but I'm not sure it can be done.  I've  
asked the dev list.



Tobia

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



Failing Mysql JDBC connections

2008-06-13 Thread Tobia Conforto

Hello

I have a big problem right now: my Cocoon MySql connections have  
started to fail randomly, and when they do they bring down all pages  
currently being generated.


My gut feeling is that it's a synchronization problem, some race  
condition in Cocoon or in the Mysql connector.  This is because the  
failures happen on random pages, that usually render correctly, and  
also because the higher the concurrency of http requests, the higher  
the rate of failure.  Apparently I didn't stress-test the server  
configuration with a high enough concurrency, before going online.


Here is what I see in the logs:

SQLTransformer.Query: Failed to execute query [...]
com.mysql.jdbc.CommunicationsException: Communications link failure  
due to underlying exception:

java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at  
com 
.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java: 
113)

...
	(other mysql jdbc classes follow, then excalibur, then the  
SQLTransformer)


Looking at a network dump, I can see a series of Mysl protocol QUIT  
messages that tear down all tcp connections to the Mysql server.  It  
happens simultaneously on ALL tcp connections and I can see the Jdbc  
connector sending appropriate QUIT messages to the server, so it's not  
a hard connection reset, coming from the network stack.  The Mysql  
server is on localhost, so it's not a network problem.


As soon as this happens, all pages being worked on at the same time  
fail with such messages as:


SQLTransformer.Query: Failed to execute query [...]
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No  
operations allowed after connection closed.


or:

ErrorHandlerHelper: Failed to process pipeline
java.lang.NullPointerException
at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:966)
...

or other such NPE inside the JDBC driver, on lines where the driver is  
trying to use its own iternal connection object (which now appears to  
be null.)


After that, the database connections are reopened and Cocoon proceeds  
normally, but after a few of these error iterations it all hangs.  
(Memory leak? I don't know.)


I'm using Cocoon 2.1.10 and 2.1.11 (same results) and MySql connector  
3.1.14 and 5.0.6 (same results.)  I'm using SQLTransformer with  
prepared statements (sql:in-parameter) and a few custom actions of  
mine which use JDBI prepared statements.  The server runs Debian  
stable with its latest Sun Java 1.5.0 and Mysql 5.0.32 packages.


I cannot use the 5.0.8 or 5.1.6 connectors because they don't work  
with Cocoon 2.1 (a strange bug with column aliases, aka. SELECT  
column AS alias, worthy of another thread.)



Has anybody seen anything like this before?  Do you want me to try and  
build a minimal example that shows the error?  Could it be the  
prepared statements' fault?


Any help will be appreciated.


Tobia

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



Re: Old Cocoon query

2008-04-17 Thread Tobia Conforto

On 17 Apr 2008, Derek Hohls wrote:

in this mail:
http://marc.info/?l=xml-cocoon-usersm=119996793507680w=2
you gave guidance on how to post-process escaped tags from a  
database.  However, when I implement it, it also strips out all the  
sql:field tags as well, leaving just text inside the sql:row  
tags.  How can the code be modified not to lose the nested tags?


My fault for posting untested code!
Try modifying the first XSLT, unescape-pre.xsl, like this:
(still untested)


xsl:template match=sql:row/*[not(self::sql:rowset)
and (contains(., 'amp') or contains(., 'lt;'))]
  xsl:copy
unescape
  xsl:copy-of select=node()/
/unescape
  /xsl:copy
/xsl:template

xsl:template match=@*|node() priority=-1
  xsl:copyxsl:apply-templates select=@*|node()//xsl:copy
/xsl:template


Tobia

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



Re: Redirect to GET, strange bug

2008-04-01 Thread Tobia Conforto

[EMAIL PROTECTED] wrote:
FYI: Cocoon's redirects usually escape from the current processing.  
The redirect is sent to the browser, but the request may not have  
been processed.  That does not appear to be what you need.


I don't quite understand what you mean here.


The Redirect from submitting a Form cannot be internal to Cocoon (or  
any web engine).


Of course.
In fact I'm issuing a global, client-side redirect (no cocoon:  
protocol and a true isGlobal argument to cocoon.redirectTo) and that  
part works flawlessly, regardless of the errors I get in my logs.  The  
problem is, what is causing those errors?



Vadim Gritsenko wrote:
This redirect URL does not seem to be correct: should start with '?'  
if passing continuation id as parameter or have '/' instead of '='  
if passing continuation id in URL path.



We all know URLs can be pretty arbitrary in Cocoon... this is not even  
what my url looks like, it was just an example.



Hm, what is this exit() method? I don't see it defined neither in  
Cocoon 2.1 nor 2.2.  To terminate script processing and send  
redirect to browser you should be using suicide method.



AFAIK cocoon.exit() is the recommended way to call FOM_Cocoon.suicide()

It's mentioned here http://cocoon.apache.org/2.1/userdocs/flow/api.html#exit 
 (while suicide isn't) and its implementation is:


FOM_Cocoon.prototype.exit = function() {
FOM_Cocoon.suicide();
}

In fact, using FOM_Cocoon.suicide() yields the same results as  
cocoon.exit(), that is, ProcessingException: Attempted to process  
incomplete pipeline.


Do you have any idea what's causing this message?

Who is attempting to process which incomplete pipeline?  I'm issuing a  
global, client-side redirect, and stopping the flow.  Why is Cocoon  
complaining?



Also, it is often a good idea to invalidate the form processing  
continuation tree, to free up memory and--even if user manages to  
submit the form again--he will receive 404.



Interesting.  How do I do this?


Tobia

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



Re: Multiple or single cocoon instances

2008-03-31 Thread Tobia Conforto

Hi

In our (limited) experience, here are pros and cons of using a single  
instance:

 + better use of server resources (RAM, CPU) this is quite important;
 + single global configuration (servlet container, Java VM, Apache or  
other frontend...)
 + being forced to deploy global updates (to Cocoon configuration,  
custom components, etc.) on all apps (projects), this is good for  
security and performance updates;
 - slower, more expensive global updates (you have to test all apps  
on the same Cocoon)
 - sometimes you have to go through loops to introduce new features  
while maintaining compatibility with older apps.


All in all, we are quite happy with a hybrid approach: we keep all  
apps in the same Cocoon, until we need such new features or such a  
different Cocoon configuration to warrant a branch to a new major  
version of our configuration.  So we have something like 30 apps  
split among 3 Cocoons.  The next update to one of the older projects  
will trigger a switch to the newest Cocoon configuration, and so on.


HTH

Tobia

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



NullPointerException without a stacktrace

2008-03-27 Thread Tobia Conforto
Does anybody occasionally get a NullPointerException in the logs,  
without a matching stacktrace?


Like this:

$date ERROR $url [sitemap.handled-errors] ErrorHandlerHelper: Sitemap:  
error calling function $flowscript_func

at map:call - $sitemap_path
java.lang.NullPointerException

And that's it, no Java stacktrace, no flowscript line number,  
nothing.  I checked Jetty's standard error too, nothing there.


I'm using Cocoon 2.1.10, and I have %{rootThrowable} in logkit.xconf  
(which is the default.)  Do you think %{throwable} would make any  
difference?  I should mention that this only happens on the production  
server (of course...) so I can't debug as much as I'd like to.


Could this be a bug in one of my components?  I mean, can a bug in a  
custom component (I've written actions, readers, transformers, and a  
input module) cause a bare NPE, without a stacktrace?  Can a bug in  
flowscript (such as calling null Java objects, or calling them the  
wrong way) cause it?



Tobia

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



Re: AJAX forms: returning to previous page after submit using Apples

2008-03-10 Thread Tobia Conforto

Victor Oomens wrote:

How can I return to another page after a user completes an ajax form?


Put a cocoon.redirectTo(...) after your showForm

See http://cocoon.apache.org/2.1/userdocs/flow/api.html


Tobia

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



Re: Sitemap pipelines

2008-03-10 Thread Tobia Conforto

Alec Bickerton wrote:
I need the pipeline to return to the pipeline in the global sitemap  
if nothing matches so that the default matchers will get hit.


You need to issue an internal redirect to the parent sitemap.

Assuming /default is a (fake) path that in the parent sitemap falls  
through to the default matcher, without entering ANY sub-pipeline,  
then you can put this at the end of your sub-sitemaps (last item after  
all matchers, before closing the last pipeline)


map:redirect-to uri=cocoon://default/

The heart of this is the double-slash cocoon: protocol, that will  
redirect internally (without sending a redirect to the browser) to the  
root sitemap.



Tobia

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



Re: Is there an url wildcard selector (equivalent)

2008-03-10 Thread Tobia Conforto

Rainer Pruy wrote:
wildcard *matcher* is one of the most used components with cocoon,  
I'd reckon. But what to do, when one needs to handle X/c/** and X/**  
(excluding X/c/**) different? At least if the contained components  
are not final (serialize, read)


Cocoon has no URI selector, wildcard or otherwise, probably as some  
kind of deliberate design choice.


This kind of problem is easily solved with Perl-compatible regexps,  
but Cocoon uses the inefficient and less powerful Jakarta Regexp  
package (this is a big gripe of mine, btw) probably for hysterical  
raisins.


If it used the native java.util.regex you could match on ^X/c/ and  
on ^X/(?!c/), but alas you're limited to egrep-style regular  
expressions, which lack negative lookaheads.


If you don't like the nested simple selector solution, or the  
resources solution, you will have to write your own matcher or  
selector.  Which is not hard at all, by the way.  Just extend  
AbstractPreparableMatcher or AbstractSwitchSelector, put your class in  
WEB-INF/classes and give it a short name in your sitemap.xconf.



Tobia

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



Re: Using xsl variables in javascript

2008-02-14 Thread Tobia Conforto

Lincoln Mitchell wrote:

I simple need to convert this inline javascript:

script type=text/javascript
  function myFunction(){
  xsl:choose
xsl:when test= $myParam='x'
  alert('x')
/xsl:when
  /xsl:choose
  }
/script

…to an external javascript file like:

function myFunction(){
  if ($myParam='x'){
alert('x')
  }
}


I don't think you have execution times very clear.  XSLT code runs on  
your server at pipeline execution time, before or during page  
generation.  Client javascript code runs in the client browser at page  
rendering time, after page generation and transmission.  This means  
that whatever comes out of your pipeline must be well-formed HTML and/ 
or Javascript that will run on the browser, without access to any XSLT  
or Cocoon variables.  In fact, by the time the generated HTML reaches  
the browser, the variables used in your XSLT won't exist anymore.


Nevertheless, it might be that what you're after is simply this:

script type=text/javascript
  var myParam = xsl:value-of select=$myParam/;
/script

Notice the extra quotation marks around the value-of: this XSLT code  
is generating a HTML script tag containing Javascript code that, when  
run by the browser, will declare a global string variable called  
myParam.  From that moment on, every piece of Javascript code run on  
the browser will have access to that global variable.


Also, this is generic web programming matter, not exactly related to  
Cocoon.



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



Re: Doing string operations over sitemap values

2008-02-14 Thread Tobia Conforto

Nacho (Derecho.com) wrote:

* I have this URL http://localhost:8080/b/menores-de-edad;
* In sitemap i have a match like b/**
* I need to do replace - in {1} to spaces
* I do this using an input module inheriting from  
AbstractJXPathModule, and using a xpath like expression,  
{request:translate('{1}','-','')}


I would write a custom input module that can be called safely like this:
{translate:-: :{1}}
It can be implemented using basic java.lang.String methods.

I think your solution doesn't quote the argument correctly and is  
susceptible to JX code injection or other problems.

For example the user might go to: 
http://localhost:8080/b/hello',nasty.java.call(),'world
If I'm not mistaken, the ' after hello would close the Jx string and  
damage would ensue.



Tobia

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



Re: Doing string operations over sitemap values

2008-02-14 Thread Tobia Conforto

Joerg Heinicke wrote:

Nacho (Derecho.com) wrote:

{request:translate('{1}','-','')}


the user might go to: http://localhost:8080/b/hello',nasty.java.call(),'world


It's JXPath, not JXTemplate. Does it evaluate Java calls at all?
If your example really works, http://localhost:8080/b/nasty.java.call() 
 will as well.


To be honest I don't know what JXPath can and cannot evaluate
(Java calls? any extensions to XPath? Java objects? request and  
session objects?)


I just saw some bad/unusual quotation  
{request:translate('{1}','-','')} and I thought I'd alert against  
possible problems. But maybe I'm wrong.



Tobia

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



Re: REPOST: Losing request parameters during form error

2008-02-14 Thread Tobia Conforto

Derek Hohls wrote:
upgrading on the servers is, unfortunately, a much longer and time- 
consuming process.  I guess I was hoping it was not a bug.


Maybe it's not.  Can you post a minimal example (simple form with  
maybe 1 widget) and minimal sitemap that exhibits the problem?



Tobia

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



Re: MySQL Year vs CForms Date

2008-02-14 Thread Tobia Conforto

Derek Hohls wrote:
if I use MySQL Year column and Cocoon Forms integer type  
together, then the forms validator complains that the widget is not  
a date type.


This part I don't understand.  Are you trying to apply some sort of  
date widget or date formatting or date validation to the integer  
field?  (You shouldn't.)  What component complains that the widget is  
not a date type?  Does a simple integer text field work?



Tobia

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



Re: Cache Browser

2008-02-12 Thread Tobia Conforto

[EMAIL PROTECTED] wrote:
The reload (Mozilla) or refresh (MSIE) command should force  
browsers to ignore cache and retrieve the entire page from the  
server. This is not always effective.


This reminds me, Shift+Reload forces the browser to refresh the entire  
page, including all dependencies, I believe on both browsers.  I use  
it all the time while developing, so I forgot to mention it.



Tobia

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



Re: Cache Browser

2008-02-11 Thread Tobia Conforto

alexandre mazouz wrote:
I have 2 web applcations A and B in localhost with the same adress  
and ports (127.0.0.1:8080\) in 2 server jetty (J1 and J2).

i close A and launch B i have A.
The only way to have B is to clean the cache of the browser.


You might try to define an action that sets the relevant HTTP headers  
to prevent caching in the browser:


	map:action name=no-cache  
src=org.apache.cocoon.acting.HttpCacheAction/


and call it at the beginning of your pipelines (even before any  
map:match, if you want it to affect every request):


map:act type=no-cache/

Although in your case I would simply change the port of one of your  
servers, as the browser cache has its uses.



Tobia


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



Re: Attempting to Install Cocoon-2.2

2008-02-04 Thread Tobia Conforto

[EMAIL PROTECTED] wrote:

FILE: mvn.bat
== Fix Bad command or filename
REM if %HOME% ==  (set HOME=%HOMEDRIVE%%HOMEPATH%)
SET HOME=C:\apache\maven-2.0.8

== Fix Invalid switch
REM exit /B %ERROR_CODE%


I haven't used Windows much (fortunately) but I have the feeling this  
script was written for NT's cmd.exe instead of 98's command.com.  In  
any case it seems to be an installation and configuration issue.  As  
you pointed out, Maven is pure Java and should work fine once properly  
installed.



I am teaching HTML, CSS, and XSL (=Cocoon) to people using Win98  
PCs.  If Maven2 will not run on Win98, neither will Cocoon-2.2.   
I'll use Cocoon-2.1 for the class.


I'm sure I've seen people mention on this mailing list that Maven is  
by no means necessary to compile, install, or use Cocoon 2.2.  It's  
merely a convenience.



Tobia

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



Re: Cforms fd:assert validation

2008-02-04 Thread Tobia Conforto

Carlos Martínez wrote:

I use the language from the page
http://cocoondev.org/xreporter/docs/core/exprlang.html
and it seems that work properly.


Yes, that link comes straight from the Most obscure and valuable  
subfolder of my Cocoon bookmarks folder :-)



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



Re: Cforms fd:assert validation

2008-02-02 Thread Tobia Conforto

Carlos Martínez wrote:

I don't know how the expression of the assert should be.


I believe this is the language used in fd:assert, at least in Cocoon  
2.1:


http://cocoondev.org/xreporter/docs/core/exprlang.html

Don't ask me why...


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



Re: Cforms and Character Encoding

2008-01-23 Thread Tobia Conforto

Peter Sparkes wrote:

The problem turned out to be in web.xml
I amended
  param-nameform-encoding/param-name
  param-valueISO-8859-1/param-value
To
  param-nameform-encoding/param-name
  param-valueUTF-8/param-value
and now everything is in UTF-8 and works properly


Just a word of caution: make sure you test your forms on every  
possible web browser.

I've had trouble with this setting in the past.


Tobia

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



Re: keypress events

2008-01-18 Thread Tobia Conforto

Edward Elhauge wrote:
I would like some guidance on what the best way is to attach an  
'onkeypress' event handler to a Cocoon CForm Widget?
My use case is that I want to set a 'form dirty' flag as users type  
data into my forms. I've been using the 'fd:on-value-changed'  
handler for that purpose but it doesn't catch the case where a user  
types data into a field and then directly clicks on a button that  
would exit the Web page.


I've been having a similar problem:
- text field (product quantity) with on-change that triggers update of  
the totals

- on-change fires only when the user leaves the text field
- if the user jumps directly to the submit button, the two ajax  
requests collide and bad things happen (mostly the change to the text  
field is lost, but I've seen errors too)


I haven't solved it yet.


Tobia

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



Re: REPOST: HTML Tags from a database field

2008-01-10 Thread Tobia

Derek Hohls wrote:

Tobia wrote:
I use the HTMLTransformer for that purpose, with a couple of XSLT  
stylesheets before and after it.  The first one writes unescape  
tags around each piece of escaped  HTML.  Then the HTMLTransformer  
is instructed to only transform text nodes inside those tags.   
Finally a second piece of XSLT gets rid of the unescape tags  
along with the fake body and html inserted by the transformer,  
and does a bit of magic with amp; and lt; characters




Whew!  Sounds like a lot of work for what I thought would be a  
simple config issue.   Any chance you could make the stylesheets  
available - maybe upload them to the wiki?


It's not much work really.

First identify the text nodes that need unescaping and wrap them in  
unescape tags.
For me that was all text nodes under a field tag, containing either an  
 or a :


xsl:template match=sql:row/*[not(self::sql:rowset)]
  xsl:choose
xsl:when test=contains(., 'amp') or contains(., 'lt;')
  unescape
xsl:copy-of select=node()/
  /unescape
/xsl:when
xsl:otherwise
  xsl:copy-of select=node()/
/xsl:otherwise
  /xsl:choose
/xsl:template

xsl:template match=@*|node() priority=-1
  xsl:copyxsl:apply-templates select=@*|node()//xsl:copy
/xsl:template


Then put it in the pipeline followed by the HTML transformer:

map:transform src=unescape-pre.xsl
map:transform type=html
  map:parameter name=tags value=unescape/
/map:transform
map:transform src=unescape-post.xsl


The latter XSLT cleans up unnecessary elements:

xsl:template match=unescape
  xsl:apply-templates select=html/body/node()/
/xsl:template

xsl:template match=@*|node() priority=-1
  xsl:copyxsl:apply-templates select=@*|node()//xsl:copy
/xsl:template


In the last step I also needed to replace  with amp; and   
with lt; (Java string notation) in all text nodes under unescape,  
by calling a utility Java function from within XSLT. But that's not an  
elegant solution and is probably related to my particular pipeline  
setup, so I won't bother you with the details unless you have the same  
problem.



Tobia

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



Re: Proper way to cache pipelines with SQL Transformer?

2008-01-10 Thread Tobia

Peter Wyngaard wrote:
The external pipelines that invoked these internal pipelines with a  
cocoon: URL passed their request parameters along.


This happens because a non-raw internal request (cocoon: schema) does  
not create a new Request object (or RequestWrapper or something like  
that) and it is actually quite a useful property.


For example, suppose you need to gather some data about the request  
not explicitly present in the request itself.  Maybe you need to issue  
a set of queries based on the URI path, to obtain one or more IDs of  
the objects being referred to, or of the user making the request, or  
some such.


Then you would like to store those IDs and misc attributes somewhere  
and access them during the rest of the request processing, however  
complex that might be.  I find request attributes (don't confuse with  
parameters) to be an excellent place for this sort of thing.


They live in Cocoon's request object, so they have the same lifetime  
of the initial HTTP request.  Which happens to be less than that of  
the session, but more than the internal sub-request, as an external  
request might generate many internal redirects and Cincludes, all  
using the cocoon: schema.  Unless you purposefully make a raw sub- 
request, and until the initial request processing is over, all sub- 
requests will be able to see the request attributes, because they  
share the request object.



HTH
Tobia

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



Re: REPOST: HTML Tags from a database field

2008-01-09 Thread Tobia

Derek Hohls wrote:
I am using the SQLTransformer from Cocoon 2.1.8 to extract data from  
text fields in a database.  At present, tags are being returned by  
the transformer (i.e. before any downstream alteration) as  
lt;tagsgt;



I use the HTMLTransformer for that purpose, with a couple of XSLT  
stylesheets before and after it.


The first one writes unescape tags around each piece of escaped  
HTML.  Then the HTMLTransformer is instructed to only transform text  
nodes inside those tags (by passing it a parameter name=tags  
value=unescape/.)  Finally a second piece of XSLT gets rid of the  
unescape tags along with the fake body and html inserted by the  
transformer, and does a bit of magic with amp; and lt; characters.



Tobia

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



Re: Cached AbstractReader

2007-12-21 Thread Tobia Conforto
Jon Evans wrote:
 How would I have made it work as a Configurable reader? I had this in
 my sitemap:

 map:read type=conceptimage mime-type=image/gif src={1}/
   map:parameter name=defaultFilename
 value=context://images/default.gif/
 /map:read

I'm not sure what Configurable is supposed to do (I haven't got around
to studying Avalon yet!) but every Cocoon Reader must implement setup()
(see: http://tinyurl.com/ynkwv2 ) and if the 4th argument to setup() is
called pars, you can just do: pars.getParameter(defaultFilename);


Tobia

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



Re: Converting CRLF to br/ in pipeline

2007-12-20 Thread Tobia Conforto
stevecam wrote:
 I have text that I am taking from a database that has formatting in
 it, mainly as CR and LF characters.  I want these to appear as br/
 tags in my XHTML output.  Is there a standard mechanism to achieve
 this, hopefully simply by adding a standard transformer into my
 pipeline?

I don't think there's a standard component to do that, but you can embed
it into a XSLT stylesheet, using for example EXSLT string extensions:

xsl:stylesheet ... xmlns:str=http://exslt.org/strings;

...

xsl:for-each select=str:tokenize($your-string, '#xA;#xD;')
xsl:value-of select=./
br/
/xsl:for-each


 I haven't much experience using pre tags in html but that may be
 another option.

pre, or the CSS equivalent { white-space: pre }, does output a newline
for each CR and/or LF character, but on the other hand won't wrap the
text when there is no CR/LF, so usually it's not an option.


Tobia

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



Re: Cached AbstractReader

2007-12-20 Thread Tobia Conforto
Jon Evans wrote:
 I've implemented a class which extends AbstractReader. It uses some
 SOAP calls to pull some binary gif image data from a remote system.
 My problem is that the resource is not cached if I throw a
 MissingResourceException.
 At the moment, products with no icons cause the remote system to be
 hit every time, and the SOAP calls are quite slow.

 The only thing I can think of is to stream the default image data out
 of my reader if the product has no image, by directly opening the
 default image file from disk inside the reader.

Yes, I think this is the best course of action.

You might want to make the path to the default image a configuration
parameter, of course, so that you won't have to recompile your reader
when the path changes, or if you want different default images for
different products.


Tobia

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



Re: JXTemplate: blank lines in source code

2007-12-20 Thread Tobia Conforto
Hello

Hans-Christian Meier wrote:
 I have noticed that the use of JXTemplate produces blank lines in the
 HTML source code.  For example the import of the macros to use CForms
 (jx-macros.xml).  In the HTML output the jx:import line is replaced
 with many blank lines.  Is there a way to prevent this?

I'd like to know this as well.

I'm thinking of replacing the src attribute of every JX transformer and
generator with an internal cocoon:/ URL that will strip whitespace-only
text nodes from the JX file.

But I'm not sure I'll be able to pull it off for JX imports too, and I'd
like to know whether this feature is already there in the JX components
and I'm just missing a configuration parameter.


Tobia

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



Re: Regular Expression Help

2007-12-14 Thread Tobia Conforto
Derek Hohls wrote:
 I need to check that a valid web address (grammatically correct
 anyway) is being entered in a form field.  I am trying to check for
 the address starting with a valid prefix - the regexp I am using is:

 pattern=^(http|https|ftp)://

The regexp validator anchors the pattern by default, as if you had
^ and $ at the ends of the pattern.

For reference, here is a very strict field that only accepts a valid,
non-numeric http URL, without any custom port, username, password or
query string, and checks that it actually resolves and points to an
existing, public web page.

You might want to loosen some of the requirements, depending on your
application :-)


field id=url required=true
  datatype base=string/
  labelURL:/label
  initial-valuehttp:///initial-value
  validation
regexp pattern=http://(?:[a-z0-9-]+\.)+[a-z]{2,}(?:/[^?]*)?
  failmessagePlease insert the URL of a web page/failmessage
/regexp
javascript
  !-- check that the URL exists --
  try {
var conn = new java.net.URL(widget.getValue()).openConnection()
conn.setInstanceFollowRedirects(true)
conn.setConnectTimeout(1)
conn.setReadTimeout(5000)
conn.connect()
if (conn.getResponseCode() != 200) throw 'error'
  } catch (e) {
widget.setValidationError(
new ValidationError(Please insert an existing URL, false))
return false
  }
  return true
/javascript
  /validation
/field


HTH
Tobia

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



Re: What is COB-INF?

2007-12-05 Thread Tobia Conforto
dperez wrote:
 Jeroen Reijn wrote:
  You can find that on the website:
  http://cocoon.apache.org/798_1_1.html

 Arrrgh, another web page I don't know how to reach through the menus!

???

It's the first page shown when you click on Getting involved /
Committer's and contributor's section.


Tobia

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



Re: different Stylesheets to be applied within a folder

2007-12-03 Thread Tobia Conforto
[EMAIL PROTECTED] wrote:
 Within a Document a stylesheet reference was set as:

 Document
...
stylesheetmyStyleA/stylesheet
...
 /Document

 How could I apply a certain stylesheet ?

This seems to be another example of content-based pipeline, which is not
directly supported in Cocoon.  See this recent thread for a few ideas:
http://marc.info/?l=xml-cocoon-usersm=119607094225772


Tobia

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



Re: Cocoon and content-negotiation

2007-11-29 Thread Tobia Conforto
Severin Gehwolf wrote:
 select a particular XML file with the best-matching language extension
 according to users Accept-Language HTTP headers.

This is usually achieved in Cocoon using the LocaleAction:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/LocaleAction.html

Other kinds of content negotiation, such as detecting patterns in the
HTTP Accept header, can be performed with the RegexpHeaderSelector:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/selection/RegexpHeaderSelector.html
or similar selectors and matchers that access the HTTP headers.


Tobia

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



Re: xpath condition on xml data in sitemap

2007-11-26 Thread Tobia Conforto
Sébastien Geindre wrote:
 i need to make a conditional treatment in my site

 generator
 transformer A
 if condition on xml from transformerA -- transformer B1
 else -- transformer B2
 transformer C
 serializer

 the condition is computed on xml data and global variables

What you ask for is not compatible with the way Cocoon works.
It is my understanding that Cocoon pipelines work like this:

1. a HTTP request reaches Cocoon;

2. the request is dispatched to the right (sub-)sitemap;

3. the tree of all matchers, selectors and actions in that sitemap is
   executed, meaning that each of them is asked (in hierarchical order)
   to make its decision and optionally perform any side effects.

What comes out of step 3. is a linear sequence of components, comprising
a generator, zero or more transformers and a serializer.  (Readers and
aggregators are chosen at this time too.)

4. This chain of components is then executed in a streaming fashion,
   meaning that the serializer can (in theory) start outputting the
   result document well before the generator is finished*;

5. the result of the serialization is sent as a HTTP response, again in
   a streaming, progressive way, at least in theory.

In any case, streaming or not, it should be clear that you cannot
choose what components to use in the pipeline (step 3.) based on the
intermediate results of the component chain itself (step 4.)

I suggest you either:

- make the choice between B1 and B2 based on the request data only, or

- merge transformers B1 and B2 in a single transformer, or

- always execute both transformers B1 and B2, controlling the function
  of each of them through appropriate elements in the XML stream, or

- delegate the work of B1 and B2 (and possibly of C and serialization)
  to appropriate sub-pipelines, using either the CInclude transformer,
  a piece of Flowscript, map:redirect-to, or similar means; remember
  to use cocoon:/ URLs in the place of http:// whenever you can, as they
  are optimized for internal sub-requests.

It's difficult to offer practical suggestions without knowing what your
pipeline does.

By the way, this whole email applies to Cocoon 2.1.  I don't know how
much of it is still true in 2.2.


Tobia

* A notable exception to this streaming behaviour is the XSL transformer,
in the general case anyway, as has been pointed out in other threads.

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



Re: New server recommendations?

2007-11-26 Thread Tobia Conforto
Peter Flynn wrote:
 I think the last time I asked, the recommendation was to make httpd
 proxy Tomcat [...] Does anyone have any specific Dos or Donts about
 this platform or configuration?

My personal experience with Tomcat for use with Cocoon 2.1 has been
terrible, both on RHEL and Debian.

We ended up using the (quite old) version of Jetty provided with Cocoon
itself, along with the cocoon.sh wrapper script and Apache reverse proxy
functionality, and it's been working like a charm ever since.

The only gotcha has to do with the AJP13 protocol, see here:
http://marc.info/?l=xml-cocoon-usersm=119201336509954

We haven't switched to Cocoon 2.2 yet, so I can't say much about it.


Tobia

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



Re: Flowscripts - are they cached?

2007-11-12 Thread Tobia Conforto
Derek Hohls wrote:
 on this server it did not seem to have any effect, so I was wondering
 if there was some other setting I had overlooked.

There is a setting in cocoon.xconf that might be related:
/cocoon/flow-interpreters/component-instance/reload-scripts


Tobia

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



Re: Flowscripts - are they cached?

2007-11-12 Thread Tobia Conforto
Derek Hohls wrote:
 I already have a setting looking like this:
 reload-scriptstrue/reload-scripts
 Is this what you meant?

Yes.  Well I guess you can try and use the ?cocoon-reload=true request
parameter, which is faster than restarting the whole container.
You can enable it in WEB-INF/web.xml:

init-param
  param-nameallow-reload/param-name
  param-valueyes/param-value
/init-param


Tobia

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



Re: Flowscripts - are they cached?

2007-11-12 Thread Tobia Conforto
Another thing: sometimes I run into missing reloads caused by
differences in the system time on servers or workstations.
That is, a newer file is not reloaded if Cocoon doesn't see it
as newer, based on the system clock.

Depending on your setup, you might want to investigate that.


Tobia

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



document() and xsltc

2007-11-07 Thread Tobia Conforto
I think I stumbled upon a bug in the XSLTC transfomer regarding the
document() function.  Here is a minimal example:


--- sitemap fragment: --

match pattern=test
  generate src=foo.xml/
  transform src=foo-bar.xsl type=xsltc/
  serialize type=xml/
/match

--- foo.xml: ---

foo/

--- bar.xml: ---

bar/

--- foo-bar.xsl: ---

xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform;

  xsl:variable name=foo select=//
  xsl:variable name=bar select=document('bar.xml')/

  xsl:template match=/
output
  fooxsl:value-of select=name($foo/*)//foo
  barxsl:value-of select=name($bar/*)//bar
/output
  /xsl:template

/xsl:stylesheet




The output I would expect, which is also the output I get using the
default xslt (Xalan-J interpretive) transformer is:

output
  foofoo/foo
  barbar/bar
/output

But if I use the xsltc (Xalan-J compiled) transformer the output is:

output
  foobar/foo
  barbar/bar
/output

It would appear that the document() call overwrites the source document
of the transformation, including all existing references to it.

Is this a known bug?  Can anybody confirm/reproduce it?


Tobia

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



Re: limited number of loops with call-template?

2007-11-06 Thread Tobia
Jens Reufsteck wrote:
 I'm using a template, which once called from outside starts calling
 itself as long as a certain condition is true. But after a certain
 amount of calls (1.100 times) it seems stopping to call itself.

I wouldn't write a template that calls itself recursively that many
times, unless I was sure that the implementation is tail-recursive and
that I am writing a tail-recursive template.

Said another way, try and traverse the document using matching (not
named) templates and apply-templates, along with modes if needed.

Based on your scarce snippet, you could try something like this:

  xsl:template match=ebene
xsl:if test=text() != preceding-sibling::ebene[1]/text()
  !-- we are looking at the first ebene of its kind:
   output all the ebene with that value inside a baum --
  baum ebene={text()}
xsl:apply-templates select=../ebene[text() = current()/text()]
 mode=output/
  /baum
/xsl:if
  /xsl:template

  xsl:template match=ebene mode=output
ebene
  ...
/ebene
  /xsl:template

Of course, I don't have the slightest idea what baums and ebenes are, so
this is probably not what you need :-)


Tobia

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



Re: Compiled XSLT

2007-10-23 Thread Tobia Conforto
Ard Schrijvers wrote:
   I'm wondering if there is a way to pre-compile XSLT into Java
   classes, using the command-line xsltc compiler, put those classes
   somewhere in Cocoon's classpath and use them as transformers.
 
  Actually, since Cocoon can already run the cached compiled
  stylesheets it shouldn't be that hard to get it to use them in the
  first place.

 Yes. You can take a look at the excalibur xmlutil in
 org.apache.excalibur.xml.xslt.XSLTProcessorImpl and write your own
 that for example first looks at compiled version at some place.

Thank you for your suggestion.

I was able to understand how XSLTProcessor, TraxProcessor, and
TraxTransformer relate to one another and I could write my own
xslt-processor-role that loads pre-compiled stylesheets from the
classpath.

Here it is, if anybody is interested or wants to take it from here.
Suggestions are welcome.


Tobia


=== cocoon.xconf ===

component class=ClassLoadingTraxProcessor logger=core.xslt 
role=org.apache.excalibur.xml.xslt.XSLTProcessor/clxsltc
parameter name=use-store value=true/
parameter name=transformer-factory 
value=org.apache.xalan.xsltc.trax.TransformerFactoryImpl/
/component

=== sitemap.xmap ===

transformer name=clxsltc 
src=org.apache.cocoon.transformation.TraxTransformer
xslt-processor-roleclxsltc/xslt-processor-role
/transformer

...

transform src=test.class type=clxsltc/

=== Java patch =

--- cocoon-2.1.10/src/java/org/apache/cocoon/components/xslt/TraxProcessor.java 
2006-12-19 12:03:37.0 +0100
+++ ClassLoadingTraxProcessor.java  2007-10-23 18:03:34.0 +0200
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.components.xslt;
+import org.apache.cocoon.components.xslt.*;

 import java.io.File;
 import java.io.IOException;
@@ -72,6 +72,14 @@

-public class TraxProcessor extends AbstractLogEnabled implements 
XSLTProcessor, Serviceable, Initializable, Disposable, Parameterizable,
+public class ClassLoadingTraxProcessor extends AbstractLogEnabled implements 
XSLTProcessor, Serviceable, Initializable, Disposable, Parameterizable,
 Recyclable, URIResolver {
+
+   private class SourceWrapper implements javax.xml.transform.Source {
+   private String id;
+   public SourceWrapper(String id) { this.id = id; }
+   public String getSystemId() { return id; }
+   public void setSystemId(String id) {}
+   }
+
 /** The store service instance */
 protected Store m_store;

@@ -208,6 +216,36 @@

 TraxErrorListener errorListener = new TraxErrorListener(getLogger(), 
stylesheet.getURI());
 try{
+
+   if (m_factory instanceof 
org.apache.xalan.xsltc.trax.TransformerFactoryImpl
+id.endsWith(.class)) {
+
+   // custom code to load pre-compiled translet 
from the classpath
+
+   if(getLogger().isDebugEnabled())
+   getLogger().debug(Loading Templates 
from classpath  + id);
+
+   m_factory.setAttribute(use-classpath, 
Boolean.TRUE);
+
+   final Templates template = 
m_factory.newTemplates(new SourceWrapper(id));
+
+   putTemplates(template, stylesheet, id);
+
+   final TransformerHandler handler = 
m_factory.newTransformerHandler(template);
+   
handler.getTransformer().setErrorListener(errorListener);
+   handler.getTransformer().setURIResolver(this);
+
+   m_factory.setAttribute(use-classpath, 
Boolean.FALSE);
+
+   final SourceValidity alwaysValid = new 
SourceValidity() {
+   public int isValid() { return 1; }
+   public int isValid(SourceValidity 
newValidity) { return 1; }
+   };
+
+   return new 
MyTransformerHandlerAndValidity(handler, alwaysValid);
+   // end custom code
+   }
+
 if (getLogger().isDebugEnabled()) {
 getLogger().debug(Creating new Templates for  + id);
 }


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



Compiled XSLT

2007-10-22 Thread Tobia Conforto
Hello,

I'm wondering if there is a way to pre-compile XSLT into Java classes,
using the command-line xsltc compiler, put those classes somewhere in
Cocoon's classpath and use them as transformers.


Tobia

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



Re: Compiled XSLT

2007-10-22 Thread Tobia Conforto
Ard Schrijvers wrote:
  I'm wondering if there is a way to pre-compile XSLT into Java
  classes, using the command-line xsltc compiler, put those classes
  somewhere in Cocoon's classpath and use them as transformers.

 your xsl stylesheets are compiled only once in cocoon and then held in
 memory cache. Unless you set the maxobjects of your default transient
 store (from top of my head, so might be a little different) extremely
 low, stylesheets won't have to be recompiled

Alas, my problem is not recompilation, but secrecy.  I'm working on a
proprietary application whose source code my client doesn't wish to
release.  I'd like to write parts of it in XSLT, pre-compile them into
classes and somehow use the classes (translets in Xalan-speak) as
transformers.

Should I write a custom transformer from scratch that uses the Xalan
XSLTC runtime to operate the translets, or is there a better way?

Do you foresee problems in integrating the pre-compiled translets with
Cocoon's source resolver?


Tobia

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



Re: Calling an InputModule from flowscript

2007-10-19 Thread Tobia Conforto
I wrote:
 I'm saving the input module into a global flowscript variable, because
 it's supposed to be request-independent.

Nevermind that.  I realized I must acquire the input module from the
selector every time, lest I end up with IllegalStateExceptions.


Tobia

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



Re: Newbie question: jx:choose/

2007-10-19 Thread Tobia Conforto
Marcus Wejderot wrote:
 I have tried all kinds of things in @test. What I really want to do
 is to check if the variable ${userid} is empty. How to do this?

I usually write:  test=${empty(userid)}

empty() is native JX language for testing against most kinds of empty,
such as (IIRC) 0, false, undefined, null, empty string, empty array...

See: http://commons.apache.org/jexl/reference/syntax.html


Tobia

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



Re: Calling an InputModule from flowscript

2007-10-19 Thread Tobia Conforto
Joerg Heinicke wrote:
 Tobia Conforto wrote:
  But I cannot pass null to my own input module in place of the third
  parameter (Map objectModel) because I use that objectModel in my
  class

 Another workaround is to create a map in your flowscript with the
 necessary data.

Yes, I had arrived at the same conclusion:

  function foo(attr) {
// call an input module that needs access to the request object
var tmp = new java.util.HashMap();
tmp.put('request', cocoon.request);
return fooInputModule.getAttribute(attr, null, tmp);
  }


  the sample fails to call cocoon.releaseComponent() on the
  InputModule selector, after calling getComponent() on it.

 the using code should not be aware of the component's implementation
 details - and that's why it should always release the component.

Here's how I did it, for the archives.  By the way, I'm saving the input
module into a global flowscript variable, because it's supposed to be
request-independent.  The fake objectModel map, on the other hand, is
created each time in the foo() function.

  // in the global scope: get the input module I will call in foo()
  var inputModuleSelector = cocoon.getComponent(InputModule.ROLE + Selector);
  try {
var fooInputModule = inputModuleSelector.select(foo);
  } finally {
cocoon.releaseComponent(inputModuleSelector);
inputModuleSelector = null;
  }


Tobia

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



Re: .DOC and .PPT modifying

2007-10-18 Thread Tobia
Luiz Antonio Falaguasta Barbosa wrote:
 Joerg Heinicke wrote:
  If you tell it to save the files in the XML format instead of the
  binary format you can use option 2 mentioned below.
 
   * since office 2003 : pure xml format, cocoon can handle them
 since its xml, but I don't know framework base on it

 Yeah, and use option 2 mentioned below means to use a I don't know
 framework base on it.  The problem is which framework I have to use.

Cocoon is the framework.

If you save the Office files in XML format, the files are pure XML.
In Cocoon you have a lot of tools to parse, transform, combine and
serialize pure XML data: I would say that's what Cocoon is all about.

I suggest you learn to program in the language XSLT, which you will use
to modify the XML data, read the introductory documentation on Cocoon's
website and study the samples provided with Cocoon, to learn how to put
a simple web-application together.


Tobia

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



Re: .DOC and .PPT modifying

2007-10-18 Thread Tobia Conforto
Luiz Antonio Falaguasta Barbosa wrote:
 using Cocoon includes putting images into the pure XML files
 (saved by MS Office 2003) too, right?

If (and only if) those file formats really are valid XML, there's
nothing in them that Cocoon can't handle.

You will have to figure out how exactly the images are embedded in the
file (I'd wager in CData sections, but I don't have such a file handy)
and work to obtain similar results yourself.  In the worst case scenario
you might have to write a piece of Java code to encode the images as an
XML fragment in the same way as the format requires... no big deal.


Tobia

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



Calling an InputModule from flowscript

2007-10-17 Thread Tobia Conforto
Hello

I'm following the advice Grzegorz gave me about coding my custom
URL-rewriting logic into an input module and using that input module
with the LinkRewriterTransformer, and wherever else I need it.

My input module works well in the sitemap, but I don't seem to be able
to call it from flowscript.  The only references I found are this message
from a year ago: http://marc.info/?l=xml-cocoon-usersm=115494972431824
and the file blocks/slide/samples/flow.js  They both suggests doing this:

importClass(Packages.org.apache.cocoon.components.modules.input.InputModule);
var foo = cocoon.getComponent(InputModule.ROLE + Selector).select(foo);
var foobar = foo.getAttribute(bar, null, null);

where foo is the input module's name as configured in cocoon.xconf.


But I cannot pass null to my own input module in place of the third
parameter (Map objectModel) because I use that objectModel in my class!

Is this the recommended way of accessing input modules from flowscript?
If so, how do I pass it the objectModel map?


Question #2:

Both the post and the sample fail to call cocoon.releaseComponent() on
the InputModule selector, after calling getComponent() on it.  I was
under the impression that you should go to great lengths (try/finally)
to release every Avalon component you acquire.  Is it not so?


Tobia

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



Re: Tabs and CForms

2007-10-16 Thread Tobia Conforto
Kamal Bhatt wrote:
 I would like to create a tab based interface where the user can freely
 navigate between tabs, without the screen validating and without every
 field being on the form (only the fields on the tab). Additionally, I
 would like to validate the form completely validates at the end.

Did you figure out what should happen when there is a validation error
on a group that's in the background?

Just a thought...


Tobia

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



Re: Cocoon 2.1 environment objects from a Java XSLT extension

2007-10-11 Thread Tobia Conforto
[EMAIL PROTECTED] wrote:
 XSLT Extensions assist formatting.  Data collection belongs in the XML
 generation phase.  Using XSLT Extensions to generate data is a very
 bad practice.  What are the requirements?

Let me explain better.

I need to translate URIs in a XML document, in the middle of a pipeline,
fetching relevant information from a SQL database.  In the middle of a
pipeline means that there are various other steps before it, so I
cannot fetch this SQL data in the initial generator.

At first I tried to have a sub-pipeline do the job, using the document()
XPath function with a cocoon: schema, but it was too slow.

My next (and current) idea is transforming the XML with XSLT, while
coding the actual URI transformations (including the SQL queries) as a
Java extension function, to be called from XSLT where appropriate.

I'm hitting a wall, because I need a DataSourceComponent to be able to
make SQL queries, but a Java XSLT extension class doesn't have any
access to Cocoon's object model (that I can see.)

I cannot pass the DataSourceComponent, or any other interesting object,
from the sitemap to my extension function, passing through the XSLT as a
parameter, because XSLT parameters get passed from the sitemap as strings.

Suggestions are welcome.

My last resort is doing everything as a custom transformer, but I'd like
to avoid it, as I'm not too keen on coding in Sax what can easily be
dealt with in XSLT (changing a bunch of attribute values.)  Although it
wouldn't be too hard with Sax either...


Tobia

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



Re: SendMail smart host (was sendmail)

2007-10-11 Thread Tobia Conforto
Peter Sparkes wrote:
 I have to use a Smart host, smtp.bytemark.co.uk.  Please is it
 possible to use a Smart Host with sendmail and if so how.

You didn't say whether you're using the Sendmail Transformer, the
Sendmail Action, or another thing entirely.

Here is how you can configure for the first two.  Notice that the
transformer wants smtphost, while the action wants smtp-host.


map:transform type=sendmail
map:parameter name=smtphost value=smtp.bytemark.co.uk/
...

map:act type=sendmail
map:parameter name=smtp-host value=smtp.bytemark.co.uk/
...


Tobia

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



Re: Cocoon 2.1 environment objects from a Java XSLT extension

2007-10-11 Thread Tobia Conforto
Grzegorz Kossakowski wrote:
 I'm not sure if it's going to fit in your case but I would suggest to
 take a look at Cocoon's quite powerful LinkRewriterTransformer[1].

Very interesting, thanks.
It seems to fit my case perfectly!


 Basically all you would need to do is to implement your own input
 module (quite simple task) and configure transformer so it uses your
 own input module.

So I would put my SQL logic in the input module... makes sense!


 I strongly agree that using extension functions in your case that
 access external that is *NOT* a good idea.

Very well, lesson taken.


Tobia

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



Cocoon 2.1 environment objects from a Java XSLT extension

2007-10-10 Thread Tobia Conforto
Hi

I'm rewriting some functionality into Java XSLT extensions, for
performance reasons.

For now I'm just writing a Java class, copying it to WEB-INF/classes and
calling its static methods from XSLT as such:

xsl:value-of select=myclass:myMethod($whatever)
xmlns:myclass=http://xml.apache.org/xalan/java/MyClass/

This works, but I need to access the standard Cocoon environment objects
(Request would suffice) from my Java class.

Should I pass the whole request object to the stylesheet as a parameter
and then pass it on to every invocation of my methods?
How do I pass the request object to the stylesheet?  I couldn't do it.

Is there a better way?


Tobia

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



Re: Cocoon Installation problems on SunOS

2007-10-10 Thread Tobia Conforto
Joerg Heinicke wrote:
 Derek Hohls wrote:
  We are trying to install Cocoon 2.1.8 under SunOS (version 5.7).
  The vanilla version of Cocoon installs and runs fine.  However, as
  soon as we try and add a mySQL driver to the lib directory, and
  alter the cocoon.xconf file, the Cocoon startup reaches a certain
  point - and then Tomcat stops
 
  Nothing in the archives I can find that addresses this problem except
  http://marc.info/?l=xml-cocoon-usersm=113356786000252w=2
  which was not answered

 All this sounds really weird. Seems to be only in a very special
 environment setup where it fails. But since Toby is still around on the
 list and has not given up with Cocoon he might have figured that out.

Uh... this is from two years ago, I don't remember how I solved it.
Sorry!

Now we are running Cocoon 2.1.10 on the bundled Jetty 4.2.23 (which
I recommend over Tomcat, by the way) with MySQL Connector 5.0.6 on the
same old server and everything works well.

But we did run on Tomcat for a while, so I'm sure that problem was
solved, maybe by upgrading Tomcat, Cocoon, the MySQL connector, or
by fixing the classpath...


Tobia

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



Re: Cocoon Installation problems on SunOS

2007-10-10 Thread Tobia Conforto
Derek Hohls wrote:
 In the meantime, rather than hacking around with all sorts of
 combinations, we are trying to locate and use another server
 (running Linux, which seems not to have these sorts of problems)

The server I was having that problem on was running Linux, so I believe
the issue to be OS-independent, but rather caused by some combination of
versions.  Or maybe something else entirely which I have forgotten about!


 Do you know of any detailed comparison of Tomcat vs Jetty, especially
 for configuring and running under Apache?

Sure!

Jetty is much lighter on memory and starts / restarts faster.  That's
all that matters to us, especially in development.  Which means we are
using it in deployment too, to avoid potential problems.


To connect Apache and Tomcat one usually uses the AJP13 protocol, with
the AJP13 connector, which is supposed to be slightly faster than HTTP.

Unfortunately using Jetty 4.2.23's AJP13 port caused weird problems
(random NullPointerException when using continuations!) so we switched
to Apache's reverse proxy functionality.  The configuration is like this:

VirtualHost *:80
ServerName www.yourwebsite.com

UseCanonicalName Off
ProxyPreserveHost On
ProxyPassReverse / http://10.0.0.3:/
ProxyPass / http://10.0.0.3:/

...
/VirtualHost

In this example 10.0.0.3 is the Cocoon server.  It could be 127.0.0.1.

Note #1: if the various Proxy* directives don't give you enough of a
fine-grained control over which requests go to Cocoon and which ones
stay in Apache, you can use rewrite rules with the [P] flag.

Note #2: when using reverse proxy, you won't find the remote IP address
(that of the web browser) in request.getRemoteAddr(), but rather in
request.getHeader('X-Forwarded-For')


HTH

Tobia

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



Re: SendMail

2007-10-09 Thread Tobia
Peter Sparkes wrote:
 I have put the Sun mail.jar and activation.jar in my WEB-INF/lib and
 removed removed geronimo-spec-javamail-*.jar and
 geronimo-spec-activation-*.jar from WEB-INF/lib.

 However I still get the error message
 Could not connect to SMTP host: localhost, port: 25

Stupid question, but... are you sure you have a MTA running on localhost?


Tobia

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



Re: .DOC and .PPT modifying

2007-10-09 Thread Tobia Conforto
Luiz Antonio Falaguasta Barbosa wrote:
 Is it possible to use Cocoon to change keys by values into .DOC and
 .PPT file types? Does anybody could give me some example?

I don't have first-hand experience with it, but here are a few ideas.

If the file is not too big, you can load it into memory as a string and
perform string replacement on it, then write it back to disk or stream
it to the user.  You can accomplish this with a number of Cocoon
technologies, for example with a custom Reader or with a piece of
Flowscript.  Actually you can do the same with any other web language or
web application framework: string substitution is pretty basic stuff.

You should check whether those file formats store strings in plain text,
which encoding they use, and how well they tolerate string substitution.
For example, any substitution will break the format if it employs a CRC
or another integrity check; variable-length substitutions will fail if
they break record lengths or offsets.  It's a hack in any case, and it
should be treated as such.

I have had good results with the RTF format, which is well understood by
most word processing applications, is text-based and allows arbitrary
substitutions.

On the other hand, the newer office productivity file formats are all
XML-based (both OpenDocument and that other Microsoft equivalent) and
Cocoon excels at handling XML.

You could create (or convert) your document templates into such a format,
using specific tags or element IDs as placeholders, or anything else that
can easily be replaced with an XSLT stylesheet.  Then have Cocoon perform
the substitution, zip the resulting XML with other needed resources (such
as images) using the ZipArchiveSerializer, and serve it to users.

Just a few ideas.


Tobia

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



Re: global:home param local and remote

2007-10-08 Thread Tobia Conforto
Lincoln Mitchell wrote:
 I am building many website and placing them in folders in webbapp

 1st I to this locally:
 http://localhost:/Asite.com.au/
 I then move it to the webapp on the server to go live:
 http://www.Asite.com.au/
 The problem is that when I move to webapp on the server the URLs become
 www.Asite.com.au/Asite.com.au/...

 So how do you get around this?

I like to use custom domain names.

If you can configure a local nameserver, setup a .local (or other) fake
domain with a * (wildcard) record pointing to your development server.
Then you can call www.Asite.com.au.local and handle the request in
Cocoon.  You just have to put a bit of logic in an action or somewhere,
to strip the .local part from request.getServerName()

If you cannot set up a local nameserver, you will have to put each fake
domain name in your hosts file*, as the hosts file does not support
wildcards, as far as I know.


Tobia

*: /etc/hosts or c:\windows\system32\drivers\etc\hosts

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



Re: Parsing HTML entities

2007-09-17 Thread Tobia Conforto
Andrew Stevens wrote:
 Tobia Conforto writes:
  I cannot change this data source component, therefore I need a
  transformer to examine every text node in the stream, split it at the
  fake br tags, substitute them with xhtml:br/ elements, and
  replace every escaped HTML entity with the relevant Unicode character.

 We have something similar in our application; I arrange the early part
 of the pipeline so that the escaped HTML appears within a unique
 element e.g.

   some_escaped_htmlLorem ipsum lt;brgt; dolor/some_escaped_html

 pass it through the html transformer

   map:transform type=html
 map:parameter name=tags value=some_escaped_html/
   /map:transform

 and follow that by a small xsl transformation to strip out the
 some_escaped_html elements and the html  body elements that JTidy
 inserts.

 Net result, the same SAX stream but with the HTML unescaped and
 cleaned up so it's well-formed again.

Thank you.
After extensive testing, turns out this is the best method.

It works for any kind of malformed HTML and is efficient enough,
provided I put some_escaped_html tags only where they are needed.


Tobia

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



Re: XSLT Transformation error in C2.2

2007-09-11 Thread Tobia Conforto
Sébastien Geindre wrote:
 I try to do this in a xslt stylesheet :
 xsl:variable name=top select=if(($type='cb') and 
 ($typeName!='wims:statusweatherproduct')) then 'max_fub' else 'top'/

if (...) then ... else ... is not an XPath 1.0 expression!

You have a few options.
One is to use standard XSLT constructs:

xsl:variable name=top
  xsl:choose
xsl:when test=$type='cb' and $typeName!='wims:...'max_fub/xsl:when
xsl:otherwisetop/xsl:otherwise
  /xsl:choose
/xsl:variable

Another is to define a custom function:

func:function name=my:if
  xsl:param name=test/
  xsl:param name=then/
  xsl:param name=else select=false()/
  xsl:choose
xsl:when test=$test
  func:result select=$then/
/xsl:when
xsl:otherwise
  func:result select=$else/
/xsl:otherwise
  /xsl:choose
/func:function

And then use it like this:

xsl:variable name=top
select=my:if($type='cb' and $typeName!='wims:...', 'max_fub', 'top')/

See here for custom functions: http://exslt.org/func/index.html


 it works with C2.1

I can't see how.
Maybe it's a custom extension of the XSLT processor you use?


Tobia

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



Problem with CInclude and nested exceptions

2007-09-10 Thread Tobia Conforto
I'm currently experiencing an annoying problem where Cocoon does not log
exceptions generated by sub-pipelines called through CInclude.

Here is my setup: a pipeline (already nested in other calls) generates a
CInclude include element and passes it through the CInclude transformer.
The transformer invokes a sub-pipeline via a cocoon:/... url, which
executes a function or continuation call.  Now, if the flowscript raises
an exception, such as a runtime EcmaError, I can't see it anywhere!

Here is what I get instead:

Exception page title (notice that EcmaError isn't mentioned anywhere!)

  javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException:
  javax.xml.transform.TransformerException:
Exception in CIncludeTransformer

Java full stacktrace (abridged)

  org.apache.cocoon.ProcessingException:
Sitemap: error calling function 'B'
  Caused by:
org.mozilla.javascript.WrappedException:
  Wrapped org.apache.cocoon.ProcessingException:
Sitemap: error calling function 'A'
  Caused by:
org.apache.cocoon.ProcessingException:
  Sitemap: error calling function 'A'
  Caused by:
org.mozilla.javascript.WrappedException:
  Wrapped org.apache.cocoon.ProcessingException:
Sitemap: error calling function 'C'
  Caused by:
org.apache.cocoon.ProcessingException:
  Sitemap: error calling function 'C'
  Caused by:
org.mozilla.javascript.WrappedException:
  Wrapped org.apache.cocoon.ProcessingException:
Failed to process pipeline
  Caused by:
org.apache.cocoon.ProcessingException:
  Failed to process pipeline
  Caused by:
org.apache.commons.lang.exception.NestableRuntimeException:
  javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException:
  javax.xml.transform.TransformerException:
Exception in CIncludeTransformer
  Caused by:
javax.xml.transform.TransformerException:
  javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException:
  Exception in CIncludeTransformer

The included flowscript function that raises the error is neither A, B,
nor C.  Those are higher-level functions that call one another before
getting to the pipeline with the CInclude transformer.  Why their
presence should cause so much exception noise is beyond me.

Am I losing exceptions because of some nesting limit?  If that is so,
can I increase that limit?

Otherwise, how can I get the CInclude transformer to pass along the
exception, so that I can see why the inner pipeline is failing, at least
in the logs?

I don't recall having this problem before, so it could very well be that
I've reached a nesting limit.

Any help will be appreciated!


Tobia

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



mod_gzip -like functionality?

2007-09-05 Thread Tobia Conforto
Dear all,

While trying to optimize execution and load time for a Cocoon web
application, I noticed that AJAX forms require a 173K dojo.js file.
This file is only transferred once per session or less, and then cached,
but I'd like to optimize the first load time among other things.

Therefore I would like to serve a compressed version of this file to
browsers that support content compression, much like mod_gzip does.

Can I enable such a feature in Cocoon?

Ad hoc, manual solutions (such as pre-compression) are welcome too, as
I will only do this for a few select static files (like dojo.js)

Is my only (or best) option to do this on the front-end Apache server
that I'm already using?


TIA
Tobia

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



Re: xhtml serialization and form textarea

2007-09-03 Thread Tobia Conforto
Peter Sparkes wrote:
 If I serialize it as html the output is :

 textarea .../textarea

 However when I serialize as XHTML 1.0 Strict the xhtml output is:

 textarea .../

What you say is true and also happens with div/, script/, and a
few other elements.  My advice is to avoid the xhtml serializer
altogether, as defined in the root sitemap.  The problem is that it
outputs XML (in fact it uses the XML serializer) but with a text/html
mime type, and that confuses browsers.

You can either use the xhtml11 serializer, which is correctly defined
to output an application/xhtml+xml mime type and that means the output
will be parsed as XML; or use the html serializer and work with HTML 4.

What I do is use xhtml11 on browsers that support XHTML (nearly all)
and html on the legacy ones (IE, wget, lynx):

selector name=accept
src=org.apache.cocoon.selection.RegexpHeaderSelector
  pattern name=xhtmlapplication/xhtml\+xml/pattern
  header-nameAccept/header-name
/selector

...

select type=accept
  when test=xhtml
serialize type=xhtml11/
  /when
  otherwise
transform src=html-fix.xsl/
serialize type=html/
  /otherwise
/select

Notice how it parses the Accept header and thus works on browsers old,
new, and yet to come, without the need to do user-agent sniffing.

html-fix.xsl adds the following element to head/, which is needed in
legacy mode but does harm in XHTML mode:

meta http-equiv=Content-Type content=text/html; charset=utf-8 /


HTH
Tobia

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



Parsing HTML entities

2007-08-31 Thread Tobia Conforto
Hello

I have a data source from which I get SAX text nodes into my pipeline
that contain escaped HTML entities and br tags.  In Java syntax:

Lorem ipsum mdash; dolor sit amet. br Consectetuer

or, in XML syntax:

Lorem ipsum amp;mdash; dolor sit amet. lt;brgt; Consectetuer

As you can see, the entities and br tags are escaped and part of the
text node.

I cannot change this data source component, therefore I need a
transformer to examine every text node in the stream, split it at the
fake br tags, substitute them with xhtml:br/ elements, and
replace every escaped entity with the relevant Unicode character.

I tried doing it with the Parser transformer, but it's too slow.

I tried using the HTML transformer, but I couldn't get it to work.


My question is: what do you suggest I use on the Java side?

Is there anything like PHP's html_entity_decode() available somewhere
in a library that Cocoon is already using, that can parse and convert
HTML 4.0 entities with a single pass on the string?


Tobia

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



Re: Parsing HTML entities

2007-08-31 Thread Tobia Conforto
Never mind, I solved it by hand

I wrote a Python script that takes a list of HTML entities and generates
a huge tree of switch() { case: switch () { case: switch () { case: ...

The generated Java code goes through a char[] in a single pass and when
it recognizes an entity it pushes the associated Unicode char into the
SAX stream, instead of the chars composing the entity.

It's pretty brutal, it produces a 36k class file, but it's the fastest
thing that could possibly solve the job, short of writing a C extension!
The pattern transformer took 800ms on some data, where mine takes 2ms!

If anybody is interested, I can post or email the code.


Joerg Heinicke wrote:
 That's one of the rare cases where I consider
 xsl:text disable-output-escaping=yes a valid approach

Yes, that was the first thing I tried, but I discarded it as it was
causing more problems than it solved.


Tobia

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



Re: Java strings vs. Javascript strings

2007-08-28 Thread Tobia Conforto
Jason Johnston wrote:
 So digging around in the Rhino API I discovered the WrapFactory
 class[1], which is what Rhino uses to wrap Java objects returned from
 methods so that they can be scripted.  By default it wraps
 java.lang.String objects just like it wraps any other Java object,
 giving your script access to its Java methods.  But it does allow you
 to switch this behavior for primitive values (strings, numbers,
 booleans), so that it exposes them as native JavaScript primitives

 Packages.org.mozilla.javascript.Context.getCurrentContext().getWrapFactory().setJavaPrimitiveWrap(false);

Thank you!  This is going to be a noticeable time saver for us, by
eliminating lots of small errors.

IMHO dynamic languages such as JavaScript are less expensive to program
in than statically typed ones like Java, at least for small- to
medium-sized projects.  But only if Things Just Work™, and having to
deal with only one class of primitive types is part of it.

I'd like to suggest making it the default in Cocoon.
Should I post an issue to JIRA or a message to the dev mailing list?


Tobia

 [1] 
 http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/WrapFactory.html

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



Java strings vs. Javascript strings

2007-08-27 Thread Tobia Conforto
Hello

Am I the only Cocoon user who is extremely annoyed by the fact that Java
strings are not Javascript strings are not Java strings?

Depending on the context, in your Flowscript you have to use either:

str.startsWith(...)
str.length()
str.codePointAt(n)

and the rest of java.lang.String methods, or:

str.match(/^.../)
str.length
str.charCodeAt(n)

and the rest of Javascript String methods.

This is very annoying and a huge waste of time, at least for me.

I found that I can wrap every string in a Javascript String(...)
constructor, so the following always work:

String(str).match(/^.../)
String(str).length
String(str).charCodeAt(n)

But it's ugly, repetitive, and prone to errors.

And don't get me started on testing for a null value or void string!

This is giving me headaches.

Can't Rhino, or whatever piece of software is bridging Javascript to Java,
do the Right Thing and present every string as a Javascript string when
I'm programming in Javascript?  Can it be configured to do so?

Am I doing something wrong?


Tobia

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



Re: Java strings vs. Javascript strings

2007-08-27 Thread Tobia Conforto
Jason Johnston wrote:
 Rhino also makes the JavaScript methods available to Java strings if
 the java.lang.String class doesn't already define them. For example:

js javaString.match(/a.*/)

Thanks, that clears part of the confusion to me.

It also explains why sometimes I could get away with treating strings
as the language (JavaScript) calls for, while other times I couldn't.
For example match() works the same on both string types, as the example
says, while replace() doesn't.  That's just great.

To complicate matters further, I cannot simply wrap a java.lang.String
in a JS String() constructor and call replace() on the resulting object,
because whenever I handle a java.lang.String I must expect to receive a
Java null, but that becomes a JS null, and String(null) == 'null'!

So:

null is false
 is false
java.lang.String() is true (!)
String(java.lang.String()) is false
String(null) is true

Uhh...

I guess I'll have to wrap EVERY Java string in something like this:

function str(javaString) {
  if (javaString == null)
return '';
  else
return String(javaString);
}

Which means every cocoon.request.get*() call, every string coming from
forms...  What a mess!


Tobia

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



Re: I'm losing my faith in SQL Transformer!

2007-08-24 Thread Tobia Conforto
Derek Hohls wrote:
 I have been frustrated before by the fact that it only nests down to
 one level; its still not clear to me why further levels of nesting
 cannot be supported?

Can you explain this problem and maybe provide an example?
I think I've nested queries up to 4 levels deep without problems,
using the SQL Transformer.


 sql:execute-query
   rpt:cols
 sql:query
 ...

I don't think you can intersperse arbitrary tags between the SQL
Transformer's tags, but I'm not sure.

Glossing over this detail, for the moment, I see that your question has
a more serious flaw:

 Expecting this will return:

 rpt:report ...
   sql:rowset
 rpt:cols
   sql:row  (2)
 sql:nameDerek/sql:name
   /sql:row
 /rpt:cols
 rpt:matrix
   sql:rowset nrofrows=0/  (1)
 /rpt:matrix
   /sql:rowset
 /rpt:report

This expected result does not make sense.  The results of a nested query
(1) can only be inside the relevant row of the parent query (2).

If you need some other sort of correlation between each row and its
child rowset, such as an id attribute, then you will need to do it in
XSLT.  Otherwise, please post the correct version.


Tobia

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



Re: output indent yes?

2007-08-16 Thread Tobia Conforto
Lincoln Mitchell wrote:
 but doesn't indent my html in the xsl file

indentyes/indent does not actually indent the code, it just adds
newlines here and there.

I personally prefer to leave all output unindented (one long line) and
just *view* it indented when I want to.  This way I don't need to worry
about newlines being inserted where they shouldn't, possibly causing
strange layout problems.

Here is the way I do it, in case you find it useful.  I have configured
my browser (Opera) to open my text editor (Vim) whenever I choose view
source.  Then I have configured Vim so that by typing a shortcut the
whole file being displayed is passed through xmllint, a tool that can
re-indent XML.  The Vim config is:  map M-f :%!xmllint --format -CR
This has the benefit of alerting me of strange errors, as xmllint is
very strict about XML syntax.

Another way is to use this Firefox extension:
https://addons.mozilla.org/en-US/firefox/addon/697


HTH
Tobia

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



Re: expire setting

2007-08-12 Thread Tobia Conforto
Johnson wrote:
 Is it possible to set up expired time for the generated pages of cocoon

Yes. Take a look at pipeline configuration, here:
http://cocoon.apache.org/2.1/userdocs/concepts/caching.html
and in the root sitemap.xmap from the Cocoon distribution, lines 370–440.

You might also find the Http Cache Action useful:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/HttpCacheAction.html


 If so, we can improve the speed of running cocoon.

I'm not sure how that would work, but more power to you!


Tobia

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



Re: Database connection problems during upgrade

2007-08-06 Thread Tobia Conforto
Johannes Textor wrote:
 this is probably because you have not included com.mysql.jdbc.Driver
 (not sure if this is the exact class name) in web.xml.

Or maybe he didn't copy the actual driver class.

For example, mine is:
WEB-INF/lib/mysql-connector-java-5.0.6-bin.jar


Tobia

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



Re: access remote jpg

2007-08-03 Thread Tobia Conforto
Lincoln Mitchell wrote:
 img src=http://www.absnetwork.com.au/abs_consult-106079.jpg;
 img src=http://static-r.arttoday.com/thb/thb13/JU/5366_C00347/
 4559477.thb.jpg?dlsmC0034765

 only the 1st image appears, but if I save the HTML cocoon generates
 and open that html file independent of cocoon the 2nd image also appears!

That's because static-r.arttoday.com seems to forbid access to their
images from unapproved referrers, but allows access with no referrer.

Besides, it's considered very rude to embed media from a different site
in your web page without permission, even if the copyright would allow it.

I suppose you should fetch the image once only, with a blank referrer
header, and serve it to your users from your server.  You should also
cache it in a database or in the filesystem for future requests.

I don't have a clue how to do that in Cocoon :-)


Tobia

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



Re: access remote jpg

2007-08-03 Thread Tobia Conforto
Lincoln Mitchell wrote:
 You said: What you probably can do is to make the request to your
 Cocoon server and let Cocoon grab it for you with a reader from the
 remote server. I am not familiar with the terms you are using so am a
 bit confused.

He meant: «Generate an HTML page that will make the client request the
image from your Cocoon server; in Cocoon, handle the request with a
reader, that will download the image from the remote server and send it
to the client.»

Example HTML:

img src=remote/123456.jpeg/

and matcher + reader:

map:match pattern=remote/*.jpeg
  map:read src=http://remote.server/blah/blah/{1}.jpeg/
/map:match


Tobia

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



Re: regexpUriMatcher

2007-08-02 Thread Tobia Conforto
Boissé Denis wrote:
 Usually ungreedy matcher are in a form (.*?) and suppose to match
 something like temp/hello/ or temp/hi/ but not matching something like
 temp/hello/dir/ (that's what happen to me)

As Alfred said, you cannot use the 'greediness' of quantifiers to
control the matching of an anchored regexp, because they will always
grow as much as needed to match the string, if possible.

You tipically use them to give more weight to one piece of the regexp
with respect to another piece.  Compare:

^temp/(.*?)/(.*)/$

^temp/(.*)/(.*?)/$

They will match temp/a/b/c/ as (a, b/c) and (a/b, c) resp.
What you described is true when the regexp is not anchored:

^temp/(.*?)/  matches temp/hello/
^temp/(.*)/   matches temp/hello/dir/


Anyways, I believe Cocoon uses Java's builtin regexp classes:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html


Tobia

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



Re: [Flowscript] everything converted to number type?

2007-07-31 Thread Tobia Conforto
Mark Lundquist wrote:
 I've got some CForms widgets of datatype base=long/, so I expect
 that the widget value should be a java.lang.Long, right?

Widget's getValue() returns an Object, so that would make sense, yes.


 it seems like every reference to the widget value gets converted to a
 JS number type

Probably because all Java number types (including their wrapping objects
in java.lang) get converted to a JS Number, which sounds reasonable BTW.
I suppose you could find notes on the type mapping between Java and JS
on Rhino's website.  Rhino is the Javascript interpreter used by Cocoon.

Now, if it also converted java.lang.String to JS strings automatically,
it would have spared me many a headache... unfortunately that's a
conversion that Rhino seems reluctant to do.


 and truncated to an integer value.

I believe that a Java long is an integer type.


Tobia

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



Re: Problem with SQLTransformer

2007-07-26 Thread Tobia Conforto
warrell harries wrote:
 From the xml snippet it appears that you have missed out the sql:
 prefix

Actually his namespaces seem to be ok, so I'm not sure what the problem
might be... maybe the SQLTransformer code is not prefix-independent?

  The source XML: sql-select-themes.xml
  ?xml version=1.0?
  page
  execute-query xmlns=http://apache.org/cocoon/SQL/v2;
   ^^^
  querySELECT nom FROM Theme/query
  /execute-query
  /page


Tobia

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



Re: error using java method id flowscript

2007-07-26 Thread Tobia Conforto
christoph wrote:
 I get following error:

 line 6: Can't find method
 org.apache.cocoon.components.flow.util.PipelineUtil.processToDOM(string).

Maybe because it's processToDOM(String uri, Object viewData)

See http://cocoon.apache.org/2.1/apidocs/index.html

Or maybe it's something else...


Tobia

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



Disable url rewriting

2007-07-25 Thread Tobia Conforto
Does anybody know how to disable url encoding in Cocoon on Jetty?

For a certain web application I want sessions to be handled only through
cookies (and not to work when cookies aren't available.)

Is it a Cocoon or a Jetty configuration parameter?


Tobia

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



Re: Disable url rewriting

2007-07-25 Thread Tobia Conforto
Let me explain the problem a bit more.
I'm still curious about the issue, although I've found a workaround.

According to the docs Cocoon will not rewrite URLs, unless you use the
encodeURL transformer or call the equivalent flowscript function.

What I'm seeing is that the Location header of a client-side redirect
gets rewritten somewhere between my flowscript call and the network.

I call:

cocoon.redirectTo('test')

And on the wire I see:

Location: http://my.server/test;jsessionid=xx

Who is rewriting the URL?  Cocoon or Jetty?  How can I disable it?


The workaround I've found is calling redirectTo like this:

cocoon.redirectTo('http://my.server/test', true)

With both a full URL as the first parameter and true as the second one,
the Location URL doesn't get rewritten.


Tobia

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



Re: Disable url rewriting

2007-07-25 Thread Tobia Conforto
Nevermind, something was (is) creating spurious sessions where it
shouldn't.  It will take a while to figure out what misguided component
or piece of flowscript is doing so.

In the meantime I have put this in a couple places to make sure there is
no session before calling redirectTo():

if (cocoon.request.getSession(false))
  cocoon.session.invalidate()

Otherwise redirectTo, which ends up calling response.encodeRedirectURL()
(in HttpEnvironment.java:138) will add ;jsessionid to the URL.


Tobia

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



Re: Simple Java from flowscript ?

2007-07-25 Thread Tobia Conforto
Schmitz, Jeffrey A wrote:
 First, is there anywhere to see specifics about the compilation error
 encountered?  All it tells me is Compilation produced 1 syntax error
 on line 1.

Check your cocoon.log file (it's in WEB-INF/logs/ if you didn't change
its location; you can change its location in WEB-INF/logkit.xconf)
Look for the useless error message about Compilation produced 1 syntax
error and a couple lines above you will find the real message with
error type, line and column.


 any ideas on what may be wrong?

 var uri = neutralInstModel / + inputType + In/ + inputFile + ...
^
:-)


Tobia

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



Client-side cache handling

2007-07-23 Thread Tobia Conforto
Hi all

Is there an established way, recommended way, ad-hoc component or sample
about manually controlling the client-side cache?

I'm serving the css for some pages as a unified, space-stripped, virtual
css file.  This speeds up page loading a bit, especially when the
original css files are many and small.

Unfortunately it means that Cocoon won't send a Last-Modified header
anymore (it seems to me that only readers do so), the browser won't put
If-Modified-Since in the following requests and the css bundle will be
downloaded time and again.

I'm looking for a way to tell Cocoon: this pipeline only depends on
these resources, so please compute and send a Last-Modified header.

Any idea?

Should I do it by hand in a piece of flowscript?


Tobia

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



Re: Error while evaluating 'cocoon:/{../1}/...not so many levels

2007-07-23 Thread Tobia Conforto
Vaduvoiu Tiberiu wrote:
 in my parent sitemap I have

 map:match pattern=*/*/*/*
   map:mount check-reload=yes uri-prefix={1}/{2}/{3} 
 src={3}/sitemap.xmap /
 /map:match

 and in my sub-sitemap I have:

 map:match pattern=home.htm
   map:aggregate element=root label=source
 map:part element=menu src=cocoon:/{../1}/{../2}/menu.xml/
   /map:aggregate

You can't access sitemap parameters across sitemaps.


I can see two solutions to your problem:

1) take off that  uri-prefix={1}/{2}/{3}  from the mount command and
modify all matchers of all sub-sitemaps to deal with the extra URL
components;

or

2) modify that particular matcher in the sub-sitemap to match agaist the
full request URI, which you can get for example with {request:requestURI}

The first solution seems more correct, but of course it depends on
your particular sitemap layout.

Also I don't know exactly how to do the latter point.
I'd wager there is a matcher somewhere that you can use with input
modules (the {request:...} thing is an input module.)


Tobia

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



Re: Cocoon sessions and cookies

2007-07-20 Thread Tobia Conforto
blogger wrote:
 I am pipelining a b2evolution blog through cocoon, and I am having a
 problem maintaining the sessions and cookies.

I suggest you fire a packet sniffer (my favorites are tcpick in a
terminal, followed by Wireshark in a GUI or on Windows) to capture both
the traffic between your browser and Cocoon, and between Cocoon and the
blog server.

This way you can see what's happening on the wire and you can easily
spot any problems.


Tobia

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



Re: Namespace: behaviour differences

2007-07-20 Thread Tobia Conforto
Let's recap.  The following two statements are equivalent and are both
prefix-independent:

xsl:apply-templates select=sq2:[EMAIL PROTECTED] = 'program-view']/

xsl:apply-templates select=*[local-name() = 'rowset'
and namespace-uri() = 'http://apache.org/cocoon/SQL/2.0'
and @name = 'program-view']/

The only way to make an XPath expression prefix-dependant (which is
usually bad) is to use the name() function.  Thus the name() function
should be avoided whenever possible, using local-name() in its stead,
or better yet direct expressions such as self::sq2:rowset.

The two statements above should apply to both XML files (which are two
equivalent forms of the same XML data) yielding the same results.

The former statement is preferable, since it's shorter, it's more easily
optimizable (as somebody else pointed out) and you are defining the SQL2
namespace only once, but they should both work on both XML files.

Indeed they do: I just tested all four combinations with xsltproc and
the result is always the same, with both found page and found rowset


It looks like something is broken in your server installation.


Tobia

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



Re: Namespace: behaviour differences

2007-07-19 Thread Tobia Conforto
Here's an interesting question: is one of the following more efficient
than the other?

xsl:value-of select=//wh:thing xmlns:wh=http://whatever/

xsl:value-of select=//*[local-name() = 'thing' and namespace-uri() = 
'http://whatever']/

I'm talking about runtime efficiency, not compilation speed (assuming
stylesheets are compiled in some way, which I believe is the case.)


Tobia

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



Re: Access to bizData in fd:on-actionfd:javascript

2007-07-19 Thread Tobia Conforto
Dev at weitling wrote:
 in an on-action-javascript in my forms definition I want to get access
 to the bizData provided with the showForm()-function.
 In the end I want to be able to change the entries in a selection list
 on an ActionEvent.

It might be just personal taste, but I tend to write all event handlers
and widget manipulation in the flowscript, so I would write it as such:


--- flowscript -

var selist = ...

var form = new Form(definitions/test2.xml);

form.getChild('mySelectionList').setSelectionList(selist, 'value', 'label');

form.getChild('changeSelectionListButton').addActionListener(function() {
  // selist.blah() ...
  // remember to call setSelectionList again here
});

form.showForm(templates/test2.xml);


--- definition -

fd:field id=mySelectionList
  fd:datatype base=string/
/fd:field

fd:action id=changeSelectionListButton
  fd:labelDo it!/fd:label
/fd:action




Tobia

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



Re: The continuation ID is invalid

2007-07-19 Thread Tobia Conforto
Christian Sengstock wrote:
 What happens is: the ID is not changing anymore! It's the same for all
 users requesting the form with a given browser.

 We restarted tomcat .. still the same problem
 We cleared the work dir .. still the same problem
 We restared the machine .. the form is working again

So the problem lies in another process, external to Tomcat... a process
which is wrongly caching the pages generated by Cocoon and serving them
to the users, with stale continuation ids.

Apache?


Tobia

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



Re: howto call xsp from xsp

2007-07-16 Thread Tobia Conforto
robf wrote:
 At some point in an xsp I want to include the resultset from calling
 another xsp, just like it is possible in xslt's

This should work:

xsp:page language=java
xmlns:xsp=http://apache.org/xsp;
xmlns:util=http://apache.org/xsp/util/2.0;
.
.
.
util:get-source
  util:hrefcocoon://someurl?esql:get-string column=XYZ//tagx/util:href
/util:get-source


The util logicsheet has a few useful functions, but I don't think it's
well documented.  You can look at the sources though (look for util.xsl)


Tobia

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



Re: Calling map:handle-errors from flowscript

2007-07-11 Thread Tobia Conforto
Joerg Heinicke wrote:
 Tobia Conforto wrote:
  throw new Packages.org.apache.cocoon.ResourceNotFoundException()
 
  produces the following Java stacktrace:
 
  org.mozilla.javascript.JavaScriptException
  Caused by: org.mozilla.javascript.WrappedException
  Caused by: org.apache.cocoon.ProcessingException
  Caused by: org.mozilla.javascript.JavaScriptException

 This looks familiar: https://issues.apache.org/jira/browse/COCOON-1205.
 The exceptions are not kept, but swallowed. Can you confirm this?

It doesn't look like the same thing to me, but I'm not sure.


Tobia

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



Re: Calling map:handle-errors from flowscript

2007-07-10 Thread Tobia Conforto
Joerg Heinicke wrote:
 Tobia wrote:
  cocoon.sendStatus(404)
  cocoon.response.setStatus(404)
  cocoon.response.sendError(404)
  throw new Packages.java.io.FileNotFoundException()
  throw new Packages.org.apache.cocoon.ResourceNotFoundException()
 
  The problem with the (send|set)(Status|Error) is that they don't
  invoke the exception handlers defined in the sitemap.  The problem
  with throwing new exceptions is that they are wrapped in a
  JavaScriptException and thus are reported as a 500 error, while I
  need a 404.

 Did you have a look at the documentation?
 It talks about unrolling an exception. Does this work?

It doesn't seem to work, or I can't get it to work.  Throwing a new
ResourceNotFoundException produces the following Java stacktrace:

org.mozilla.javascript.JavaScriptException
Caused by: org.mozilla.javascript.WrappedException
Caused by: org.apache.cocoon.ProcessingException
Caused by: org.mozilla.javascript.JavaScriptException

The exception selector is configured to unroll as much as possible, but
the JavaScriptException seems to be unrollable.


Anyways, I solved the problem using the XPathExceptionSelector.

Flowscript:

throw 'not-found'

Sitemap:

selector name=exception 
src=org.apache.cocoon.selection.XPathExceptionSelector
  exception name=not-found 
class=org.apache.cocoon.ResourceNotFoundException/
  exception name=flowscript 
class=org.mozilla.javascript.JavaScriptException
xpath name=not-found test=starts-with(message, 'not-found ')/
  /exception
  exception class=java.lang.Throwable unroll=true/
/selector


Tobia

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



Re: Basic error handling

2007-07-06 Thread Tobia
Derek Hohls wrote:
 right at the end of the sitemap, after *all* of the map:pipeline
 sections I have:

   map:handle-errors
 map:select type=exception
   map:when test=not-found
 map:generate type=file src=docs/missing.xml/
  map:call resource=simple-page2html/
   /map:when
 /map:select
   /map:handle-errors

  /map:pipelines

 /map:sitemap

I believe handle-errors goes inside a pipeline.


Tobia

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



Re: [Jexl] linebreaks in jexl expressions

2007-07-05 Thread Tobia
Christoph Gaffga (triplemind.com) wrote:
 But the encoding of the linebreak in JX Generator expressions seems to
 be a problem:

 p${value.indexOf('\n')}/p

 p${value.indexOf('#10;')}/p

Did you try all the naive workarounds?

${value.indexOf('\n')}
${value.indexOf('\\n')}
${value.indexOf('\\\n')}
${value.indexOf('n')}

${value.indexOf('#10;')}
${value.indexOf('amp;#10;')}
${value.indexOf('amp;amp;#10;')}

${value.indexOf('\#10;')}
${value.indexOf('\\#10;')}
${value.indexOf('\amp;#10;')}
...


Tobia

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



Re: serialize type question

2007-07-04 Thread Tobia
Vaduvoiu Tiberiu wrote:
 my serializer:

 map:serializer name=xhtml
 ...

Here you are defining a serializer called xhtml.


 I have a question: if my serialize type is the type xml, my resulted
 xml file has encoding ISO-8859-1. How can I change this to utf-8?

 ...
 map:serialize type=xml/

Here you are using a serializer called xml, that is probably defined
in the root sitemap.

They are two different serializers, defined in different places, that do
different things.


Did you try Jasha's suggestion?


Tobia

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



Re: Cocoon database access strategy

2007-07-04 Thread Tobia
Here's a followup for the fellow users who build their queries with XSLT.

I found the question-mark + sql:in-parameter syntax a bit inconvenient,
especially when the query is composed out of building blocks in XSLT:

sql:query
  SELECT ...
  FROM ...
  WHERE ...
  xsl:if test=$name and $filter-name
AND name = ?
  /xsl:if
/sql:query

xsl:if test=$name and $filter-name
  sql:in-parameter nr=1 value={$name}/
/xsl:if

As you can see, this approach is a maintainability nightmare: think of a
50 line query with dozens of parameters.

So I came up with this solution, which works very well for me.
It's somewhat similar in usage to esql:parameter:

sql:query
  SELECT ...
  FROM ...
  WHERE ...
  xsl:if test=$name and $filter-name
AND name = sql:param value={$name}/
  /xsl:if
/sql:query

This is processed by an additional XSLT transformer before being fed to
the SQL transformer:

xsl:template match=sql:query
  xsl:copy
xsl:apply-templates select=@*|node()/
  /xsl:copy
  xsl:for-each select=.//sql:param
sql:in-parameter value=[EMAIL PROTECTED] nr={position()}/
  /xsl:for-each
/xsl:template

xsl:template match=sql:param
  xsl:text?/xsl:text
/xsl:template

I think it would be useful to include this functionality in the SQL
transformer itself.


HTH
Tobia

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



Re: Cocoon database access strategy

2007-07-04 Thread Tobia
[EMAIL PROTECTED] wrote:
  xsl:template match=sql:query
xsl:copy
  xsl:apply-templates select=@*|node()/
/xsl:copy
xsl:for-each select=.//sql:param
  sql:in-parameter value=[EMAIL PROTECTED] nr={position()}/
/xsl:for-each
  /xsl:template
 
  xsl:template match=sql:param
xsl:text?/xsl:text
  /xsl:template

 I like it.  Add priority=2 to the first match to make certain
 sql:in-parameter elements are created before the sql:param are changed
 to question marks.

 From my understanding of XSLT it doesn't change sql:param's to ?s in
the source tree, but only in the result tree, so the processing order
is irrelevant.  Actually there is no predefined processing order: XSLT
is (mostly) a declarative programming language free from side effects.


Tobia

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



  1   2   >