Hi,
The LinkRewritingTransformer might be your thing, but given that you
are using map:redirect, I suspect that it isn't. You could sub-class
XMLFileModule to dynamically provide the configuration you need via
modeConf (LinkRewritingTransformer provides the configuration this way).
You need to override the getAttribute() method, and create a
DefaultConfiguration object with an element of 'file' and a 'src'
attribute with the URI of the XML file to read; your suggested
xpointer syntax is nice (although my own version didn't bother with
that, and just used a fragment identifier to separate the URI and the
XPath).
i.e. you are programatically providing:
<file src="uri"/>
to the module via the modeConf. See the documentation for Avalon's
DefaultConfiguration object.
Beware of the caching though; document caching doesn't use the
Transient Cache, but instead a memory cache, which isn't even using
SoftReferences (although oddly the XPath cache does), so if you've
got a large or unlimited number of documents, turn caching off
entirely (look at the code for XMLFileModule), else you'll run the
risk of running out of memory.
Ellis.
On 2 May 2006, at 18:38, Andrew Stevens wrote:
In the Cocoon javadocs[1] it says that input modules are passed a
dynamic, per-request configuration which will usually override the
static configuration from the cocoon.xconf. However, neither the
javadocs nor the Input Modules Reference[2] in the docs give any
indication of how you actually do this. Is it talking about
something you can include in a pipeline, or somehow within the
{foo:bar} string of a sitemap parameter/attribute? Or is it simply
talking about the <map:component-configurations> section of the
pipeline? If the latter, is it possible to include these within a
pipeline matcher, and use any available sitemap variables in the
configured values?
My suspicion is the "dynamic" configuration isn't as dynamic as I
need. I have a number of XML files (using the same DTD) and need
to extract a value from one of them to pass into a map:redirect-to
(which file to use being supplied as part of the request). If I
was using a single file, I think I could handle it with the
XMLFileModule; judging from the URLEncode & decode input modules'
docs, it's okay to nest input module attributes (e.g. src="http://
remote/page?param1={url-encode:{request-param:param1}}"), so I
reckon something along the lines of <map:redirect-to uri="{xmlfile:/
document/[EMAIL PROTECTED]'{../1}'/url}"/> would work. With separate
files, I can just use {xmlfile:/document/link/url}, but how do I
specify for each request which file this is evaluated on?
If the XMLFileModule can't be used in this way, I guess I've got
two options:
- either write my own input module that takes an xinclude-like
expression as the attribute ({myxmlfile:{1}.xml#xpointer(/document/
link/url)}) specifying both the source file and jxpath
- or, (since the XMLFileModule user docs say the XML can be
obtained from any cocoon source) use the directory generator and c/
xinclude transformer in a separate pipeline to combine all the
files and configure the input module to use that pipeline as its
"file".
Or does anyone know of a better way?
Andrew.
[1] see under "Static/dynamic configuration" in http://
cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/modules/
input/package-summary.html
[2] http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]