[4suite] [Amara] Error in xml_xslt
Uche Ogbuji
uche at ogbuji.net
Sat Dec 9 19:25:18 MST 2006
Luis Miguel Morillas wrote:
> I was testing a Chimezie's bookmark:
> http://www.xml.com/pub/a/2006/11/29/xslt-xml-pretty-printer.html
>
> My program with amara was very single:
>
> {{{
> import amara
> FILE = 'indent.xsl'
>
> doc = amara.parse(FILE)
>
> print doc.xml_xslt(doc.xml())
> }}}
>
> indent.xsl is the complete stylesheet at the end of the article.
>
> This is the error I get:
>
> Traceback (most recent call last):
> File "/home/lm/pythons/pretty_print.py", line 6, in <module>
> print doc.xml_xslt(doc.xml())
> File "build/bdist.linux-i686/egg/amara/bindery.py", line 833, in xml_xslt
> outputStream=output)
> File
> "/usr/lib/python2.5/site-packages/4Suite_XML-1.0-py2.5-linux-i686.egg/Ft/Xml/Xslt/Processor.py",
>
> line 467, in runNode
> self._stripElements(node)
> File
> "/usr/lib/python2.5/site-packages/4Suite_XML-1.0-py2.5-linux-i686.egg/Ft/Xml/Xslt/Processor.py",
>
> line 922, in _stripElements
> StripElements.StripElements(node, stripElements)
> File
> "/usr/lib/python2.5/site-packages/4Suite_XML-1.0-py2.5-linux-i686.egg/Ft/Xml/Lib/StripElements.py",
>
> line 8, in StripElements
> StripElements(c,stripElements,stripState)
> File
> "/usr/lib/python2.5/site-packages/4Suite_XML-1.0-py2.5-linux-i686.egg/Ft/Xml/Lib/StripElements.py",
>
> line 30, in StripElements
> StripElements(c,stripElements,stripState)
> File
> "/usr/lib/python2.5/site-packages/4Suite_XML-1.0-py2.5-linux-i686.egg/Ft/Xml/Lib/StripElements.py",
>
> line 34, in StripElements
> node.parentNode.removeChild(node)
> AttributeError: 'stylesheet' object has no attribute 'removeChild'
>
>
> I had no problem with Xslt.Processor:
>
> {{{
> from Ft.Xml.Xslt import Processor
> from Ft.Xml import InputSource
> from Ft.Lib.Uri import OsPathToUri
>
> FILE = 'indent.xsl'
>
> processor = Processor.Processor()
>
> src_uri = OsPathToUri(FILE)
> src = InputSource.DefaultFactory.fromUri(src_uri)
> # IMPORTANT: Two src needed.
> src2 = InputSource.DefaultFactory.fromUri(src_uri)
> processor.appendStylesheet(src)
>
> result = processor.run(src2)
>
> print result
> }}}
Yes, this is what I expect. As I've said before, xml_xslt is quite
limited. If you find your transform does not work with it, then use the
full Ft.Xml.Xslt.transform.
I don't plan to address these limitations before Amara 2.0.
--
Uche Ogbuji Work: The Kadomo Group, Inc.
http://uche.ogbuji.net http://kadomo.com
http://copia.ogbuji.net Lead dev at http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/
More information about the 4suite
mailing list