forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Crossley <cross...@apache.org>
Subject explain sitemap matches and pass parameters to transformers
Date Wed, 26 Apr 2006 03:09:09 GMT
Web Maestro Clay wrote in thread "Re: ODT: adding":
> Ferdinand Soethe wrote:
> >Clay Leeds wrote:
> >
> >>Do you have a link or path to the file? I surfed svn a bit, and the
> >>Forrest HowTo section a bit, but couldn't find it.
> >
> >No but you could check if the sample file openoffice-writer-howto.sxw
> >still works ok and if so find out where it is processed. Probably as
> >part of the normal writer-document processing.
>
> Thanks! That was the clue I needed. It wasn't in the HowTo section...
> It was in the OOo-Writer section.
>
> I checked, and it doesn't help. It's done there the same way it was
> done in OOo (by passing the '$filename' xsl:variable). In addition to
> getting the data out of the meta.xml file, I'll have to figure out
> how to pass the variable through to the odt_to_xhtml.xsl stylesheet.
>
> Thanks for remembering!

There are explanations of this in our mail archives, e.g.
http://marc.theaimsgroup.com/?l=forrest-dev&m=112382352019400

I will spend some time to explain this again below
to hopefully add this to a doc later.

Also, when you need to find info like this try doing:
cd $FORREST_HOME/webapp
grep path *.xmap
vi linkmap.xmap
at around line 66 ...
<map:match pattern="**linkmap-*">
  <map:generate src="cocoon://abs-linkmap" />
  <map:transform src="{lm:transform.linkmap.linkmap-relativized}">
    <map:parameter name="path" value="{1}{2}" />
    <map:parameter name="site-root" value="{conf:project-url}" />
  </map:transform>
  <map:serialize type="xml" />
</map:match>

I hope that i don't confuse with that linkmap
example, but i don't have time to find a better one.
For each page that Cocoon processes, it does an internal
request for a map of links of the page. So a request for
localhost/samples/subdir/foo.html
will include an internal request for
localhost/samples/subdir/linkmap-foo.xml

To understand the value="{1}{2}" one needs to
understand the Cocoon sitemap. Here is one doc,
there might be better ones.
http://cocoon.apache.org/2.1/userdocs/matchers.html

Basically in the linkmap.xmap example above:
** matches path elements of the uri including /
* matches path elements of the uri excluding /
{1} is the first matched pattern
{2} is the second matched pattern
when tested against a uri like localhost/samples/subdir/linkmap-foo.html
{1} would yield "/samples/subdir/"
{2} would yield "foo.xml"

Here is another example. The match pattern "**/*.html"
when tested against a uri like localhost/samples/subdir/foo.html
{1} would yield "/samples/subdir"
{2} would yield "foo"
{0} would yield "/samples/subdir/foo.html"

Whereas this pattern "/*/*/*.html"
{1} would yield "samples"
{2} would yield "subdir"
{3} would yield "foo"
{0} would yield "/samples/subdir/foo.html"
and a uri like "/samples/bar.html" would not
be matched at all.

To complete the explanation, consider a regexp match
<map:match type="regexp" pattern="^(.*?)([^/]*).xml$">
when tested against a uri like localhost/samples/subdir/foo.xml
{1} would yield "/samples/subdir/"
{2} would yield "foo"

So getting back to our example linkmap.xmap
the <map:parameter name="path" value="{1}{2}" />
will pass a variable into that transformer replacing
those {1}{2} to become
<map:parameter name="path" value="/samples/subdir/foo.xml" />

Looking up the locationmap will find that the
transformer is webapp/resources/stylesheets/relativize-linkmap.xsl
and the $path variable is used in the stylesheet.

------
These other docs help with sitemap understanding:

http://forrest.apache.org/docs/dev/sitemap-ref.html
and see the Cocoon references.

http://forrest.apache.org/docs/dev/howto/howto-custom-html-source.html

We need FAQs or docs about these two or even combined topics:
* passing variables from sitemap to transformers
* interpreting sitemap matches

-David

Mime
View raw message