help need with template toolkit process

veeru reddy <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CA+JyuYU-oFoKcUGu0=x-JhKUYXX67Beq1478t6-fpAFzv_Z3iA@mail.gmail.com>
Hi everyone,
I have one xml data and I through XML::simple then i stored in a string and
processing using template. but my problem is I have some repeated nodes in
xml data suppose university name is repeated then no need to process . how
can i do with template if  if same name occurs twice then font process that
one like that. I am converting xml data into pdf so same data occurring two
times so i need to overcome this problem.
<university>
<name>svu</name>
 <location>ravru</location>
 <branch>
   <electronics>
     <student name="xxx" number="12">
     <semester number="1"subjects="7" rank="2"/>
     </student>
     <student name="xxx" number="15">
     <semester number="1" subjects="7" rank="10"/>
     <semester number="2" subjects="4" rank="1"/>
      </student>
       <student name="xxx" number="16">
       <semester number="1"subjects="7" rank="2"/>
      <semester number="2"subjects="4" rank="2"/>
       </student>
    </electronics>
 </branch>
 </university>
 <university>
 <name>sku</name>
  <location>ANTP</location>
   <branch>
     <electronics>
       <student name="xxx" number="12">
     <semester number="3"subjects="6" rank="20"/>
        </section>
    </electronics>
  </branch>
 </university>

I used XML::Simple to store this data into one hash data structure variable
$data and that information is like this

$var1={
        'university'=>{
           'name'=>'svu',
           'location'=>'ravru',
            'branch'=>{
                     'electronics'=>{
                                'student'=>[
                                         {
                                        'name'=>'mikky',
                                         'number'=>'12',
                                           'semester'=>{
                                                  'Number'=>'1',
                                                  'subjects'=>'7',
                                                   'rank'=>'1'
                                                  }
                                               },
                                       {
                                        'name'=>'vijju',
                                         'number'=>'15',
                                           'semester'=>[
                                                {
                                               'number'=>'1',
                                                'subjects'=>'3',
                                                 'rank'=>'10'
                                                  },
                                                 {
                                                'number'=>'1',
                                                'subjects'=>'2',
                                                 'rank'=>'1'
                                                  }
                                                 ]
                                               },
                                            ]
                                          }
                                         }
                                       };

             'name'=>'sku',
             'location'=>'ANTP',
            'branch'=>{
               'electronics'=>{
                          'student'=>[
                                     {
                                     'name'=>'shyam',
                                     'number'=>'12',
                                       'semester'=>{
                                                'Number'=>'3',
                                                'subjects'=>'5',
                                                'rank'=>'20'
                                                  }
                                               },

                                             ]
                                           }

                                         }
                                       };

I written some script using template toolkit to genarate pdf file using
pdflatex compiler.

[% FOREACH st IN university %]
[% st.name %]
[%st.location%]
studentdata:
[% FOREACH student IN st.branch.electronics.student %]
Component type: [%+ student.name +%][%+ student.number +%]
       [% FOREACH semester IN student.semester %]
   [%+ semester.number +%]
   [%+ semester.subjects +%]
   [%+  semester.rank +%]
     [% END %]
 [% END %]
[% END %]
can any one help me how to remove duplicate data .

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.