forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferdinand Soethe <>
Subject Re: Error transforming Table IDs
Date Fri, 29 Jul 2005 14:51:46 GMT
OK, I think I found the culprit for the strange behavior with

The Problem:

After fixing the problem of id-attributes not being passed
through to the final HTML I notices a strange behaviour with

- If an IMG-element had no id-attribute everything worked fine. IMG
  was processed as expected.
- If it had an id-attribute however strange things happended, the
  IMG-element was renderered like this

  <img alt="Icon"><a name="icon"></a> which obviously made it pretty


Going down the pipeline I found the culprit in pelts document2html
where img is processed as part of this default template:

1  <xsl:template match="node()|@*" priority="-1">
2    <xsl:copy>
3      <xsl:apply-templates select="@*"/>
4      <xsl:apply-templates/>
5    </xsl:copy>
6  </xsl:template>

Debugging this I found line 3 starting to copy the IMG-element then
trying to execute the following template

 <!-- Generate a <a name="..."> tag for an @id -->
  <xsl:template match="@id">
    <xsl:if test="normalize-space(.)!=''">
      <a name="{.}"/>

which tries to insert a a-element right into our open img-element,
triggering an error and aborting the processing (which explains the
strange result).

Attempted Solution:

1  <xsl:template match="node()|@*" priority="-1">
     <!-- id processing will create its own a-element so processing has to
          happen outside the copied element
2   <xsl:apply-templates select="@id"/>
3    <xsl:copy>
4      <xsl:apply-templates select="@* and ???"/>
5       <xsl:attribute name="id">{id}</xsl:attribute>

Line 2 will only process ids and insert the a-element before the
       img-tag as usual (question: does it make sense to have this
       id-processing here AND in several templates that I saw in
       common? That seems to invite redundant processing?)

Line 4 should now exclude @id but I'm not sure how to express that in
       X-Path if I want to process all attributes but id? Can someone
       pls help?

Line 5 inserts the unprocessed id-attribute for use in css-styling.

So wdyt?

Ferdinand Soethe

View raw message