[Zope] How do I control iteration over XML elements?
Curtis Maloney
curtis@umd.com.au
Tue, 1 Aug 2000 16:40:07 +1000
On Tue, 01 Aug 2000, Jean Jordaan wrote:
> hi Curtis
>
> Yaaay! It works :) Thanks a lot!
>
> I wouldn't have found "objectValues" on my own .. where'd
> you learn about that? I'm ploughing through docs and wiki's
> now, just don't know if they're the right ones. I also need
> to read more about Python ..
>
The Zope Quick Reference. An indispensible resource, which you can find
through the zope.com Documentation section.
> Anyway, I messed about with your instructions a bit, and
> tried:
>
> <dtml-var "text_content('member')">
>
> (which renders nothing), and:
>
> <dtml-var "text_content">
>
> which renders:
>
> <Python Method object at 13bead8>
>
> Dunno how soon I'd've navigated that maze on my own. The
> "text_content" I can understand -- putting it between ""
> means that it should be evaluated, so text_content is
> evaluated without parameters, and dtml-var is being asked
> to render the method itself. Doing "text_content('member')",
> text_content is replaced by the result of evaluating it
> on 'member' .. this works when it's fed the output of
> getElementsByTagName, but since I'm already "in" the members,
> there aren't any member elements to be had inside them --
> only their text_contents.
Another option is getChildNodes()
>
> Well, that's as far as I can puzzle it out ..
>
> Now for another question (which I'm throwing to the group
> seperately too):
>
> How do I show all groups that a specific member is part
> of? In other words, if I have:
>
> <teams>
> <team>
> <name>Ham</name>
> <desc>White papers, brochures, case studies.</desc>
> <member>Eduan</member>
> <member>Jacqui</member>
> </team>
>
> <team>
> <name>Green eggs</name>
> <desc>Green papers, brochures, case studies.</desc>
> <member>Tracey</member>
> <member>Jacqui</member>
> </team>
> </teams>
>
> how do I get
>
> "Jacqui is member of the Ham and Green eggs teams."
yuck....
<dtml-var member_name> is member of
<dtml-in "objectValues('team')">
<dtml-in "objectValues('member')">
<dtml-if "text_content() == member_name"><dtml-var name>, </dtml-if>
</dtml-in>
</dtml-in>
that's my best guess, but you _might_ run into a problem with 'name'....
Have a better one,
Curtis.