You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Perez <cr...@yahoo.es> on 2005/05/23 11:06:27 UTC

Conditional branching

Hi all,

I need branching depending on the current contents of some tag in the 
XML at a given pipeline step.

So the first thing comes up to my mind is to use a matcher.
I've found the WildcardParameterMatcher that allows me to use sitemap 
variable and an input module called XmlFileModule. 
This input module allows me to use any XPath expression of any pipeline.
The problem is how can I pass the current XML flow to the XmlFileModule?
The generator isn't file based, it parses the body of a post request.

Here is a possible sketch of this solution:

<map:match pattern="myurl">
    <map:generate type="mygenerator"/>
    <map:transform pattern="sheet1.xsl"/>
    <!--I would like to branch here if  /*/branching-tag='valueA'-->
    <map:match type="wildcard-param" pattern="valueA">
        <map:parameter name="parameter-name" value="my-param"/>
        <map:parameter name="my-param" 
value="{xml-file-module:/*/branching-tag}"/>
        <map:transform pattern="sheet2a.xsl"/>
       <map:serialize/>
    </map:match>
    <map:transform pattern="sheet2b.xsl"/>
    <map:serialize type='myserializer'>
  </map:match>

Has anyone tried any better solution?
Is this solution viable?

Thanks in advance for any hint.

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


Re: Conditional branching

Posted by David Perez <cr...@yahoo.es>.
Reinhard Poetz schrieb:

Thanks Reinhard,
Please, any good keyword for searching the archives?
I've tried "branching" and "xml stream" with no luck.

> David Perez wrote:
>
>> Hi all,
>>
>> I need branching depending on the current contents of some tag in the 
>> XML at a given pipeline step.
>>
>> So the first thing comes up to my mind is to use a matcher.
>> I've found the WildcardParameterMatcher that allows me to use sitemap 
>> variable and an input module called XmlFileModule. This input module 
>> allows me to use any XPath expression of any pipeline.
>> The problem is how can I pass the current XML flow to the XmlFileModule?
>> The generator isn't file based, it parses the body of a post request.
>>
>> Here is a possible sketch of this solution:
>>
>> <map:match pattern="myurl">
>>    <map:generate type="mygenerator"/>
>>    <map:transform pattern="sheet1.xsl"/>
>>    <!--I would like to branch here if  /*/branching-tag='valueA'-->
>>    <map:match type="wildcard-param" pattern="valueA">
>>        <map:parameter name="parameter-name" value="my-param"/>
>>        <map:parameter name="my-param" 
>> value="{xml-file-module:/*/branching-tag}"/>
>>        <map:transform pattern="sheet2a.xsl"/>
>>       <map:serialize/>
>>    </map:match>
>>    <map:transform pattern="sheet2b.xsl"/>
>>    <map:serialize type='myserializer'>
>>  </map:match>
>>
>> Has anyone tried any better solution?
>> Is this solution viable?
>>
>> Thanks in advance for any hint.
>
>
> Branching based on the content of the XML stream is disallowed by 
> design. There have been some discussions about this that can be found 
> in the archives of the users and the dev mailing list.
>


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


Re: Conditional branching

Posted by Reinhard Poetz <re...@apache.org>.
David Perez wrote:
> Hi all,
> 
> I need branching depending on the current contents of some tag in the 
> XML at a given pipeline step.
> 
> So the first thing comes up to my mind is to use a matcher.
> I've found the WildcardParameterMatcher that allows me to use sitemap 
> variable and an input module called XmlFileModule. This input module 
> allows me to use any XPath expression of any pipeline.
> The problem is how can I pass the current XML flow to the XmlFileModule?
> The generator isn't file based, it parses the body of a post request.
> 
> Here is a possible sketch of this solution:
> 
> <map:match pattern="myurl">
>    <map:generate type="mygenerator"/>
>    <map:transform pattern="sheet1.xsl"/>
>    <!--I would like to branch here if  /*/branching-tag='valueA'-->
>    <map:match type="wildcard-param" pattern="valueA">
>        <map:parameter name="parameter-name" value="my-param"/>
>        <map:parameter name="my-param" 
> value="{xml-file-module:/*/branching-tag}"/>
>        <map:transform pattern="sheet2a.xsl"/>
>       <map:serialize/>
>    </map:match>
>    <map:transform pattern="sheet2b.xsl"/>
>    <map:serialize type='myserializer'>
>  </map:match>
> 
> Has anyone tried any better solution?
> Is this solution viable?
> 
> Thanks in advance for any hint.

Branching based on the content of the XML stream is disallowed by design. There 
have been some discussions about this that can be found in the archives of the 
users and the dev mailing list.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------


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