On Apr 14, 2008, at 7:43 AM, Carlos Tejo Alonso wrote:
Hello,
I was doing some research about how to obtain a xml from a xml file
+ an XPATH expression in Cocoon, but I haven't found any
information really clear. Is there any parameter to add into a
generator, or a transformer or something that can do that issue?
It does seem odd to me that there isn't a simple xpath transformer or
generator in cocoon,
but in any case there do seem to be several ways to do the equivalent
thing.
I've been trying to do this by using JX to generate an xml file with
an xinclude statement
with the file and an xpointer fragment identifier, and then running
it thru the xinclude
transformer.
In my sitemap is:
<map:pipeline>
<map:match pattern="xpath/*/*/**">
<map:generate type="jx" src="scripts/xpath.jx" >
<map:parameter name="instdir" value="{1}" />
<map:parameter name="file" value="{2}" />
<map:parameter name="path" value="/{3}" />
</map:generate>
<map:transform type="xinclude" />
<map:serialize type="xml" />
</map:match>
</map:pipeline>
[ ** I believe I have type="jx" redefined to use "newjx"
so I didn't have to change all of my sitemaps. ** ]
The jx template file ( xpath.jx ) contains:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="../published/${cocoon.parameters.instdir}/$
{cocoon.parameters.file}#xpointer(/${cocoon.parameters.path})"
/>
</fragment>
And, given a valid file and xpath expression, it works properly
( yielding the value of the xpointer expression wrapped in
<fragment>...</fragment> tags )
except that (using cocoon 2.1.11) I get the following deprecation
warning:
WARN (2008-04-14) 16:26.33:681 [sitemap.transformer.xinclude] (/
cocoon/vivaead/xpath/odu/vino00012.xml/eadheader/eadid) http-8080-
Processor23/XIncludeTransformer.XIncludePipe: Fragment identifer
found in 'href' attribute: ../published/odu/vino00012.xml#xpointer(//
eadheader/eadid)Fragment identifiers are forbidden by the XInclude
specification. They are still handled by XIncludeTransformer for
backward compatibility, but their use is deprecated and will be
prohibited in a future release. Use the 'xpointer' attribute instead.
Changing the xinclude to use a xpointer attribute, instead of a
xpointer #fragment-id eliminates that warning:
<xi:include href="../published/${cocoon.parameters.instdir}/$
{cocoon.parameters.file}"
parse="xml" xpointer="xpointer(/${cocoon.parameters.path})"
/>
[ You could also use the JXP XPATH API directly from flowscript/
javaflow,
and you could also probably pass a DOM or some other object model
to jx transformer. ]
-- Steve Majewski / UVA Alderman Library
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]