[xslt] overwriting attributes



Hi,

i found something weired in xsltproc/libxslt. I searched the bug 
archive but didnt found anything.

I produced an html file from an xml file and it shows up with two 
attributes of the same name in one element, which is an error, right? 
 
here is what i do: after parsing the sourcetree into chunks i want to 
add some default attributes to my html tags. So before writing to 
file i call an template with mode html.defaults.

I found a workaround for me with many choose statements but thats not 
very nice.

here comes a part of the xsl code...

<xsl:template name="write.chunk">
  <xsl:param name="filename" select="''"/>
  <xsl:param name="method" select="'html'"/>
  <xsl:param name="encoding" select="'ISO-8859-1'"/>
  <xsl:param name="content" select="''"/>

  <saxon:output href="{$filename}"
    method="{$method}"   encoding="{$encoding}"
    indent="{$indent}" xmlns:exslt="http://exslt.org/common";>
    <xsl:apply-templates mode="html.defaults"  
     select="exslt:node-set($content)"/>
  </saxon:output>
</xsl:template>

<!-- == doesnt work with xsltproc ====== -->
<!-- default templates for copying the rest -->
<!-- in html.defaults are left out to keep the example short -->

<xsl:template match="table" mode="html.defaults">
  <xsl:copy use-attribute-sets="table.defaults">
    <xsl:for-each select="@*">
      <xsl:copy/>
    </xsl:for-each>
    <xsl:apply-templates mode="html.defaults"/>
  </xsl:copy>
</xsl:template>


normally the second attribute should owerwrite the first. At least 
Michael Kay say so in XSLT Programmers Reference and for me it seems 
to be convinient.

regards,
janning


xsltproc -V
Using libxml 20419, libxslt 10015 and libexslt 706
xsltproc was compiled against libxml 20419, libxslt 10015 and 
libexslt 706
libxslt 10015 was compiled against libxml 20419
libexslt 706 was compiled against libxml 20419

-- 
Planwerk 6 /websolutions
Herzogstraße 86
40215 Düsseldorf

fon 0211-6015919
fax 0211-6015917
http://www.planwerk6.de



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]