[daisy] Parameterizing an include using a field value..

Marc Portier mpo at outerthought.org
Wed Apr 4 01:40:42 CDT 2007



Alan Mortensen wrote:
> I've seen this done with daisy content using queries, but I want to do
> it with external (or more specifically cocoon:) URLs.  The situation is
> kind of like this:
> 
> DocumentType: Category
> Name: Blue
> 
> and either through include or through a custom publisher request I'd
> like to include:
> 
> cocoon://ext/mysearch/Blue
> 
> Which returns XML formatted data from a database.
> 

yummy!

> Hrm.. another way to say it is: I'd like to parameterize an external
> include based on the data in a document..
> 
> What's the best way to do this.. or at least ANY way to do this?
> 

I'ld go for modifying the document-specific styling for that document
and insert the url there

that xslt should have access to the fields

what you need to 'leave' in the xslt output is a tag to be picked up by
Daisy's include-transformer (a daisy provided cocoon component)

the tag looks like this:

  <einclude:include
      xmlns:einclude="http://outerx.org/daisy/1.0#externalinclude"
      src="cocoon:/ext/mysearch/{fielvalue-or-docname}" />


note though that this include-transformer is at the end of the pipeline,
so it is fit to insert a ready HTML blurp (not XML). In other words your
extension-pipeline should be doing his part of the html rendering already.

HTH,
-marc= ((loosing the fight to resist) adding that this is the kind of
stuff our Daisy Workshop is addressing...)

PS: by the way: living in these 'modern ajax times' you might also opt
to fetch this stuff asynchronously (might turn out easier)


> I've been pulling my hair out a bit so far.  I don't see a way to do it

uhuh, never looked at myself as a hair-protecting shampoo,
nevertheless I'm hoping the above advise will be effective in this area
as well :-)

> in the pub request itself.  I don't see how in the document content to
> insert a value like the name or field FOO into an include.  I finally
> resorted to trying to get the document using the document() method in
> the document-styling XSL which I know is hacky (and at this time not
> working for me) but I don't know what else to do..
> 

interesting approach, without wanting to judge the hack-level this
should work imho, what error do you get?

> The reason I need to do this is that there are a large number of
> Category documents, and the users are not exactly tech savvy.  So
> instead of requiring them to put in the include with the URL correctly
> in every category document (it's a bit more complex a URL than the
> example) or me having to edit each document I was hoping I could just
> have them enter a field and be done with it.
> 
> Oh, and if it wasn't clear, I'd like the include to be associated with
> the type or the pubrequest somehow, just the parameter should change per
> instance document.
> 

attaching it to the type is easy through 'document-specific styling'
(see http://cocoondev.org/daisydocs-2_0/374-cd/g1/26-cd.html)

if you want to let the chosen publisher request have a say in this, then
you should leave a @styleHint in there
(see http://cocoondev.org/daisydocs-2_0/373-cd/194-cd.html)

> Alan

cool stuff, mate!
-marc=


More information about the daisy mailing list