You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Corey Keith <ck...@loc.gov> on 2003/05/01 04:57:02 UTC

Dynamic transformation from value in xml document

A newbie question here so I may be overlooking the obvious but anyway...
  I've got a pretty simple pipeline but I'd like to use an attribute
value from my generated document to determine the transformation xslt. 
For something like this:

<map:match pattern="*">
  <map:generate src="mets/{1}.xml"/>
  <map:transform src="xslt/{a value from {1}.xml}.xsl">
    <map:parameter name="use-request-parameters" value="true"/>
  </map:transform>
</map:match>

So for example if the request was 
http://localhost/cocoon/12345
and 12345.xml had an attribute on the root node called type with the
value of "book":

<map:match pattern="*">
  <map:generate src="mets/12345.xml"/>
  <map:transform src="xslt/book.xsl">
    <map:parameter name="use-request-parameters" value="true"/>
  </map:transform>
</map:match>  

I was thinking about writing an action which I would pass the source
document location and then sax parse to obtain my value and return that
to the sitemap for later processing.  Does this sound reasonable?  It
seems as if there should be an easier solution.

Thanks,
Corey

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Dynamic transformation from value in xml document

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Hi:

Can you explain what are you trying to do. I mean the target not the
approach you are trying to use. The approach is clear below.

Why you need an attribute or element inside an XML file to define the
stylesheet you need to use?

Maybe there is another approach more friendly that will have the same
target as you need.

But is you still want to continue with this approach your can use XPointer
inside ONLY ONE XSL file with all the posible configurations and after
reading the attribute or element you can then define what pattern apply.
This is just another approach to target the same....

Best Regards,

Antonio Gallardo

Joerg Heinicke dijo:
> Hello Corey,
>
> the action is the correct solution, if you do it the way you want. But
> in my opinion already the way is wrong! The XML should not have
> influence on the selection of the XSLT. This is the old behaviour in
> Cocoon 1 where the XSLT processing was driven by a processing
> instruction in the XML.
>
> Joerg
>
> Corey Keith wrote:
>> A newbie question here so I may be overlooking the obvious but
>> anyway...
>>   I've got a pretty simple pipeline but I'd like to use an attribute
>> value from my generated document to determine the transformation xslt.
>>  For something like this:
>>
>> <map:match pattern="*">
>>   <map:generate src="mets/{1}.xml"/>
>>   <map:transform src="xslt/{a value from {1}.xml}.xsl">
>>     <map:parameter name="use-request-parameters" value="true"/>
>>   </map:transform>
>> </map:match>
>>
>> So for example if the request was
>> http://localhost/cocoon/12345
>> and 12345.xml had an attribute on the root node called type with the
>> value of "book":
>>
>> <map:match pattern="*">
>>   <map:generate src="mets/12345.xml"/>
>>   <map:transform src="xslt/book.xsl">
>>     <map:parameter name="use-request-parameters" value="true"/>
>>   </map:transform>
>> </map:match>
>>
>> I was thinking about writing an action which I would pass the source
>> document location and then sax parse to obtain my value and return
>> that to the sitemap for later processing.  Does this sound reasonable?
>>  It seems as if there should be an easier solution.
>>
>> Thanks,
>> Corey
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Dynamic transformation from value in xml document

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Corey,

the action is the correct solution, if you do it the way you want. But 
in my opinion already the way is wrong! The XML should not have 
influence on the selection of the XSLT. This is the old behaviour in 
Cocoon 1 where the XSLT processing was driven by a processing 
instruction in the XML.

Joerg

Corey Keith wrote:
> A newbie question here so I may be overlooking the obvious but anyway...
>   I've got a pretty simple pipeline but I'd like to use an attribute
> value from my generated document to determine the transformation xslt. 
> For something like this:
> 
> <map:match pattern="*">
>   <map:generate src="mets/{1}.xml"/>
>   <map:transform src="xslt/{a value from {1}.xml}.xsl">
>     <map:parameter name="use-request-parameters" value="true"/>
>   </map:transform>
> </map:match>
> 
> So for example if the request was 
> http://localhost/cocoon/12345
> and 12345.xml had an attribute on the root node called type with the
> value of "book":
> 
> <map:match pattern="*">
>   <map:generate src="mets/12345.xml"/>
>   <map:transform src="xslt/book.xsl">
>     <map:parameter name="use-request-parameters" value="true"/>
>   </map:transform>
> </map:match>  
> 
> I was thinking about writing an action which I would pass the source
> document location and then sax parse to obtain my value and return that
> to the sitemap for later processing.  Does this sound reasonable?  It
> seems as if there should be an easier solution.
> 
> Thanks,
> Corey


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org