You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by James Burton <st...@yahoo.com> on 2002/02/27 12:09:48 UTC
XML-Based Selection (Redirect Serializer?)
Hi all! We're working on a Cocoon 2 project and
*very* strongly need the ability to "branch" to a
different pipeline or part of a pipeline based on the
XML output of a Transformer. This is because we use a
custom Transformer for communicating with an EJB back
end. Originally I thought to use an XML selector like
this:
<map:match pattern="example">
<map:generate src="..." />
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:select type="xml" node="/result/flag">
<map:when test="normalResult">
<map:transform src="styles/normal.xsl" />
</map:when>
<map:when test="specialResult">
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:transform src="styles/special.xsl" />
</map:when>
</map:select>
<map:serialize />
</map:match>
However I found in the mail archives (Subject: XML
selector) that this method does not work because
Selectors have no access to the XML results of
Transformers. For similar reason a custom Matcher
wouldn't work either. But this functionality is
crucial!
Therefore, I wondered if it would be possible for me
to create a "redirecting serializer": one that would
call a different pipe (or a different resource) based
on the final XML feed. In other words something like
this:
<map:match pattern="example">
<map:generate src="..." />
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:serialize type="redirector">
<map:parameter name="node" value="result/flag" />
<map:parameter name="match1" value="normal" />
<map:parameter name="call1" value="normal-pipe" />
<map:parameter name="match2" value="special" />
<map:parameter name="call2" value="special-pipe"
/>
</map:select>
</map:match>
Can someone give me a hint for how to start
implementing this? I know how to make a Serializer,
but don't know what it would call to start invoking a
pipe with a different URL (I imagine it must be
similar to the implementation of <map:call>). Or, if
this is not going to work, could somebody let me know?
In that case, I think the only alternative left is to
make a serializer that issues an HTTP redirect to a
given URL based on its parameters; i.e. a
"RedirectSerializer". I would be happy to contribute
this serializer if I can get it to work.
Many thanks from Prague,
James Burton
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: XML-Based Selection (Redirect Serializer?)
Posted by Stefano Mazzocchi <st...@apache.org>.
James Burton wrote:
>
> --- Stefano Mazzocchi <st...@apache.org> wrote:
> >
> > What about writing a custom selectors that connects
> > to the EJB logic?
> > will sure be faster and cleaner than to have to
> > serialize things as SAX
> > events, and have a selectors look into the pipe for
> > that.
>
> The reason we use a Transformer is that our EJB
> back-end offers services with an XML-in, XML-out API,
> so we really like being able to invoke it as just
> another pipe component. If there were a selector that
> took SAX on input that would work, but I think then
> we're talking about the same thing.
The real point is: should a selector have knowledge on what flows into
the pipe?
See my next reply.
> (By the way, Cocoon ROCKS. Right now it's the only
> Java-based web interface framework I've found that
> understands the real concerns of the designers as well
> as the programmers).
Thanks.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: XML-Based Selection (Redirect Serializer?)
Posted by James Burton <st...@yahoo.com>.
--- Stefano Mazzocchi <st...@apache.org> wrote:
>
> What about writing a custom selectors that connects
> to the EJB logic?
> will sure be faster and cleaner than to have to
> serialize things as SAX
> events, and have a selectors look into the pipe for
> that.
The reason we use a Transformer is that our EJB
back-end offers services with an XML-in, XML-out API,
so we really like being able to invoke it as just
another pipe component. If there were a selector that
took SAX on input that would work, but I think then
we're talking about the same thing.
(By the way, Cocoon ROCKS. Right now it's the only
Java-based web interface framework I've found that
understands the real concerns of the designers as well
as the programmers).
Best regards,
James Burton
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: XML-Based Selection (Redirect Serializer?)
Posted by Stefano Mazzocchi <st...@apache.org>.
James Burton wrote:
>
> Hi all! We're working on a Cocoon 2 project and
> *very* strongly need the ability to "branch" to a
> different pipeline or part of a pipeline based on the
> XML output of a Transformer. This is because we use a
> custom Transformer for communicating with an EJB back
> end. Originally I thought to use an XML selector like
> this:
>
> <map:match pattern="example">
> <map:generate src="..." />
> <map:transform type="custom-ejb-interface">
> ...
> </map:transform>
> <map:select type="xml" node="/result/flag">
> <map:when test="normalResult">
> <map:transform src="styles/normal.xsl" />
> </map:when>
> <map:when test="specialResult">
> <map:transform type="custom-ejb-interface">
> ...
> </map:transform>
> <map:transform src="styles/special.xsl" />
> </map:when>
> </map:select>
> <map:serialize />
> </map:match>
What about writing a custom selectors that connects to the EJB logic?
will sure be faster and cleaner than to have to serialize things as SAX
events, and have a selectors look into the pipe for that.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
RE: XML-Based Selection (Redirect Serializer?)
Posted by James Burton <st...@yahoo.com>.
Hi Matthew,
Thanks very much for the suggestion. It works in
theory (at least I am able to switch to a different
pipe based on different XML from the stream), but has
two problems:
1) If possible, I'd like to keep the mapping from XML
result => new pipeline inside of the sitemap file.
2) I get an error with CInclude "ProcessingException:
Failed to execute pipeline.:
org.apache.cocoon.ProcessingException: Attempted to
process incomplete pipeline" every *alternate* time I
reload the page. I am using these pipes
<!-- Generate request XML as the "get-req" pipe -->
<map:match pattern="get-req" >
<map:generate type="request" />
<map:serialize type="xml" />
</map:match>
<!-- Include "get-req" into an XML file -->
<map:match pattern="cinclude-test" >
<map:generate src="a.xml" />
<map:transform type="cinclude" />
<map:serialize type="xml" />
</map:match>
With this data for "a.xml":
<?xml version="1.0" encoding="UTF-8"?>
<page
xmlns:cinclude="http://apache.org/cocoon/include/1.0">
<title>Hello</title>
<content>
<para>This will test cinclude</para>
<cinclude:include src="cocoon:/get-req"
element="included"/>
</content>
</page>
Could this be some sort of multithreading error causes
by CInclude not being used to "cocoon:/"-type URLs?
So here is my next question: it looks like the core
lines in the CIncludeTransformer are these:
source = this.sourceResolver.resolve(src);
source.toSAX(consumer);
Does this mean that all it would take to generate a
SAX stream from the pipeline "foo" would be to execute
the code
this.sourceResolver.resolve("cocoon://foo");
source.toSAX(...)
And how does that work if the pipe invoked returns
non-XML content? Actually, it seems easier if someone
could tell me the code for invoking and outputting an
arbitrary Cocoon URI (so I could make the custom
serializer), but I have no idea how to do that.
Thanks,
Jim
--- Matthew Langham <ml...@s-und-n.de> wrote:
> Hi James,
>
> one solution that may help:
>
> Your Transformer -> Stylesheet ->
> CIncludeTransformer -> serializer
> :
> v
> pipeline (via: "cocoon://...")
>
> So the stylesheet constructs the URI from the data
> your transformer sends.
>
> Matthew
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
RE: XML-Based Selection (Redirect Serializer?)
Posted by Matthew Langham <ml...@s-und-n.de>.
Hi James,
one solution that may help:
Your Transformer -> Stylesheet -> CIncludeTransformer -> serializer
:
v
pipeline (via: "cocoon://...")
So the stylesheet constructs the URI from the data your transformer sends.
Matthew
--
Open Source Group sunShine - Lighting up e:Business
=================================================================
Matthew Langham, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
Tel:+49-5251-1581-30 mlangham@s-und-n.de - http://www.s-und-n.de
Weblogging at: http://www.need-a-cake.com
=================================================================
-----Original Message-----
From: James Burton [mailto:strangegames@yahoo.com]
Sent: Wednesday, February 27, 2002 12:10 PM
To: cocoon-dev@xml.apache.org
Subject: XML-Based Selection (Redirect Serializer?)
Hi all! We're working on a Cocoon 2 project and
*very* strongly need the ability to "branch" to a
different pipeline or part of a pipeline based on the
XML output of a Transformer. This is because we use a
custom Transformer for communicating with an EJB back
end. Originally I thought to use an XML selector like
this:
<map:match pattern="example">
<map:generate src="..." />
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:select type="xml" node="/result/flag">
<map:when test="normalResult">
<map:transform src="styles/normal.xsl" />
</map:when>
<map:when test="specialResult">
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:transform src="styles/special.xsl" />
</map:when>
</map:select>
<map:serialize />
</map:match>
However I found in the mail archives (Subject: XML
selector) that this method does not work because
Selectors have no access to the XML results of
Transformers. For similar reason a custom Matcher
wouldn't work either. But this functionality is
crucial!
Therefore, I wondered if it would be possible for me
to create a "redirecting serializer": one that would
call a different pipe (or a different resource) based
on the final XML feed. In other words something like
this:
<map:match pattern="example">
<map:generate src="..." />
<map:transform type="custom-ejb-interface">
...
</map:transform>
<map:serialize type="redirector">
<map:parameter name="node" value="result/flag" />
<map:parameter name="match1" value="normal" />
<map:parameter name="call1" value="normal-pipe" />
<map:parameter name="match2" value="special" />
<map:parameter name="call2" value="special-pipe"
/>
</map:select>
</map:match>
Can someone give me a hint for how to start
implementing this? I know how to make a Serializer,
but don't know what it would call to start invoking a
pipe with a different URL (I imagine it must be
similar to the implementation of <map:call>). Or, if
this is not going to work, could somebody let me know?
In that case, I think the only alternative left is to
make a serializer that issues an HTTP redirect to a
given URL based on its parameters; i.e. a
"RedirectSerializer". I would be happy to contribute
this serializer if I can get it to work.
Many thanks from Prague,
James Burton
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org