Hi all, i'm a bit confused with the behavior of the XMLDocument product. I have a very simple XML Document : test <?xml version="1.0"?> <doc> <p> bla bla ...</p> <p> bla bla ...</p> </doc> I've got also a DTML method view_test : <dtml-var standard_html_header> <h2><dtml-var title_or_id> <dtml-var document_title></h2> <dtml-with "test[0]"> <dtml-in "getChildNodes()"> <p><dtml-var absolute_url></p> </dtml-in> </dtml-with> <dtml-var standard_html_footer> I launch the view method and i expect to have 2 URLs, i've got 5 with 3 non-existent nodes ... I use the last version of XMLDocument. -- Serge Stinckwich -< ) Debian GNU/Linux 2.2 (frozen) CNRS UPRESA 6072>GREYC>I3>SMILE /~\ http://debian.org/ Université de Caen>IUT de Caen>Campus 3>Dept Info (/ | http://zope.org/ http://www.iutc3.unicaen.fr/~stincs _|_/ http://zschool.org/
[as a side note, there's a zope-xml@egroups.com list that's about Zope and XML..it may be easier to direct your questions on XMLDocument there] Serge Stinckwich wrote:
i'm a bit confused with the behavior of the XMLDocument product. [snip code]
I launch the view method and i expect to have 2 URLs, i've got 5 with 3 non-existent nodes ...
What is going on is that your display method picks up text nodes as well; they don't contain much text beyond whitespace, but there's there between the element nodes. You can do something like this to skip them: <dtml-in "getChildNodes()"> <dtml-if "getNodeName() != '#text'"> <p><dtml-var absolute_url></p> </dtml-if> </dtml-in> A more advanced option is to use my XMLWidgets product, to be found here: http://www.zope.org/Members/faassen/XMLWidgets Regards, Martijn
On Wed, 12 Apr 2000, Serge Stinckwich wrote:
Hi all,
i'm a bit confused with the behavior of the XMLDocument product.
I have a very simple XML Document : test
<?xml version="1.0"?> <doc> <p> bla bla ...</p> <p> bla bla ...</p> </doc>
I've got also a DTML method view_test :
<dtml-var standard_html_header> <h2><dtml-var title_or_id> <dtml-var document_title></h2>
<dtml-with "test[0]">
<dtml-in "getChildNodes()"> <p><dtml-var absolute_url></p> </dtml-in>
</dtml-with> <dtml-var standard_html_footer>
I launch the view method and i expect to have 2 URLs, i've got 5 with 3 non-existent nodes ...
I use the last version of XMLDocument.
I ran into something that might explain this when i was messing about with XMLDocument and the tree tag. One of the ways in which XML differs from SGML is that the whitespace between tags IS counted. So, if you check the meta types of the objects you're getting, you'll probably see 3 of them are the formatting space between your tags. Instead of getChildNodes(), try objectValues('p'), which will only return tags of type 'p'. I use this in my current production code, and it works fine. -- Have a better one, Curtis. <dtml-var standard_work_disclaimer>
participants (3)
-
Curtis Maloney -
Martijn Faassen -
Serge Stinckwich