[4suite] TextWriter bug ?

Alexandre Fayolle alf at logilab.com
Thu Sep 21 11:29:58 MDT 2000


Hello...

Sorry, more bad news :o(

Tough evening, is it not?

We are experiencing a strange behaviour of 4xslt. Attached to this mail
are an xsl transformation and a rdf file. The xsl transformation is
supposed to output some html from the rdf, it's pretty standard. 

When we process this using DomWriter (patched, with the patched
Document.py and Element.py as in my previous mail), everything goes
fine. If we use TextWriter, the crowd goes wild (and python too):

[alf at leo journal]$ python ../xslt.py freshmeat.rdf toto.xsl  > toto.html
Traceback (innermost last):
  File "../xslt.py", line 21, in ?
    test()
  File "../xslt.py", line 16, in test
    result =
processor.runNode(xml_dom,ignorePis=1)#,writer=DomWriter.DomWriter())
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 395,
in runNode
    self.applyTemplates(context, None)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 417,
in applyTemplates
    self.applyBuiltins(context, mode)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 431,
in applyBuiltins
    self.applyTemplates(context, mode)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 413,
in applyTemplates
    found = sty.applyTemplates(context, mode, self, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Stylesheet.py", line
636, in applyTemplates
    patternInfo[TEMPLATE].instantiate(context, processor, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/TemplateElement.py",
line 254, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/LiteralElement.py", line
237, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/LiteralElement.py", line
237, in instantiate
    context = child.instantiate(context, processor)[0]
  File
"/usr/lib/python1.5/site-packages/xml/xslt/ApplyTemplatesElement.py", line
173, in instantiate
    processor.applyTemplates(context, mode, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 413,
in applyTemplates
    found = sty.applyTemplates(context, mode, self, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Stylesheet.py", line
636, in applyTemplates
    patternInfo[TEMPLATE].instantiate(context, processor, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/TemplateElement.py",
line 254, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/LiteralElement.py", line
237, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/LiteralElement.py", line
237, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/LiteralElement.py", line
237, in instantiate
    context = child.instantiate(context, processor)[0]
  File
"/usr/lib/python1.5/site-packages/xml/xslt/ApplyTemplatesElement.py", line
173, in instantiate
    processor.applyTemplates(context, mode, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Processor.py", line 413,
in applyTemplates
    found = sty.applyTemplates(context, mode, self, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/Stylesheet.py", line
636, in applyTemplates
    patternInfo[TEMPLATE].instantiate(context, processor, params)
  File "/usr/lib/python1.5/site-packages/xml/xslt/TemplateElement.py",
line 252, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/ElementElement.py", line
191, in instantiate
    context = child.instantiate(context, processor)[0]
  File "/usr/lib/python1.5/site-packages/xml/xslt/AttributeElement.py",
line 193, in instantiate
    processor.writers[-1].attribute(name, value, namespace)
  File "/usr/lib/python1.5/site-packages/xml/xslt/TextWriter.py", line
192, in attribute
    self.__currElement.attrs[name] = value
AttributeError: 'None' object has no attribute 'attrs'


Well, I think I'll leave you on this one for tonight. I can't help
thinking it's a good thing that ther's an 8 hours time shift between Paris
and Boulder. Gives you time to work while we go to sleep and stop mail
bombing the list. 


-- 
Alexandre Fayolle & Nicolas Chauvat
Crazy frenchies
http://www.logilab.com - "Mais o est donc Ornicar ?" - 
LOGILAB, Paris (France).
-------------- next part --------------
<?xml version="1.0"?>

<xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
  <xsl:strip-space elements='//*'/>

  <xsl:template match='rss'>
    <html-body>
      <h1>
        <xsl:apply-templates select="channel"/>
      </h1>
    </html-body>
  </xsl:template>

  <xsl:template match='channel'>
    <h2>
      <xsl:value-of select='./title'/>
    </h2>
    <table>
      <tr>
        <td>Description:</td>
        <td>
          <xsl:value-of select='./description'/>
        </td>
      </tr>
<tr>
<td>URL:</td>
<td>
<xsl:apply-templates mode='multilink' select='link'/>
</td>
</tr>
</table>
<xsl:apply-templates select='item'/>
</xsl:template>

<xsl:template match='item'>
<h3>
<xsl:apply-templates select='title'/>
</h3>
<table>
<xsl:apply-templates mode='first' select='description'/>
<xsl:apply-templates mode='first' select='link'/>
</table>
</xsl:template>
<xsl:template match='title'>
<xsl:value-of select='.'/>
</xsl:template>

<xsl:template match='link'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='.'/>
</xsl:attribute>
<xsl:value-of select='.'/>
</xsl:element>
</xsl:template>

<xsl:template mode='multi' match='*'>
<xsl:value-of select='.'/>
</xsl:template>

<xsl:template mode='first' match='description'>
<tr>
<td>
Description:
</td>
<td>
<xsl:apply-templates mode='multi'
select='../description'/>
</td>
</tr>
</xsl:template>
<xsl:template mode='multilink' match='*'>
<xsl:element name='a'>
<xsl:attribute name='href'>
<xsl:value-of select='.'/>
</xsl:attribute>
<xsl:value-of select='.'/>
</xsl:element>
</xsl:template>

<xsl:template mode='first' match='link'>
<tr>
<td>
More detail at:
</td>
<td>
<xsl:apply-templates mode='multilink' select='../link'/>
</td>
</tr>
</xsl:template>

</xsl:transform>

-------------- next part --------------
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">

<channel>
<title>freshmeat.net</title>
<link>http://freshmeat.net</link>
<description>the one-stop-shop for all your Linux software needs</description>
<language>en-us</language>

<item>
<title>Alzabo 0.06a</title>
<link>http://freshmeat.net/news/2000/07/19/964065475.html</link>
<description>Perl data modelling tool and RDBMS-OO mapper.</description>
</item>

<item>
<title>HLmaps 0.90</title>
<link>http://freshmeat.net/news/2000/07/19/964065450.html</link>
<description>A Perl/CGI script for Half-Life servers to present a list of loaded maps</description>
</item>

<textinput>
<title>quick finder</title>
<description>Use the text input below to search the freshmeat application database</description>
<name>query</name>
<link>http://core.freshmeat.net/search.php3</link>
</textinput>
</channel>
</rss>



More information about the 4suite mailing list