You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@forrest.apache.org by Ross Gardler <rg...@apache.org> on 2005/09/05 09:16:54 UTC

Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Helena Edelson wrote:
> I mean how in *xdocs* files would you do the equivalent of @author_id or:
> 
> <a href="../by_author_{author_id}.html">{name}</a>

I'm still not sure what you mean, where is the {author_id} parameter 
coming from? That is, what supplies that value for this token?

Like I said earlier, there is an author element in the XDoc, can't you 
just use that with a custom transformation to give you the link you want?

If the author tag is no use to you then you need to create your own 
pipelines to do these replacements. There are a number of ways of doing 
it. Perhaps the easiest way, if you do not have detailed Cocoon 
knowledge, is to use an XSLT transformation to do the replacements. You 
need to pass the values in to the transformation and have the XSLT do 
the replacements, see my earlier reply (copied below) for a hint on how 
to do this.

You may also consider using the JXTempalteTransformer 
http://cocoon.apache.org/2.1/userdocs/transformers/jx-template-transformer.html

Another alternative is XSP: 
http://cocoon.apache.org/2.1/userdocs/xsp/index.html

If you more clearly define the problem we can probably give you more 
direct help, i.e. code examples.

> on the second, I mean how to write the line of code, I'm not sure what 
> the $x or @x I have to look at the number of entries of type foo and 
> only show say 4 of the total number in an xsl file. how you would write 
> the value to stop at and the ($entries.......)*] part
> does that make any sense at all?

I'm reeally not sure I am understranding your problem. The xsl is:

<xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">

If you want to pass the number of elements being processed in as a 
parameter then see my earlier response which tells you how to find 
examples in our source code.

Note, this list is not the best place to get help with XSLT. If you need 
more help with XSLT I'd recomend taking a look at the tutorials on 
http://www.zvon.org

Ross

> 
> thx
> Holly
> 
> 
> 
> Ross Gardler wrote:
> 
>> Helena Edelson wrote:
>>
>>> I know how to code for forrest for this link in the xsl files:
>>>
>>> <a href="../by_author_holly.html">Holly Edelson</a>
>>>
>>> but how do you code for this sort of link in an xdocs/*.xml file?
>>> can I put dynamic code there?
>>
>>
>> In what way is it dynamic? Isn't the authors tag sufficient?
>>
>> http://forrest.apache.org/dtdx/document-v20.dtdx.html#authors
>>
>>> Also, how, for  src/xdocs/index.xml file can you code the xsl for it 
>>> to count the entries in the /meta-data/foo.xml, set a max integer 
>>> (value) for to generate on the xdocs/index.html page when you run 
>>> forrest to only show x number of entries for category foo if exists 
>>> and not show the rest?
>>>
>>> I mean, say I have type foo and type bar in my meta-data/foo.xml 
>>> file. Say I have 10 items of type foo and 10 items of type bar, but I 
>>> only want the generated home page (html) to display 4 per type?
>>> is it like <xsl:for-each select="articles/article[ type= foo][ 
>>> *position() &lt; ($entries+1)* ]">?
>>>                                                                                                       
>>> ->this is where I don't have a clue
>>
>>
>> Do you mean you want to know how to pass the value of $entries into 
>> the XSL?
>>
>> If so take a look at our sitemaps, there are lots of examples. Search 
>> for "<map:paramter"
>>
>> You could also pass it in using a configuraiton file. You can also see 
>> examples of this in our skins, search for "$config".
>>
>> Ross
>>
>>


Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> I reckon Helena wants a piece of code (maybe a plugin) that looks up
> meta-data (meta/foo.xml) and provides links "like" google about authors
> and their articles. 
> 
> Like I understood it she wants to have 2 different pages for that.
> e.g. overview page (generated from meta/foo.xml):
> <a href="../by_author_thorsten.html">All articles by thorsten</a>
> <a href="../by_author_ross.html">All articles by ross</a>
> ...

Oh, OK. If that is the case then take a look at the seed-business site 
in SVN head. It does that with resumes for staff, i.e. show me all the 
staff with skill XYZ. The "clever" bits are in the resume plugin (in 
whiteboard). It works, but needs improving...

> Helena we do not use yet metadata in forrest. What you are planing to do
> would IMO be a good plugin, but you would need to write it. AFAIK nobody
> have done that before. Besides that it is far more then a user question
> and should better discussed on dev. 

Actually, Tim recently committed an example plugin to our whiteboard 
that uses meta-data to do this, it looks like a better way of achieving 
what I did with the Resume plugin, but I've not got around to looking at 
how to integrate it yet.

These two whiteboard plugins would be a great starting point for Helena, 
if Thorsten has interpreted the question correctly and this is indeed 
what you want to do you could take a look at that and join us on the dev 
list to extend its functionlaity.

Ross

Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Posted by Thorsten Scherler <th...@apache.org>.
I reckon Helena wants a piece of code (maybe a plugin) that looks up
meta-data (meta/foo.xml) and provides links "like" google about authors
and their articles. 

Like I understood it she wants to have 2 different pages for that.
e.g. overview page (generated from meta/foo.xml):
<a href="../by_author_thorsten.html">All articles by thorsten</a>
<a href="../by_author_ross.html">All articles by ross</a>
...

Then each by_author_*.html should contain links to the articles the
author wrote in a paginator style view (as well generated from
meta/foo.xml or by a xpath dir generator?).
e.g. All articles by ross
<a href="site:some/site">ross on plugins</a>
...

http://cocoon.apache.org/2.1/howto/howto-paginator-transformer.html

Helena we do not use yet metadata in forrest. What you are planing to do
would IMO be a good plugin, but you would need to write it. AFAIK nobody
have done that before. Besides that it is far more then a user question
and should better discussed on dev. 

Please follow Ross tips. ;-)

salu2

On Mon, 2005-09-05 at 08:16 +0100, Ross Gardler wrote: 
> Helena Edelson wrote:
> > I mean how in *xdocs* files would you do the equivalent of @author_id or:
> > 
> > <a href="../by_author_{author_id}.html">{name}</a>
> 
> I'm still not sure what you mean, where is the {author_id} parameter 
> coming from? That is, what supplies that value for this token?
> 
> Like I said earlier, there is an author element in the XDoc, can't you 
> just use that with a custom transformation to give you the link you want?
> 
> If the author tag is no use to you then you need to create your own 
> pipelines to do these replacements. There are a number of ways of doing 
> it. Perhaps the easiest way, if you do not have detailed Cocoon 
> knowledge, is to use an XSLT transformation to do the replacements. You 
> need to pass the values in to the transformation and have the XSLT do 
> the replacements, see my earlier reply (copied below) for a hint on how 
> to do this.
> 
> You may also consider using the JXTempalteTransformer 
> http://cocoon.apache.org/2.1/userdocs/transformers/jx-template-transformer.html
> 
> Another alternative is XSP: 
> http://cocoon.apache.org/2.1/userdocs/xsp/index.html
> 
> If you more clearly define the problem we can probably give you more 
> direct help, i.e. code examples.
> 
> > on the second, I mean how to write the line of code, I'm not sure what 
> > the $x or @x I have to look at the number of entries of type foo and 
> > only show say 4 of the total number in an xsl file. how you would write 
> > the value to stop at and the ($entries.......)*] part
> > does that make any sense at all?
> 
> I'm reeally not sure I am understranding your problem. The xsl is:
> 
> <xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">
> 
> If you want to pass the number of elements being processed in as a 
> parameter then see my earlier response which tells you how to find 
> examples in our source code.
> 
> Note, this list is not the best place to get help with XSLT. If you need 
> more help with XSLT I'd recomend taking a look at the tutorials on 
> http://www.zvon.org
> 
> Ross
> 
> > 
> > thx
> > Holly
> > 
> > 
> > 
> > Ross Gardler wrote:
> > 
> >> Helena Edelson wrote:
> >>
> >>> I know how to code for forrest for this link in the xsl files:
> >>>
> >>> <a href="../by_author_holly.html">Holly Edelson</a>
> >>>
> >>> but how do you code for this sort of link in an xdocs/*.xml file?
> >>> can I put dynamic code there?
> >>
> >>
> >> In what way is it dynamic? Isn't the authors tag sufficient?
> >>
> >> http://forrest.apache.org/dtdx/document-v20.dtdx.html#authors
> >>
> >>> Also, how, for  src/xdocs/index.xml file can you code the xsl for it 
> >>> to count the entries in the /meta-data/foo.xml, set a max integer 
> >>> (value) for to generate on the xdocs/index.html page when you run 
> >>> forrest to only show x number of entries for category foo if exists 
> >>> and not show the rest?
> >>>
> >>> I mean, say I have type foo and type bar in my meta-data/foo.xml 
> >>> file. Say I have 10 items of type foo and 10 items of type bar, but I 
> >>> only want the generated home page (html) to display 4 per type?
> >>> is it like <xsl:for-each select="articles/article[ type= foo][ 
> >>> *position() &lt; ($entries+1)* ]">?
> >>>                                                                                                       
> >>> ->this is where I don't have a clue
> >>
> >>
> >> Do you mean you want to know how to pass the value of $entries into 
> >> the XSL?
> >>
> >> If so take a look at our sitemaps, there are lots of examples. Search 
> >> for "<map:paramter"
> >>
> >> You could also pass it in using a configuraiton file. You can also see 
> >> examples of this in our skins, search for "$config".
> >>
> >> Ross
> >>
> >>
> 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Posted by Thorsten Scherler <th...@apache.org>.
On Mon, 2005-09-05 at 15:59 +0100, Ross Gardler wrote:
> Helena Edelson wrote:
> > <xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">
> >   
> > I think the directive I am not understanding is what
> > position() &lt; 5 
> > is doing. Is it checking an array or vector of types and saying if not null
> > return 0-4?
> 
> The last part simply says if the position of a node within the list of 
> nodes returned by the previous statements is leff than 5 then include it 
> in the result set. Anything in a square bracket is a test.
> 
> > And I then have those ready for my out.print?
> 
> Not sure what you mean by out.print, there is no such concept in XSLT. 
> However, yes, the nodes that pass the tests in the XPath statement are 
> available to whatever you have inside the for-each loop.
> 
> Like I said earlier this list is not a good place to be looking for 
> general XSLT help. You would be far better going through the tutorials 
> on http://www.zvon.org, of course, if you have an XSLT problem specific 
> to Forrest, we will be glad to help.
> 

In addition, one of the best (if not *the* best) xsl mailing list on the
planet:
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To subscribe, go to: http://lists.mulberrytech.com/xsl-list/

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Posted by Ross Gardler <rg...@apache.org>.
Helena Edelson wrote:
> <xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">
>   
> I think the directive I am not understanding is what
> position() &lt; 5 
> is doing. Is it checking an array or vector of types and saying if not null
> return 0-4?

The last part simply says if the position of a node within the list of 
nodes returned by the previous statements is leff than 5 then include it 
in the result set. Anything in a square bracket is a test.

> And I then have those ready for my out.print?

Not sure what you mean by out.print, there is no such concept in XSLT. 
However, yes, the nodes that pass the tests in the XPath statement are 
available to whatever you have inside the for-each loop.

Like I said earlier this list is not a good place to be looking for 
general XSLT help. You would be far better going through the tutorials 
on http://www.zvon.org, of course, if you have an XSLT problem specific 
to Forrest, we will be glad to help.

>  There are some things we
> need to create to make forrest more friendly for non-extranet sites I
> suspect

We are always interested in any custisations that users need to make. If 
you need them, it is likely others will too so we would like to work 
with you to incorporate relavent changes into Forrest itself.

Ross

Re: coding dynamicall in xdocs/ and to delimit output in meta-data?

Posted by Helena Edelson <he...@greenjaguar.com>.
Hi

<xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">
  
I think the directive I am not understanding is what
position() &lt; 5 
is doing. Is it checking an array or vector of types and saying if not null
return 0-4? And I then have those ready for my out.print?

I know it's a custom XSLT but I was missing the understanding of what
$entries or position represents. However, am very intrigued and will further
investigate the JXTemplateTransformer and other insights mentioned below.
Thank you for the leads and yes, embarrassingly, I haven't yet looked at the
forrest source for examples which will probably answer all basic questions.

I am doing 4 new production sites in forrest this September besides
www.thesummitjournal.com, and we are very excited. There are some things we
need to create to make forrest more friendly for non-extranet sites I
suspect, however there seems to be a vast functionality I have yet to grasp
and look forward to doing so!

Kind regards,
Helena




On 9/5/05 3:16 AM, "Ross Gardler" <rg...@apache.org> wrote:

> Helena Edelson wrote:
>> I mean how in *xdocs* files would you do the equivalent of @author_id or:
>> 
>> <a href="../by_author_{author_id}.html">{name}</a>
> 
> I'm still not sure what you mean, where is the {author_id} parameter
> coming from? That is, what supplies that value for this token?
> 
> Like I said earlier, there is an author element in the XDoc, can't you
> just use that with a custom transformation to give you the link you want?
> 
> If the author tag is no use to you then you need to create your own
> pipelines to do these replacements. There are a number of ways of doing
> it. Perhaps the easiest way, if you do not have detailed Cocoon
> knowledge, is to use an XSLT transformation to do the replacements. You
> need to pass the values in to the transformation and have the XSLT do
> the replacements, see my earlier reply (copied below) for a hint on how
> to do this.
> 
> You may also consider using the JXTempalteTransformer
> 
http://cocoon.apache.org/2.1/userdocs/transformers/jx-template-transformer.htm>
l
> 
> Another alternative is XSP:
> http://cocoon.apache.org/2.1/userdocs/xsp/index.html
> 
> If you more clearly define the problem we can probably give you more
> direct help, i.e. code examples.
> 
>> on the second, I mean how to write the line of code, I'm not sure what
>> the $x or @x I have to look at the number of entries of type foo and
>> only show say 4 of the total number in an xsl file. how you would write
>> the value to stop at and the ($entries.......)*] part
>> does that make any sense at all?
> 
> I'm reeally not sure I am understranding your problem. The xsl is:
> 
> <xsl:for-each select="(articles/article[@type='foo'][position() &lt; 5 ]">
> 
> If you want to pass the number of elements being processed in as a
> parameter then see my earlier response which tells you how to find
> examples in our source code.
> 
> Note, this list is not the best place to get help with XSLT. If you need
> more help with XSLT I'd recomend taking a look at the tutorials on
> http://www.zvon.org
> 
> Ross
> 
>> 
>> thx
>> Holly
>> 
>> 
>> 
>> Ross Gardler wrote:
>> 
>>> Helena Edelson wrote:
>>> 
>>>> I know how to code for forrest for this link in the xsl files:
>>>> 
>>>> <a href="../by_author_holly.html">Holly Edelson</a>
>>>> 
>>>> but how do you code for this sort of link in an xdocs/*.xml file?
>>>> can I put dynamic code there?
>>> 
>>> 
>>> In what way is it dynamic? Isn't the authors tag sufficient?
>>> 
>>> http://forrest.apache.org/dtdx/document-v20.dtdx.html#authors
>>> 
>>>> Also, how, for  src/xdocs/index.xml file can you code the xsl for it
>>>> to count the entries in the /meta-data/foo.xml, set a max integer
>>>> (value) for to generate on the xdocs/index.html page when you run
>>>> forrest to only show x number of entries for category foo if exists
>>>> and not show the rest?
>>>> 
>>>> I mean, say I have type foo and type bar in my meta-data/foo.xml
>>>> file. Say I have 10 items of type foo and 10 items of type bar, but I
>>>> only want the generated home page (html) to display 4 per type?
>>>> is it like <xsl:for-each select="articles/article[ type= foo][
>>>> *position() &lt; ($entries+1)* ]">?
>>>>               
>>>> ->this is where I don't have a clue
>>> 
>>> 
>>> Do you mean you want to know how to pass the value of $entries into
>>> the XSL?
>>> 
>>> If so take a look at our sitemaps, there are lots of examples. Search
>>> for "<map:paramter"
>>> 
>>> You could also pass it in using a configuraiton file. You can also see
>>> examples of this in our skins, search for "$config".
>>> 
>>> Ross
>>> 
>>> 
> 
>