You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by SETIssl <se...@hlsw.org> on 2007/03/13 23:35:53 UTC
request parameter from sax stream/xml file to sitemap
hello, i need some advice for my document management application based on
cocoon.
i've got an xml-file with the structure
<document>
<docnorm/>
<sender/> <receiver/> <content/> ...
</document>
Now this file gets loaded into a pipeline with the file generator and
transformed in the next step by an xslt-transformer, which contains the
following template:
<xsl:template match="doknorm">
<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query>
SELECT norm_id FROM documents WHERE name = 'test'
</sql:query>
</sql:execute-query>
</xsl:template>
All working fine till here, the transformer gets the documents norm id
from the database and puts it in the sax stream(?) in the place where
<docnorm/> was before.
But now in the next step i need this norm_id value in the sitemap for
choosing the next transformation file related to the choosen norm.
I wrote the following pipeline code, which should be working fine, except
from the problem of getting the norm id value loaded as a parameter in
there (marked with ???):
<map:select type="parameter">
<map:parameter name="parameter-selector-test" value="???how to get norm
id in here???"/>
<map:when test="2">
<map:transform src="userfiles/common/xsl/gbrief2pdfDIN676A.xsl"
type="xslt">
</map:transform>
</map:when>
<map:when test="3">
<map:transform src="userfiles/common/xsl/gbrief2pdfDIN676B.xsl"
type="xslt">
</map:transform>
</map:when>
</map:select>
I found some similar entries by searching the mailing list, but nothing
clear that was useful for me so far.
I hope i explained my problem clear and somebody can help me with it, as
it is the last piece of my application puzzle :)
greetings Sebastian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: request parameter from sax stream/xml file to sitemap
Posted by SETIssl <se...@hlsw.org>.
"What makes this case really complicated is that you have a
two-step-processing of pipeline content. It would be much easier if you
could determine the norm_id directly"
Hm, thought this was, was actions are used for, among other things.
The Pipeline gets called from an HTML-Href-Link inside of an generated
html-file:
<xsl:attribute name="href">dokumente/anzeigen/pdf/<xsl:value-of
select="document-type"/>/<xsl:value-of select="userlogin"/>/<xsl:value-of
select="document-name"/>?realpath=<xsl:value-of
select="realpath"/></xsl:attribute>
<!-- Pipeline zur Anzeige von Dokumenten in PDF -->
<!-- {1}=doctype; {2}=login; {3}=docname;-->
<map:pipeline>
<map:match pattern="dokumente/anzeigen/pdf/*/*/*">
<map:select type="resource-exists">
<map:when
test="{request-param:realpath}/letterman/userfiles/{2}/docs/{3}.xml">
<map:generate src="userfiles/{2}/docs/{3}.xml" type="file"/>
...
So, when i got the "docname" {3} in the pipeline, would it be so hard to
insert a database select action there
and request the current norm_id for this document and use the response as
a parameter for further select-operations?
Problem is, i'm not familiar with the hole flowscript-programming
and i wouldn't like to mix up the Sitemap/Pipeline with the old
standard-elements
und the new flowscript-system, as it is an old programm which just
should be updated and expanded a little.
Am 29.04.2007, 12:31 Uhr, schrieb Joerg Heinicke <jo...@gmx.de>:
> On 23.04.2007 17:27, SETIssl wrote:
>
>> I tried to implement a DatabaseSelectAction like its described in the
>> docs and the api, but couldn't find any details or any kind of example
>> on how the request/the sitemap pipeline action part actually should
>> look like.
>
> From rereading the thread I get your case is more complex. The actions
> might not work or really complicate your sitemap a lot. I'd go with flow
> script.
>
> To clarify let me rephrase your steps:
> 1. Get a document from the document system. (How is determined which
> document?)
> 2. Parse it for whatever to retrieve norm_id with that information from
> the database.
> 3. Switch pipeline depending on this norm_id.
>
> What makes this case really complicated is that you have a
> two-step-processing of pipeline content. It would be much easier if you
> could determine the norm_id directly from the "How is determined which
> document?"-parameters without parsing pipeline content. Is that an
> option?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: request parameter from sax stream/xml file to sitemap
Posted by Joerg Heinicke <jo...@gmx.de>.
On 23.04.2007 17:27, SETIssl wrote:
> I tried to implement a DatabaseSelectAction like its described in the
> docs and the api, but couldn't find any details or any kind of example
> on how the request/the sitemap pipeline action part actually should look
> like.
From rereading the thread I get your case is more complex. The actions
might not work or really complicate your sitemap a lot. I'd go with flow
script.
To clarify let me rephrase your steps:
1. Get a document from the document system. (How is determined which
document?)
2. Parse it for whatever to retrieve norm_id with that information from
the database.
3. Switch pipeline depending on this norm_id.
What makes this case really complicated is that you have a
two-step-processing of pipeline content. It would be much easier if you
could determine the norm_id directly from the "How is determined which
document?"-parameters without parsing pipeline content. Is that an option?
Otherwise it could look like the following (you need 3 pipelines):
// same pattern as before
<map:match pattern="">
// delegate to a flow script function
<map:call function="processDocument"/>
</map:match>
// get document from document management
<map:match pattern="getDocument">
<map:generate/>
<map:serialize/>
</map:match>
// final processing
<map:match pattern="showDocument">
// it's probably possible to inject the document directly,
// otherwise get the document from document management again
<map:generate/>
<map:select type="parameter">
<map:parameter name="parameter-selector-test"
value="{flow-attr:norm-id}"/>
<map:when test="2">
<map:transform src="userfiles/common/xsl/gbrief2pdfDIN676A.xsl"
type="xslt">
</map:transform>
</map:when>
<map:when test="3">
<map:transform src="userfiles/common/xsl/gbrief2pdfDIN676B.xsl"
type="xslt">
</map:transform>
</map:when>
</map:select>
<map:serialize/>
</map:match>
flow script:
function processDocument() {
var pipelineUtil = // get pipelineUtil
var data = // data you might need to retrieve the document
var document = pipelineUtil.processToDOM("getDocument", data);
var normId = // get normId from the DOM
cocoon.sendPage("showDocument", {"norm-id": normId});
}
Hope this gets you the idea.
2 comments:
1. "getDocument" and "showDocument" should actually go into a
<map:pipeline internal-only="true"> section to prevent access from external.
2. And if you do the conversion of the norm_id values 2, 3, etc. to the
actual norm strings used in the xsl names in the flow script you can
refrain from the select in the pipeline:
function processDocument() {
...
var normId = // get normId from the DOM
var normName = convertNormIdToNormName(normId);
cocoon.sendPage("showDocument", {"norm-name": normName});
}
// final processing
<map:match pattern="showDocument">
// it's probably possible to inject the document directly,
// otherwise get the document from document management again
<map:generate/>
<map:transform src="userfiles/common/xsl/gbrief2pdf{norm-name}.xsl"
<map:serialize/>
</map:match>
Regards
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: request parameter from sax stream/xml file to sitemap
Posted by SETIssl <se...@hlsw.org>.
Thanks for your reply.
I tried to implement a DatabaseSelectAction like its described in the docs
and the api, but couldn't find any details or any kind of example on how
the request/the sitemap pipeline action part actually should look like.
so if anyone got this action type working or a link to a tutorial showing
the codeon an example, i would like to take a look at it.
grettings SETIssl
Am 14.03.2007, 08:01 Uhr, schrieb Joerg Heinicke <jo...@gmx.de>:
> On 13.03.2007 23:35, SETIssl wrote:
>
>> All working fine till here, the transformer gets the documents norm id
>> from the database and puts it in the sax stream(?) in the place where
>> <docnorm/> was before.
>> But now in the next step i need this norm_id value in the sitemap for
>> choosing the next transformation file related to the choosen norm.
>> I wrote the following pipeline code, which should be working fine,
>> except from the problem of getting the norm id value loaded as a
>> parameter in there (marked with ???):
>
> No chance up to now. Despite existing ideas content-based pipelines have
> never been implemented.
>
> You need to retrieve the database id before the pipeline is set up,
> either via flow script or via an action.
>
> Jörg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: request parameter from sax stream/xml file to sitemap
Posted by Joerg Heinicke <jo...@gmx.de>.
On 13.03.2007 23:35, SETIssl wrote:
> All working fine till here, the transformer gets the documents norm id
> from the database and puts it in the sax stream(?) in the place where
> <docnorm/> was before.
> But now in the next step i need this norm_id value in the sitemap for
> choosing the next transformation file related to the choosen norm.
> I wrote the following pipeline code, which should be working fine,
> except from the problem of getting the norm id value loaded as a
> parameter in there (marked with ???):
No chance up to now. Despite existing ideas content-based pipelines have
never been implemented.
You need to retrieve the database id before the pipeline is set up,
either via flow script or via an action.
Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org