You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Brent Johnson <bl...@gmail.com> on 2004/11/01 20:38:03 UTC

Matching Subdirectories

I'm sure I am missing something key in the sitemap but I'm trying to
find a way to wildcard match to any number of subdirectories.  It
looks like the way to accomplish this is to use a matching like
"**/*.html" or something similar.  Problem is.. its not working as I
expected.

Here's my example (without subdirectories):

  <map:pipeline internal-only="true">
    <map:match pattern="blocks/*">
        <map:generate type="jx" src="public/blocks/{1}.jx"/>
        <map:serialize type="xml"/>
    </map:match>
  </map:pipeline>
  <map:pipeline type="noncaching">
    <map:match pattern="*.html">
        <map:call function="showPage">
            <map:parameter name="page" value="{1}"/>
        </map:call>
    </map:match>
    <map:match pattern="content/*.html">
        <map:generate type="jx" src="public/layouts/{1}.jx"/>
        <map:transform type="cinclude"/>
        <map:transform src="themes/{global:theme}/main.xsl"/>
        <map:serialize type="html"/>
    </map:match>
...etc...

Long story short.. the user requests "/index.html".. flow then does a
cocoon.sendPage("content/index.html", ...).  Then the JXTemplate
"public/layouts/index.jx" gets called.. which in turn does some
content aggregation of the pipeline "blocks/about.jx" which looks for
the file "public/blocks/about.jx."

Hope that doesnt sound too confusuing.  Anyways.. I want to be able to
match for "/whatever/dir/index.html".. which in turn looks in
"content/whatever/dir/index.html", which finds the file
"public/layouts/whatever/dir/index.jx".. etc.. same for the blocks.

I tried this with **/*.html and **/*.jx, etc... but this got
unpredictable results.  Most notably.. adding a match for **/*.html
along with a match for *.html (since apparently /index.html doesnt
match **/*.html) results in Cocoon just sending a blank page to the
browser.

Anyone tried anything like this?

Thanks.

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


Re: Matching Subdirectories [SOLVED]

Posted by Brent Johnson <bl...@gmail.com>.
OK - I figured out the problem.  Turns out matching on **/*.html will
work just fine (and **/*.jx, etc).  I was getting a blank page because
of this:

    <map:match pattern="**/*.html">
        <map:call function="showPage">
            <map:parameter name="page" value="{1}/{2}"/>
        </map:call>
    </map:match>

    <map:match pattern="content/**/*.html">
        <map:generate type="jx" src="public/layouts/{1}/{2}.jx"/>
        <map:transform type="cinclude"/>
        <map:transform src="themes/{global:theme}/main.xsl"/>
        <map:serialize type="html"/>
    </map:match>

I didnt think about the ordering of the sitemap.xmap matching :)  The
problem is.. the flow did a sendPage to "content/whatever/blah.html". 
Well guess what.. that matched the first **/*.html so it calls the
flow again.. and again.. and again.. and again.

So I reversed the matching putting the content stuff before **/*.html
and it works great.  I can now match HTML URLs, content, layout files
and blocks at any level I like.

Thanks.. your **/*/*.html just got me thinking about match ordering :)
 I also looked at the sitemap logged and saw
"/content/content/content/content/content/..../index.html" and knew
there had to be a problem.

- Brent

On Mon, 1 Nov 2004 22:25:25 +0100, Robin Wyles <ro...@robinwyles.com> wrote:
> Hi Brent,
> 
> If I understood you correctly I think a matcher like this might be what
> you need:
> 
>      <map:match pattern="**/*/*.html">
>          <map:generate type="jx" src="public/layouts/{1}/{2}/{3}.jx"/>
>          <map:transform type="cinclude"/>
>          <map:transform src="themes/{global:theme}/main.xsl"/>
>          <map:serialize type="html"/>
>      </map:match>
> 
> The ** corresponding to the {1} in the generate will be any number of
> directories in at the start of the uri.
> 
> The first *, {2} matches your directory name, and the last *, {3}
> matches the file name.
> 
> Hope this helps,
> 
> Robin
> 
> 
> 
> 
> On 1 Nov 2004, at 20:38, Brent Johnson wrote:
> 
> > I'm sure I am missing something key in the sitemap but I'm trying to
> > find a way to wildcard match to any number of subdirectories.  It
> > looks like the way to accomplish this is to use a matching like
> > "**/*.html" or something similar.  Problem is.. its not working as I
> > expected.
> >
> > Here's my example (without subdirectories):
> >
> >   <map:pipeline internal-only="true">
> >     <map:match pattern="blocks/*">
> >         <map:generate type="jx" src="public/blocks/{1}.jx"/>
> >         <map:serialize type="xml"/>
> >     </map:match>
> >   </map:pipeline>
> >   <map:pipeline type="noncaching">
> >     <map:match pattern="*.html">
> >         <map:call function="showPage">
> >             <map:parameter name="page" value="{1}"/>
> >         </map:call>
> >     </map:match>
> >     <map:match pattern="content/*.html">
> >         <map:generate type="jx" src="public/layouts/{1}.jx"/>
> >         <map:transform type="cinclude"/>
> >         <map:transform src="themes/{global:theme}/main.xsl"/>
> >         <map:serialize type="html"/>
> >     </map:match>
> > ...etc...
> >
> > Long story short.. the user requests "/index.html".. flow then does a
> > cocoon.sendPage("content/index.html", ...).  Then the JXTemplate
> > "public/layouts/index.jx" gets called.. which in turn does some
> > content aggregation of the pipeline "blocks/about.jx" which looks for
> > the file "public/blocks/about.jx."
> >
> > Hope that doesnt sound too confusuing.  Anyways.. I want to be able to
> > match for "/whatever/dir/index.html".. which in turn looks in
> > "content/whatever/dir/index.html", which finds the file
> > "public/layouts/whatever/dir/index.jx".. etc.. same for the blocks.
> >
> > I tried this with **/*.html and **/*.jx, etc... but this got
> > unpredictable results.  Most notably.. adding a match for **/*.html
> > along with a match for *.html (since apparently /index.html doesnt
> > match **/*.html) results in Cocoon just sending a blank page to the
> > browser.
> >
> > Anyone tried anything like this?
> >
> > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

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


Re: Matching Subdirectories

Posted by Brent Johnson <bl...@gmail.com>.
Hmm.. thats a little closer I think.  That's supposed to match
anything two subdirectories down.  I tried a "*/*.html" match and that
worked for one directory down.  I then tried your idea of
"**/*/*.html" and now I get no sitemap match (its trying to find a
sitemap in temp.. meaning it didnt match the **/*/*.html).

Hmmm... I'll keep poking around with it.

Thanks

- Brent

On Mon, 1 Nov 2004 22:25:25 +0100, Robin Wyles <ro...@robinwyles.com> wrote:
> Hi Brent,
> 
> If I understood you correctly I think a matcher like this might be what
> you need:
> 
>      <map:match pattern="**/*/*.html">
>          <map:generate type="jx" src="public/layouts/{1}/{2}/{3}.jx"/>
>          <map:transform type="cinclude"/>
>          <map:transform src="themes/{global:theme}/main.xsl"/>
>          <map:serialize type="html"/>
>      </map:match>
> 
> The ** corresponding to the {1} in the generate will be any number of
> directories in at the start of the uri.
> 
> The first *, {2} matches your directory name, and the last *, {3}
> matches the file name.
> 
> Hope this helps,
> 
> Robin
> 
> 
> 
> 
> On 1 Nov 2004, at 20:38, Brent Johnson wrote:
> 
> > I'm sure I am missing something key in the sitemap but I'm trying to
> > find a way to wildcard match to any number of subdirectories.  It
> > looks like the way to accomplish this is to use a matching like
> > "**/*.html" or something similar.  Problem is.. its not working as I
> > expected.
> >
> > Here's my example (without subdirectories):
> >
> >   <map:pipeline internal-only="true">
> >     <map:match pattern="blocks/*">
> >         <map:generate type="jx" src="public/blocks/{1}.jx"/>
> >         <map:serialize type="xml"/>
> >     </map:match>
> >   </map:pipeline>
> >   <map:pipeline type="noncaching">
> >     <map:match pattern="*.html">
> >         <map:call function="showPage">
> >             <map:parameter name="page" value="{1}"/>
> >         </map:call>
> >     </map:match>
> >     <map:match pattern="content/*.html">
> >         <map:generate type="jx" src="public/layouts/{1}.jx"/>
> >         <map:transform type="cinclude"/>
> >         <map:transform src="themes/{global:theme}/main.xsl"/>
> >         <map:serialize type="html"/>
> >     </map:match>
> > ...etc...
> >
> > Long story short.. the user requests "/index.html".. flow then does a
> > cocoon.sendPage("content/index.html", ...).  Then the JXTemplate
> > "public/layouts/index.jx" gets called.. which in turn does some
> > content aggregation of the pipeline "blocks/about.jx" which looks for
> > the file "public/blocks/about.jx."
> >
> > Hope that doesnt sound too confusuing.  Anyways.. I want to be able to
> > match for "/whatever/dir/index.html".. which in turn looks in
> > "content/whatever/dir/index.html", which finds the file
> > "public/layouts/whatever/dir/index.jx".. etc.. same for the blocks.
> >
> > I tried this with **/*.html and **/*.jx, etc... but this got
> > unpredictable results.  Most notably.. adding a match for **/*.html
> > along with a match for *.html (since apparently /index.html doesnt
> > match **/*.html) results in Cocoon just sending a blank page to the
> > browser.
> >
> > Anyone tried anything like this?
> >
> > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

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


Re: Matching Subdirectories

Posted by Robin Wyles <ro...@robinwyles.com>.
Hi Brent,

If I understood you correctly I think a matcher like this might be what 
you need:

     <map:match pattern="**/*/*.html">
         <map:generate type="jx" src="public/layouts/{1}/{2}/{3}.jx"/>
         <map:transform type="cinclude"/>
         <map:transform src="themes/{global:theme}/main.xsl"/>
         <map:serialize type="html"/>
     </map:match>

The ** corresponding to the {1} in the generate will be any number of 
directories in at the start of the uri.

The first *, {2} matches your directory name, and the last *, {3} 
matches the file name.

Hope this helps,

Robin


On 1 Nov 2004, at 20:38, Brent Johnson wrote:

> I'm sure I am missing something key in the sitemap but I'm trying to
> find a way to wildcard match to any number of subdirectories.  It
> looks like the way to accomplish this is to use a matching like
> "**/*.html" or something similar.  Problem is.. its not working as I
> expected.
>
> Here's my example (without subdirectories):
>
>   <map:pipeline internal-only="true">
>     <map:match pattern="blocks/*">
>         <map:generate type="jx" src="public/blocks/{1}.jx"/>
>         <map:serialize type="xml"/>
>     </map:match>
>   </map:pipeline>
>   <map:pipeline type="noncaching">
>     <map:match pattern="*.html">
>         <map:call function="showPage">
>             <map:parameter name="page" value="{1}"/>
>         </map:call>
>     </map:match>
>     <map:match pattern="content/*.html">
>         <map:generate type="jx" src="public/layouts/{1}.jx"/>
>         <map:transform type="cinclude"/>
>         <map:transform src="themes/{global:theme}/main.xsl"/>
>         <map:serialize type="html"/>
>     </map:match>
> ...etc...
>
> Long story short.. the user requests "/index.html".. flow then does a
> cocoon.sendPage("content/index.html", ...).  Then the JXTemplate
> "public/layouts/index.jx" gets called.. which in turn does some
> content aggregation of the pipeline "blocks/about.jx" which looks for
> the file "public/blocks/about.jx."
>
> Hope that doesnt sound too confusuing.  Anyways.. I want to be able to
> match for "/whatever/dir/index.html".. which in turn looks in
> "content/whatever/dir/index.html", which finds the file
> "public/layouts/whatever/dir/index.jx".. etc.. same for the blocks.
>
> I tried this with **/*.html and **/*.jx, etc... but this got
> unpredictable results.  Most notably.. adding a match for **/*.html
> along with a match for *.html (since apparently /index.html doesnt
> match **/*.html) results in Cocoon just sending a blank page to the
> browser.
>
> Anyone tried anything like this?
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


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