cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: Using Xpath in Cocoon 1.8
Date Thu, 16 Nov 2000 18:08:52 GMT
Gerard Maas <gerard.maas@alcatel.be> wrote:
>After following the list for quite a while, the time has come when I'm
>hitting my head against a cocoonish rock ;-) and here I go...
>
>The point is the following: like many of you, I've some XML data that
>I'd like to include in my 'basis' XML page. This data is coming from a
>profile server in the form of a Java API call.  This data looks like:
>(fake data follows)
><person id="xxxx">
>     <name>
>         <first>John</first>
>         <last>Doe</last>
>     </name>
>     <preferences>
>         <cities>
>             <city>
>                 <name>NYC</name>
>                 <land> USA</land>
>             </city>
>             <city>
>                 <name>Caracas</name>
>                 <land>Venezuela</land>
>             </city>
>             . . .
>             . . .
>     </preferences>
></person>
>
>This data is included in my 'base' xml document to fill some
>placeholders: <insert source="query_name" path="//name/first">. A
>typical use will be to produce a VoiceXML page that says "Welcome back
>John [person/name/first], Which will be your selection today? NYC
>,Caracas,... ? [for-each preferences/cities/city]...
>
>This could be also in HTML form.
>
>I found no straightforward way to include arbitrary pieces of my XML
>Data into the static XML content,

There's quite a few ways in the website FAQ under site architecture issues, 
but none of them are exactly what you want.

>I used as reference the Documentation of Xalan at xml.apache.org, but it
>seems that the packaque included in Cocoon 1.8 doesn't have the same
>structure. org.apache.xalan.xpath vs org.apache.xpath
>My question is: first: where do I find the documentation for the version
>included in Cocoon 1.8?.

The version in Cocoon 1.8 is 1.2.D02. Download that version from Xalan 
website and in the full Xalan distribution you will find appropriate docs 
for that version (hopefully).

>2.- Am I making my life misserable with this approach?
>       Should I look at another way instead?
>
>I actually thought about inserting the XML Data into the document, and
>making a kind of XSLT tranformation based on the document itself, but I
>seemed to me that I was going to a black hole of complexity.

The trouble is, you can't dynamically compose XPath expressions in XSLT, 
based on XPath expressions in the XML source. This is a key limitation of 
XSLT - rigorous separation of input, instructions and output. Output (result 
tree fragments) can't feed back into input, and input is limited in terms of 
feeding into the instructions.

>Having XPath and Xslt  on board, writting somelike like eSQL for an XML
>data source seems just not right to me.

If only your data source was a file or URL (that's redundant, actually - 
files _are_ URLs), you could just use the XInclude processor. What I suggest 
is try basing your solution on the XInclude processor.

There is no documentation on the Cocoon site for Xinclude, but it's not 
needed because the only things you need to know are:

(1) The processing instruction is <?cocoon-process type="xinclude"?>
(2) The spec is at w3.org.


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Mime
View raw message