cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Johnston" ...@lojjic.net>
Subject Re: Content negiation / fallback if document not found
Date Fri, 13 Jan 2006 17:10:35 GMT
> Hi!
>
> I want to do something like Apache Webserver's content negotiation using
> MultiViews with Cocoon.
>
> For example, I have documents like this:
>
>   doc.de.xml
>   doc.fr.xml
>   doc.xml    (default language)
>
> And want to do something like this:
>
>   <map:act type="locale">
>     <map:match pattern="doc">
>       try {
>         <map:generate src="doc.{../language}.xml"/>
>       } catch (FileNotFoundException e) {
>         <map:generate src="doc.xml"/>
>       }
>       <map:serialize/>
>     </map:match>
>   </map:act>
>
> Is something like this possible?
>

Does the ResourceExistsSelector meet your need?
http://cocoon.apache.org/2.1/userdocs/resourceexists-selector.html

<map:act type="locale">
   <map:match pattern="doc">
      <map:select type="resource-exists">
         <map:when test="doc.{../language}.xml>
            <map:generate src="doc.{../language}.xml"/>
         </map:when>
         <map:otherwise>
            <map:generate src="doc.xml"/>
         </map:otherwise>
      </map:select>
      <map:serialize/>
   </map:match>
</map:act>


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


Mime
View raw message