From: "Andrew S. Townley" Date: 2009-03-29T09:26:21+09:00 Subject: Re: [PATCH] tagz-5.0.0 -- processing instruction support (BROKEN) On Sat, 2009-03-28 at 03:05 +0900, Andrew S. Townley wrote: > Hi Ara, > > I'm sure you're sick of me by now, but I've added processing instruction > support to tagz. It may not suit your style, but I've tried to keep it > in the spirit of the library. > > excalibur$ diff > -u /var/lib/gems/1.8/gems/tagz-5.0.0/lib/tagz.rb /tmp/tagz.rb > --- /var/lib/gems/1.8/gems/tagz-5.0.0/lib/tagz.rb 2009-03-24 > 11:58:05.000000000 +0000 > +++ /tmp/tagz.rb 2009-03-27 18:01:11.000000000 +0000 Hi Ara, I was wondering if you might be able to help me. It seems that by moving the attribute processing into a separate method, I've screwed up the scope handling. The patch does indeed deliver processing instructions and works fine in the "happy day" path, but if you use any kind of conditionals inside an element block, it seems to go haywire. i.e.: $ cat a.rb #require 'rubygems' require 'tagz' include Tagz.globally def makeelt container_{ element_ { child1_ "hello world" } arr = [] if arr.length > 0 element2_ { child2_ "some child" } end } end puts Tagz { list_{ 2.times do makeelt end } } With the patch applied, it gives the following bogus markup: hello worldhello world ^^^^^^^^^^^ With your version, it works as expected, so obviously the patch is busted. Clearly, I don't quite understand what's going on enough to know why what I changed would cause this sort of behavior. Would you have any ideas? The PI support is a bit of syntax sugar that will be handy for generating some of the XML that I need to generate, but I can get by with the vanilla one for now. Still, I'd like to understand why the behavior occurs. If you or anyone else has an idea, I'd love to hear it. If you add an element to the array, it works as expected, so the conditional is certainly the key somehow... $ ruby a.rb | tidy -xml -i No warnings or errors were found. hello world some child hello world some child Other than that, I have to say that I've found Tagz absolutely fantastic to work with. I'm in the process of converting some of my code to use it instead of using string concatenation & hand-coded elements for building XML, and it just makes sense. Brilliant stuff! Cheers, ast -- Andrew S. Townley http://atownley.org