Sorry Matt, I guess I made the highly simplified XML that I posted a
little too simplified.

Here is a better generalization of the XML I want to produce:

     .........
       <users>
          <user>
             <first_name> ... </first_name>
             <user_id> ... </user_id>
             <last_name> ... </last_name>
             <username> ... </username>
             <users_arms>
               <users-arm>
                 <hand>
                   <fingers>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                   </fingers>
                 </hand>
                 <elbow>  ....  </elbow>
               </users-arm>
               <users-arm>
                 <hand>
                   <fingers>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                     <finger> .... </finger>
                   </fingers>
                 </hand>
                 <elbow>  ....  </elbow>
               </users-arm>
             </users-arms>
          </user>
          <user>  .... </user>
        </users>
     .....

Basically what I am trying to produce is a deeply nested XML tree
where each group of singular elements is enclosed in a larger plural
element (arms->arm, fingers->finger).

Doing what you suggested works fine whith the question I originally
posted, but my actual need is more complicated (again, sorry for
oversimplifying it).

After posting my question to the mailling list, I looked around myself
for an answer to my problem.  I haven't yet found a way to use
TaglibHelper to do what I want, but I have been looking at the
TaglibHelper code and I think that a very minor change would make the
functionality possible.

I think it may be as simple as changing this snippet of code:

170     # each item within an array should have a wrapper "-item" tag
171        my $item;
172       if ($options{itemtag}) {
173            $item = $document->createElement($options{itemtag});
174        }
175       else {
176            my $funcname = $options{'array_uses_hash'} ? $lastkey :
177                    func_name($funspec) || func_name($funspec);
178            $funcname =~ s/_|\s/-/g;    # convert back to XML-style tagnames
179            $item = $document->createElement("${funcname}-item");
180        }

to this new snippet of code:

170     # each item within an array should have a wrapper "-item" tag
171                     my $item;
172                if ($options{itemtag}) {
173                    $item = $document->createElement($options{itemtag});
174                }
175             elsif($options{'plural_tags'}) {
176                 my $new_element_name = $lastkey;
177                 $new_element_name =~ s/s$//;        # Remove trailing s's
from plural tags
178                 $item = $document->createElement($new_element_name);
179             }
180                else {
181                    my $funcname = $options{'array_uses_hash'} ? $lastkey :
182                            func_name($funspec) || func_name($funspec);
183                    $funcname =~ s/_|\s/-/g;    # convert back to
XML-style tagnames
184                    $item = $document->createElement("${funcname}-item");
185                }

I have not yet tested the above code (will probably do that in the morning)

Am I oversimplying the modifications needed to add this
functionallity?  Is there something that I'm missing?

Thanks,

-Chuck

On 10/3/05, Matt Sergeant <[EMAIL PROTECTED]> wrote:
> On 30 Sep 2005, at 15:12, Chuck Phillips wrote:
>
> > Any ideas on how to convince TaglibHelper to not include the unwanted
> > "-item" tags?
>
> return:
>
> 'users' => [
>     {
>               'first_name' => '...',
>               'user_id' => '...',
>               'last_name' => '...',
>               'username' => '...',
>     },
>     ...
> ]
>
> and set itemtag=user in your @EXPORT_TAGLIB line.
>
> Matt.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to