You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2002/11/06 14:34:33 UTC

suggestion for dtd

i would like to suggest that the 'title' element allow an 'anchor'
within it, and/or that 'section' allow 'anchor' before 'title'.

otherwise, the archor ends up being *after* the section title, and
someone following a link to it will arrive at a screen view whose
title is just off the top of the screen.

RE: suggestion for dtd

Posted by Robert Koberg <ro...@koberg.com>.
Hi again,

I gues I have already done something like this (in the
WEB-INF/styling/util/path_builders.xsl)

You call it like this:

<xsl:call-template name="remove_quotes">
  <xsl:with-param name="string" select="translate(@label, ' ', '_')"/>
</xsl:call-template>

best,
-Rob

> -----Original Message-----
> From: Robert Koberg [mailto:rob@koberg.com]
> Sent: Wednesday, November 06, 2002 7:52 AM
> To: forrest-dev@xml.apache.org
> Subject: RE: suggestion for dtd
>
>
> Here is one I use to 'fix quotes' - I will get to this soon (today?)
> if you want
> to wait.  Otherwise check this out and it should give you some ideas:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template name="fix_quotes">
>    <xsl:param name="string"/>
>
>    <xsl:choose>
>      <xsl:when test="contains($string, &quot;'&quot;)">
>        <xsl:value-of
>          select="substring-before($string, &quot;'&quot;)"/>
>        <xsl:text>\'</xsl:text>
>        <xsl:call-template name="fix_quotes">
>          <xsl:with-param name="string"
>            select="substring-after($string, &quot;'&quot;)"/>
>        </xsl:call-template>
>      </xsl:when>
>      <xsl:otherwise>
>        <xsl:value-of select="$string"/>
>      </xsl:otherwise>
>    </xsl:choose>
>
> </xsl:template>
>
> <xsl:template name="remove_quotes">
>    <xsl:param name="string"/>
>
>    <xsl:choose>
>      <xsl:when test="contains($string, &quot;'&quot;)">
>        <xsl:value-of
>          select="substring-before($string, &quot;'&quot;)"/>
>        <xsl:call-template name="remove_quotes">
>          <xsl:with-param name="string"
>            select="substring-after($string, &quot;'&quot;)"/>
>        </xsl:call-template>
>      </xsl:when>
>      <xsl:otherwise>
>        <xsl:value-of select="$string"/>
>      </xsl:otherwise>
>    </xsl:choose>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
> > -----Original Message-----
> > From: Jeff Turner [mailto:jefft@apache.org]
> > Sent: Wednesday, November 06, 2002 7:56 AM
> > To: forrest-dev@xml.apache.org
> > Subject: Re: suggestion for dtd
> >
> >
> > On Wed, Nov 06, 2002 at 07:19:42AM -0800, Robert Koberg wrote:
> > ...> > http://xml.apache.org/forrest/your-project.html#N1014A
> > > >
> > > > as soon as someone regenerates the site, that URL is liable to break.
> > >
> > > Well, I did say for links on the same page. If so, then this
> > problem would not
> > > occur.
> >
> > 'cept people tend to cut-and-paste whatever's in the browser location
> > bar.
> >
> > > > So it might be best to abandon generate-id() altogether, and
> > > > auto-generate an @id from the section title.  An anchor like
> > > > #advanced_customizations is also more descriptive than #N1014A
> > >
> > > I like this more and am going to change the way I do TOCs to this. I like
> > > descriptive URLs :). You can still use my template example and
> > substitute some
> > > xsl (a named template) that replaces spaces with underscores and
> > removes things
> > > that ID does not like (like a dot/period - or is this business logic :)
> >
> > I tried it with translate(title, '!@#$%...', '_____') once.. Saxon kept
> > complaining and I kept adding chars..  Saxon won in the end :)  Guess
> > I'll have to read the RFC to do it properly.
> >
> >
> > --Jeff
> >
> >
> > > thanks,
> > > -Rob
> > >
> > > >
> > > >
> > > > --Jeff
> > > >
> > >
> > >
> >
>
>



RE: suggestion for dtd

Posted by Robert Koberg <ro...@koberg.com>.
Here is one I use to 'fix quotes' - I will get to this soon (today?) if you want
to wait.  Otherwise check this out and it should give you some ideas:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="fix_quotes">
   <xsl:param name="string"/>

   <xsl:choose>
     <xsl:when test="contains($string, &quot;'&quot;)">
       <xsl:value-of
         select="substring-before($string, &quot;'&quot;)"/>
       <xsl:text>\'</xsl:text>
       <xsl:call-template name="fix_quotes">
         <xsl:with-param name="string"
           select="substring-after($string, &quot;'&quot;)"/>
       </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="$string"/>
     </xsl:otherwise>
   </xsl:choose>

</xsl:template>

<xsl:template name="remove_quotes">
   <xsl:param name="string"/>

   <xsl:choose>
     <xsl:when test="contains($string, &quot;'&quot;)">
       <xsl:value-of
         select="substring-before($string, &quot;'&quot;)"/>
       <xsl:call-template name="remove_quotes">
         <xsl:with-param name="string"
           select="substring-after($string, &quot;'&quot;)"/>
       </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="$string"/>
     </xsl:otherwise>
   </xsl:choose>

</xsl:template>

</xsl:stylesheet>

> -----Original Message-----
> From: Jeff Turner [mailto:jefft@apache.org]
> Sent: Wednesday, November 06, 2002 7:56 AM
> To: forrest-dev@xml.apache.org
> Subject: Re: suggestion for dtd
>
>
> On Wed, Nov 06, 2002 at 07:19:42AM -0800, Robert Koberg wrote:
> ...> > http://xml.apache.org/forrest/your-project.html#N1014A
> > >
> > > as soon as someone regenerates the site, that URL is liable to break.
> >
> > Well, I did say for links on the same page. If so, then this
> problem would not
> > occur.
>
> 'cept people tend to cut-and-paste whatever's in the browser location
> bar.
>
> > > So it might be best to abandon generate-id() altogether, and
> > > auto-generate an @id from the section title.  An anchor like
> > > #advanced_customizations is also more descriptive than #N1014A
> >
> > I like this more and am going to change the way I do TOCs to this. I like
> > descriptive URLs :). You can still use my template example and
> substitute some
> > xsl (a named template) that replaces spaces with underscores and
> removes things
> > that ID does not like (like a dot/period - or is this business logic :)
>
> I tried it with translate(title, '!@#$%...', '_____') once.. Saxon kept
> complaining and I kept adding chars..  Saxon won in the end :)  Guess
> I'll have to read the RFC to do it properly.
>
>
> --Jeff
>
>
> > thanks,
> > -Rob
> >
> > >
> > >
> > > --Jeff
> > >
> >
> >
>



Re: suggestion for dtd

Posted by Jeff Turner <je...@apache.org>.
On Wed, Nov 06, 2002 at 07:19:42AM -0800, Robert Koberg wrote:
...> > http://xml.apache.org/forrest/your-project.html#N1014A
> >
> > as soon as someone regenerates the site, that URL is liable to break.
> 
> Well, I did say for links on the same page. If so, then this problem would not
> occur.

'cept people tend to cut-and-paste whatever's in the browser location
bar.

> > So it might be best to abandon generate-id() altogether, and
> > auto-generate an @id from the section title.  An anchor like
> > #advanced_customizations is also more descriptive than #N1014A
> 
> I like this more and am going to change the way I do TOCs to this. I like
> descriptive URLs :). You can still use my template example and substitute some
> xsl (a named template) that replaces spaces with underscores and removes things
> that ID does not like (like a dot/period - or is this business logic :)

I tried it with translate(title, '!@#$%...', '_____') once.. Saxon kept
complaining and I kept adding chars..  Saxon won in the end :)  Guess
I'll have to read the RFC to do it properly.


--Jeff


> thanks,
> -Rob
> 
> >
> >
> > --Jeff
> >
> 
> 

RE: suggestion for dtd

Posted by Robert Koberg <ro...@koberg.com>.
Howdy,

> -----Original Message-----
> From: Jeff Turner [mailto:jefft@apache.org]
> Sent: Wednesday, November 06, 2002 7:15 AM
> To: forrest-dev@xml.apache.org
> Subject: Re: suggestion for dtd
>
>
> On Wed, Nov 06, 2002 at 06:51:09AM -0800, Robert Koberg wrote:
> > Hi guys,
> >
> > If the anchor is on the same page (for something like a table of
> contents) you
> > don't need to put IDs in your elements. You could use the xsl function
> > generate-id(). This function is guaranteed to return the same value
> for a node
> > whenever it is called in the XSL transformation.
>
> Each section already has a generated id, which is linked to by the
> in-page TOC.
>
> The problem is that generate-id() is not guaranteed to return the same
> value in different XSLT processors, or even in different invocations of
> the same processor.  If I point you to:
>
> http://xml.apache.org/forrest/your-project.html#N1014A
>
> as soon as someone regenerates the site, that URL is liable to break.

Well, I did say for links on the same page. If so, then this problem would not
occur.

>
> So it might be best to abandon generate-id() altogether, and
> auto-generate an @id from the section title.  An anchor like
> #advanced_customizations is also more descriptive than #N1014A

I like this more and am going to change the way I do TOCs to this. I like
descriptive URLs :). You can still use my template example and substitute some
xsl (a named template) that replaces spaces with underscores and removes things
that ID does not like (like a dot/period - or is this business logic :)

thanks,
-Rob

>
>
> --Jeff
>



Re: suggestion for dtd

Posted by Jeff Turner <je...@apache.org>.
On Wed, Nov 06, 2002 at 06:51:09AM -0800, Robert Koberg wrote:
> Hi guys,
> 
> If the anchor is on the same page (for something like a table of contents) you
> don't need to put IDs in your elements. You could use the xsl function
> generate-id(). This function is guaranteed to return the same value for a node
> whenever it is called in the XSL transformation.

Each section already has a generated id, which is linked to by the
in-page TOC.

The problem is that generate-id() is not guaranteed to return the same
value in different XSLT processors, or even in different invocations of
the same processor.  If I point you to:

http://xml.apache.org/forrest/your-project.html#N1014A

as soon as someone regenerates the site, that URL is liable to break.

So it might be best to abandon generate-id() altogether, and
auto-generate an @id from the section title.  An anchor like
#advanced_customizations is also more descriptive than #N1014A


--Jeff


Re: suggestion for dtd

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
* On 2002-11-06 at 09:39,
  Jeff Turner <je...@apache.org> excited the electrons to say:
> 
> Try using the 'id' attribute on the section:

d'oh!

RE: suggestion for dtd

Posted by Robert Koberg <ro...@koberg.com>.
Hi guys,

If the anchor is on the same page (for something like a table of contents) you
don't need to put IDs in your elements. You could use the xsl function
generate-id(). This function is guaranteed to return the same value for a node
whenever it is called in the XSL transformation. Using this technique you do not
have to worry about maintaining the ID's. For example you have some templates
that create a TOC:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="toc">
  <div class="toctitle">
    Page Table of Contents:
  </div>
  <div class="toc">
    <xsl:apply-templates select="$page_nodeset/col[@type='wide_center']"
mode="start_toc"/>
  </div>
</xsl:template>

<xsl:template match="article" mode="toc">
  <xsl:apply-templates select="h | h1 | h2 | h3 | h4 | h5 | section"
mode="toc"/>
</xsl:template>

<xsl:template match="section" mode="toc">
  <div class="tocsection">
    <xsl:apply-templates select="h | h1 | h2 | h3 | h4 | h5 | section"
mode="toc"/>
   </div>
</xsl:template>

<xsl:template match="h | h1 | h2 | h3 | h4 | h5" mode="toc">
  <div class="tocitem">
    <a href="#{generate-id()}">
      <xsl:value-of select="."/>
    </a>
    <xsl:apply-templates select="h | h1 | h2 | h3 | h4 | h5 | section"
mode="toc"/>
  </div>
</xsl:template>
</xsl:stylesheet>

Then in some template that styles the content you would have:

<xsl:template match="h | h1 | h2 | h3 | h4 | h5">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:attribute name="id">
      <xsl:value-of select="generate-id()"/>
    </xsl:attribute>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

best,
-Rob


> -----Original Message-----
> From: Jeff Turner [mailto:jefft@apache.org]
> Sent: Wednesday, November 06, 2002 6:39 AM
> To: forrest-dev@xml.apache.org
> Subject: Re: suggestion for dtd
>
>
> On Wed, Nov 06, 2002 at 08:34:33AM -0500, Rodent of Unusual Size wrote:
> > i would like to suggest that the 'title' element allow an 'anchor'
> > within it, and/or that 'section' allow 'anchor' before 'title'.
>
> Try using the 'id' attribute on the section:
>
> <section id="doing_stuff">
>   <title>Doing Stuff</title>
>   ...
>
>
> <p>.. in the <link href="#doing_stuff">Doing Stuff</link> section.
>
> --Jeff
>
> > otherwise, the archor ends up being *after* the section title, and
> > someone following a link to it will arrive at a screen view whose
> > title is just off the top of the screen.
>



Re: suggestion for dtd

Posted by Jeff Turner <je...@apache.org>.
On Wed, Nov 06, 2002 at 08:34:33AM -0500, Rodent of Unusual Size wrote:
> i would like to suggest that the 'title' element allow an 'anchor'
> within it, and/or that 'section' allow 'anchor' before 'title'.

Try using the 'id' attribute on the section:

<section id="doing_stuff">
  <title>Doing Stuff</title>
  ...


<p>.. in the <link href="#doing_stuff">Doing Stuff</link> section.

--Jeff

> otherwise, the archor ends up being *after* the section title, and
> someone following a link to it will arrive at a screen view whose
> title is just off the top of the screen.