You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alessio Sangalli <al...@manoweb.com> on 2002/11/11 19:21:45 UTC

link rel=

Hi I've a little problem because I want to automatically generate the 
"link" header (if you use Mozilla, it's very useful, if you want to show 
it: menu -> view - show-hide - site navigation toolbar - show [as needed]).

Here is an example:

<link rel="home" type="text/html" title="How to build an IR receiver" 
href="."/>
<link rel="prev" type="text/html" title="Circuit" href="circuit.html"/>
<link rel="next" type="text/html" title="Diode and Resistor" 
href="02.html"/>
<link rel="last" type="text/html" title="Links" href="links.html"/>

I wrote an howto about building a serial IR receiver 
(http://www.manoweb.com/alesan/lirc); there are few pages describing the 
process:
index.shtm
tools.html
parts.html
circuit.html
01.html
02.html
03.html
04.html
05.html
links.html

The above html code sample is from 01.html: "home" links to index.shtm, 
"prev" to circuit.html, "next" to 02.html, "last" to links.html.

Until now I wrote my html by hand but I wanted to automate it with 
Cocoon. It's quite finished (simple xml files trasformed with xsl in 
html (pdf)) but now I need to generate automatically those links in the 
header.

How can I implement it? Perhaps on the sitemap a parameter to the xsl 
transformer wich tells the actual file name; the xsl-t should then check 
it against an xml file where I wrote the exact order of the pages, and 
write the link headers accordingly.

What do you think?
Thank you
as





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Joerg Heinicke <jo...@gmx.de>.
Really strange, but this is definitely a Mozilla problem. I use Mozilla 
1.1 and have no problems. Maybe you should post a bug at 
http://bugzilla.mozilla.org.

Joerg

Alessio Sangalli wrote:
> 
> Joerg Heinicke wrote:
> 
>> Hmm, what exactly do you mean? You request an XML page, but you don't
>> see anything? Mozilla has no built-in stylesheet by default like IE. But
>> you can see the source of the document (Ctrl + u).
> 
> 
> no, I mean when I reply an email like yours, containing a piece of xml 
> code. All your message is quoted, but the lines with code are blank.
> 
> bye
> as


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Alessio Sangalli <al...@manoweb.com>.
Joerg Heinicke wrote:

> Hmm, what exactly do you mean? You request an XML page, but you don't
> see anything? Mozilla has no built-in stylesheet by default like IE. But
> you can see the source of the document (Ctrl + u).

no, I mean when I reply an email like yours, containing a piece of xml 
code. All your message is quoted, but the lines with code are blank.

bye
as





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Joerg Heinicke <jo...@gmx.de>.
> I use Mozilla 1.2b. When I quote xml code it doesn't appear. Is this a 
> know bug?

Hmm, what exactly do you mean? You request an XML page, but you don't 
see anything? Mozilla has no built-in stylesheet by default like IE. But 
you can see the source of the document (Ctrl + u).

Joerg


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Alessio Sangalli <al...@manoweb.com>.
Joerg Heinicke wrote:

> that's ok ;-) It was more a general statement than a need for the numbers.

:) ok I wanted to be precise!

>
> >  >  Maybe it's an alternative to aggregate the XML source
> >  > with the navigation XML.
> >
> > I don't understand this, could you explain?
>
>
> example of sitemap aggregation:

I use Mozilla 1.2b. When I quote xml code it doesn't appear. Is this a 
know bug?

Back to aggragation: I see I can use it like a 'multiple generator' now 
I should read the docs/references. There is not so much difference than 
a Xinclude I think, and I'm going to (hopefully) use Cocoon by command 
line to generate static html, pdf, so performance isn't a key feature.

Many thanks, this discussion clarified my ideas!


bye
as




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Alessio,

Alessio Sangalli wrote:
> 
> Joerg Heinicke wrote:
> 
>> Exactly the way I would do it. But beware: XSLTs are chached with their
>> parameters. So it's interesting to know, how many pages you have or how
>> big the XSLTs are.
> 
> $ ls *.xml | wc -l
>      12
> (to be honest two xml pages are only tests)
> 
> $ wc -ml html.xsl
>      86    2055 html.xsl
> $ grep -c "<xsl:template" html.xsl
> 13
> 
> the xsl file is rather small, 86 linees 2055 characters for 13 templates.

that's ok ;-) It was more a general statement than a need for the numbers.

>  >  Maybe it's an alternative to aggregate the XML source
>  > with the navigation XML.
> 
> I don't understand this, could you explain?

example of sitemap aggregation:

<map:match pattern="test">
   <map:aggregate element="page">
     <map:part src="navigation.xml"/>
     <map:part src="page-description.xml"/>
   </map:aggregate>
   <map:transform src="xml2html.xsl"/>
   <map:serialize type="html"/>
</map:match>

 > Jeremy Quinn wrote:
 >>
 >> what I do to deal with this kind of thing is to have a menu.xml
 >> structure, that is imported into all my pages via CInclude, then xslt
 >
 > mh, I've never understood the difference between Xinclude and
 > Cinclude...

CInclude was an earlier implementation. Later the standard conform 
XInclude was implemented and the CInclude refactored. Now they have in 
general the same functionality AFAIK and somebody wanted to bring them 
to the same code and functionality (so that only the namespaces are 
different and both are usable and do the same).

Regards,

Joerg


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Alessio Sangalli <al...@manoweb.com>.

Joerg Heinicke wrote:

> Exactly the way I would do it. But beware: XSLTs are chached with their
> parameters. So it's interesting to know, how many pages you have or how
> big the XSLTs are.


$ ls *.xml | wc -l
      12
(to be honest two xml pages are only tests)

$ wc -ml html.xsl
      86    2055 html.xsl
$ grep -c "<xsl:template" html.xsl
13

the xsl file is rather small, 86 linees 2055 characters for 13 templates.

 >  Maybe it's an alternative to aggregate the XML source
 > with the navigation XML.

I don't understand this, could you explain?


bye
as




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Joerg Heinicke <jo...@gmx.de>.
Alessio Sangalli wrote:
> Hi I've a little problem because I want to automatically generate the 
> "link" header (if you use Mozilla, it's very useful, if you want to show 
> it: menu -> view - show-hide - site navigation toolbar - show [as needed]).

<!-- example snipped -->

> How can I implement it? Perhaps on the sitemap a parameter to the xsl 
> transformer wich tells the actual file name; the xsl-t should then check 
> it against an xml file where I wrote the exact order of the pages, and 
> write the link headers accordingly.
> 
> What do you think?
> Thank you
> as

Exactly the way I would do it. But beware: XSLTs are chached with their 
parameters. So it's interesting to know, how many pages you have or how 
big the XSLTs are. Maybe it's an alternative to aggregate the XML source 
with the navigation XML.

Regards,

Joerg


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Alessio Sangalli <al...@manoweb.com>.
Jeremy Quinn wrote:

yours code is quite different than mine because I use a different 
approach: this is the xml data I Xinclude in all files:

<structure>
  <chapter><title>Index</title><href>index.html</href></chapter>
  <chapter><title>Tools</title><href>tools.html</href></chapter>
  <chapter><title>Parts</title><href>parts.html</href></chapter>
  <chapter><title>Circuit</title><href>circuit.html</href></chapter>
  <chapter><title>01</title><href>01.html</href></chapter>
  <chapter><title>02</title><href>02.html</href></chapter>
  <chapter><title>03</title><href>03.html</href></chapter>
  <chapter><title>04</title><href>04.html</href></chapter>
  <chapter><title>05</title><href>05.html</href></chapter>
  <chapter><title>Links</title><href>links.html</href></chapter>
</structure>

and this is the xsl code wich generates the link rel things:

<!-- if this page is not the first, we write link rel=first and link 
rel=prev -->
<xsl:if test="not(//structure/chapter[1]/href=$myself)">
<link rel="first" href="{//structure/chapter[1]/href}" 
title="{//structure/chapter[1]/title}"/>
<link rel="prev" 
href="{//structure/chapter[href=$myself]/preceding-sibling::chapter[1]/href}" 
title="{//structure/chapter[href=$myself]/preceding-sibling::chapter[1]/title}"/>
</xsl:if>
<!-- if this page is not the last, we write link rel=last and link 
rel=next -->
<xsl:if test="not(//structure/chapter[last()]/href=$myself)">
<link rel="last" href="{//structure/chapter[last()]/href}" 
title="{//structure/chapter[last()]/title}"/>
<link rel="next" 
href="{//structure/chapter[href=$myself]/following-sibling::chapter[1]/href}" 
title="{//structure/chapter[href=$myself]/following-sibling::chapter[1]/title}"/>
</xsl:if>



bye! and thank you you example gave me inspiration (is it the correct 
english word? boh)

bye
as





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Tuesday, Nov 12, 2002, at 13:55 Europe/London, Alessio Sangalli 
wrote:

>
> Jeremy Quinn wrote:
>
>> what I do to deal with this kind of thing is to have a menu.xml
>> structure, that is imported into all my pages via CInclude, then xslt
>
> mh, I've never understood the difference between Xinclude and 
> Cinclude...
>

Unfortunately (in 2.1) there are three (?) versions, 
CachingCIncludeTransformer, CIncludeTransformer and 
XIncludeTransformer. They all basically do the same job, but have 
different options.

The XInclude on uses the W3c XInclude standard tags and includes the 
XPointer syntax, the CInclude 'family' use Cocoon-specific tags.

>> (having been provided with the 'id' of the page via the sitemap) makes
>> two structures from the menu.xml, 1) my html navigation 2) the meta
>> links you mention.
>
> yes, cool; I would like to prepare accurate documentation about the 
> way my website was built. This could also be a useful how-to for 
> cocoon newbies. If you want to contribute, I'd accept some pieces of 
> code from your xsl-transformations...!

Well that is tricky, mine works with my data, I cannot guarantee this 
even works as it stands ........ my data is more complex than this, I 
hope the xslt below works properly with the simplified case, it is not 
tested!

My menus look something like this:

<menu>
	<meta>
		<title>A Menu</title>
		<desc>this is a sample</desc>
	</meta>
	<title>Home Page</title>
	<href>index</href>
	<item>
		<title>Page One</title>
		<href>one/index</href>
	</item>
	<item>
		<title>Page Two</title>
		<href>two/index</href>
		<item>
			<title>Page Two/One</title>
			<href>two/one</href>
		</item>
		<item>
			<title>Page Two/Two</title>
			<href>two/two</href>
		</item>
	</item>
	etc ......
</menu>

This is my xslt for making <link/>s (in it's present design, it works 
on the <menu/> being the only content). This does not deal with the 
internal links within documents.

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

	<xsl:param name="res"/> <!-- 'res' param in the form "two/index" -->

	<xsl:variable name="me" select="//*[href = $res]"/>
	<xsl:variable name="mum" select="$me/parent::*"/>
	<xsl:variable name="psibs" select="$me/preceding-sibling::item"/>
	<xsl:variable name="fsibs" select="$me/following-sibling::item"/>
	<xsl:variable name="kids" select="$me/item"/>

	<xsl:template match="menu">
		<xsl:for-each select="$mum">
			<link href="{href}" title="{title}" rel="Up"/>
		</xsl:for-each>
		<xsl:for-each select="$psibs[1]">
			<link href="{href}" title="{title}" rel="First"/>
		</xsl:for-each>
		<xsl:for-each select="$psibs[last()]">
			<link href="{href}" title="{title}" rel="Prev"/>
		</xsl:for-each>
		<xsl:for-each select="$fsibs[1]">
			<link href="{href}" title="{title}" rel="Next"/>
		</xsl:for-each>
		<xsl:for-each select="$fsibs[last()]">
			<link href="{href}" title="{title}" rel="Last"/>
		</xsl:for-each>
		<xsl:for-each select="$psibs">
			<link href="{href}" title="{title}" rel="Section"/>
		</xsl:for-each>
		<xsl:for-each select="$me[1]">
			<link href="{href}" title="{title}" rel="Section"/>
		</xsl:for-each>
		<xsl:for-each select="$fsibs">
			<link href="{href}" title="{title}" rel="Section"/>
		</xsl:for-each>
		<xsl:for-each select="$kids">
			<link href="{href}" title="{title}" rel="SubSection"/>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>


Hope this helps

regards Jeremy


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Diana Shannon <sh...@apache.org>.
On Tuesday, November 12, 2002, at 08:55  AM, Alessio Sangalli wrote:

> mh, I've never understood the difference between Xinclude and 
> Cinclude...

Have you checked:
   http://xml.apache.org/cocoon/faq/faq-transformers.html#faq-2


Diana


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Alessio Sangalli <al...@manoweb.com>.
Jeremy Quinn wrote:

> what I do to deal with this kind of thing is to have a menu.xml
> structure, that is imported into all my pages via CInclude, then xslt

mh, I've never understood the difference between Xinclude and Cinclude...

> (having been provided with the 'id' of the page via the sitemap) makes
> two structures from the menu.xml, 1) my html navigation 2) the meta
> links you mention.

yes, cool; I would like to prepare accurate documentation about the way 
my website was built. This could also be a useful how-to for cocoon 
newbies. If you want to contribute, I'd accept some pieces of code from 
your xsl-transformations...!


>  I also output rel="Chapter" (of sub-pages) links so
> all nav can be done from the site nav toolbar. Mozilla also handles
> rel="Section" and rel="SubSection".


my data is rather simple so I don't need chapters and subchapters. Maybe 
I will use those features in the future, thank you!

bye
as





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: link rel=

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Monday, Nov 11, 2002, at 18:21 Europe/London, Alessio Sangalli wrote:

> Hi I've a little problem because I want to automatically generate the 
> "link" header (if you use Mozilla, it's very useful, if you want to 
> show it: menu -> view - show-hide - site navigation toolbar - show [as 
> needed]).
>
> Here is an example:
>
> <link rel="home" type="text/html" title="How to build an IR receiver" 
> href="."/>
> <link rel="prev" type="text/html" title="Circuit" href="circuit.html"/>
> <link rel="next" type="text/html" title="Diode and Resistor" 
> href="02.html"/>
> <link rel="last" type="text/html" title="Links" href="links.html"/>
>


what I do to deal with this kind of thing is to have a menu.xml 
structure, that is imported into all my pages via CInclude, then xslt 
(having been provided with the 'id' of the page via the sitemap) makes 
two structures from the menu.xml, 1) my html navigation 2) the meta 
links you mention. I also output rel="Chapter" (of sub-pages) links so 
all nav can be done from the site nav toolbar. Mozilla also handles 
rel="Section" and rel="SubSection".


Hope this helps

regards Jeremy


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>