SlideShare a Scribd company logo
1 of 13
Download to read offline
XML::Writer::Simple

                  Alberto Sim˜es
                             o
                  ambs@cpan.org


      Portuguese Perl Workshop 2008




Alberto Sim˜es ambs@cpan.org
           o                   XML::Writer::Simple
Why?




XML wasn’t designed to be written manually;
So, we normally generate XML;
But then, we need to write it          (in programs)

And we do not want to do that!




        Alberto Sim˜es ambs@cpan.org
                   o                    XML::Writer::Simple
Typical Java Code




System.out.println(quot; <agenda>quot;);
while(contact.next()) {
  System.out.println(quot;<contact>quot;);
  System.out.println(quot; <name>quot;+contact.name()+quot;</name>quot;);
  System.out.println(quot; <email>quot;+contact.mail()+quot;</email>quot;);
  System.out.println(quot; <tel>quot;+contact.tel()+quot;</tel>quot;);
  System.out.println(quot;</contact>quot;);
}
System.out.println(quot; </agenda>quot;);




           Alberto Sim˜es ambs@cpan.org
                      o                   XML::Writer::Simple
Possible Perl code




print quot; <agenda>nquot;;
for $contact (@contacts) {
  print quot;<contact>nquot;;
  print quot; <name>$contact->{name}</name>nquot;;
  print quot; <email>$contact->{mail}</email>nquot;;
  print quot; <tel>$contact->{tel}</tel>nquot;;
  print quot;</contact>nquot;;
}
print quot; </agenda>nquot;;




           Alberto Sim˜es ambs@cpan.org
                      o                   XML::Writer::Simple
Using XML::Writer::Simple




  print agenda(
     map { contact(
              name($_->{name}),
              email($_->{mail}),
              tel($_->{tel})) } @contacts )
Yeah, stolen from CGI!




            Alberto Sim˜es ambs@cpan.org
                       o                   XML::Writer::Simple
What tags to use?




we want a function for each tag:
    easy for HTML!
and for XML?
    what are the valid tags?
    who tell us?




        Alberto Sim˜es ambs@cpan.org
                   o                   XML::Writer::Simple
Full XML::Writer::Simple example




use XML::Writer::Simple
    tags => [qw/agenda contact name email tel/];

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
Full XML::Writer::Simple example using a DTD




use XML::Writer::Simple
    dtd => quot;agenda.dtdquot;;

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
Full XML::Writer::Simple example using a sample file




use XML::Writer::Simple
    xml => [qw/mycontacts.xml morecontacts.xml/];

print agenda(
   map { contact(
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )




         Alberto Sim˜es ambs@cpan.org
                    o                   XML::Writer::Simple
And about attributes?


  they do not need to be declared!
  just use them as you would under CGI.
  that is, use as first parameter an hash reference.



use XML::Writer::Simple
    xml => [qw/mycontacts.xml morecontacts.xml/];

print agenda(
   map { contact( { owner => quot;ambs@di.uminho.ptquot; },
            name($_->{name}),
            email($_->{mail}),
            tel($_->{tel})) } @contacts )



          Alberto Sim˜es ambs@cpan.org
                     o                   XML::Writer::Simple
And more! PowerTags



PowerTags:
    apply more than one XML tag;
    follow the Perl data structure;
PowerTag by example:
    ul_li(quot;aquot;,quot;bquot;,quot;cquot;)
         <ul><li>a</li><li>b</li><li>c</li></ul>
    ul_li({attr=>quot;valquot;},quot;aquot;,quot;bquot;)
         <ul attr=quot;valquot;><li>a</li><li>b</li></ul>
or yet...
table_tr_td( [quot;aquot;,quot;bquot;,quot;cquot;],[quot;dquot;,quot;equot;,quot;fquot;] );




        Alberto Sim˜es ambs@cpan.org
                   o                   XML::Writer::Simple
PowerTags — How to define them?




n levels;
Can be declared...
       use XML::Writer::Simple
           powertags=>[qw/ul_li ol_li/];
Can be created in runtime...
       powertag(quot;tablequot;,quot;trquot;,quot;tdquot;);




            Alberto Sim˜es ambs@cpan.org
                       o                   XML::Writer::Simple
Five Minutes Yet?




Alberto Sim˜es ambs@cpan.org
           o                   XML::Writer::Simple

More Related Content

Viewers also liked

Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac-Cgil Varese
 
El próximo escenario global
El próximo escenario global El próximo escenario global
El próximo escenario global Al Cougar
 
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Lazo Roljic
 
Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3Iñaki Lakarra
 
Abusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain NamesAbusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain Namesiptwins1
 
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
C:\Documents And Settings\Usuario\Escritorio\La Aventura De ApenderC:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
C:\Documents And Settings\Usuario\Escritorio\La Aventura De ApenderDavid Zarza
 
Tema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 FinalTema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 FinalmariasusanaSD
 
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013Sing Your Name
 
Collar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de NikkenCollar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de NikkenNIKKEN Perú
 
EACS Newsletter 2013
EACS Newsletter 2013EACS Newsletter 2013
EACS Newsletter 2013iantaylor2100
 
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13Juanjo Brizuela
 
La foto de un autor regional
La foto de un autor regionalLa foto de un autor regional
La foto de un autor regional51976122
 
Az web company profiling example
Az web   company profiling exampleAz web   company profiling example
Az web company profiling examplefrankpaul_con
 
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015 NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015 Keith G. Tidball
 
Sevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OSSevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OSFrancisco Jordano
 

Viewers also liked (20)

Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altroFisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
Fisac Varese Informa il numero di Ottobre 2012 - In piazza ed altro
 
Alerta epidemiologicano1 2015meningitismeningococica
Alerta epidemiologicano1 2015meningitismeningococicaAlerta epidemiologicano1 2015meningitismeningococica
Alerta epidemiologicano1 2015meningitismeningococica
 
Pikondoa
PikondoaPikondoa
Pikondoa
 
El próximo escenario global
El próximo escenario global El próximo escenario global
El próximo escenario global
 
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016Roljic_Lazo-Karton_naucnog_radnika-februar__2016
Roljic_Lazo-Karton_naucnog_radnika-februar__2016
 
August 2011 The Business Value of Office 365 for SharePoint users
August 2011 The Business Value of Office 365 for SharePoint usersAugust 2011 The Business Value of Office 365 for SharePoint users
August 2011 The Business Value of Office 365 for SharePoint users
 
Alv funciones
Alv   funcionesAlv   funciones
Alv funciones
 
Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3Usabilidad Convertibilidad 3
Usabilidad Convertibilidad 3
 
Abusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain NamesAbusive Registration And Use Of Domain Names
Abusive Registration And Use Of Domain Names
 
deber laboratorio
deber laboratoriodeber laboratorio
deber laboratorio
 
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
C:\Documents And Settings\Usuario\Escritorio\La Aventura De ApenderC:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
C:\Documents And Settings\Usuario\Escritorio\La Aventura De Apender
 
Tema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 FinalTema De Dominio Tcp Ip Version 1 Final
Tema De Dominio Tcp Ip Version 1 Final
 
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
Libro de la fundacion de El Pueblo de El Progreso Piaxtla Puebla 2013
 
Collar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de NikkenCollar y Brazalete Marquesa de Nikken
Collar y Brazalete Marquesa de Nikken
 
EACS Newsletter 2013
EACS Newsletter 2013EACS Newsletter 2013
EACS Newsletter 2013
 
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
Hoy es el primer día de tu nueva vida / Inguralde / Equiliqua 30oct13
 
La foto de un autor regional
La foto de un autor regionalLa foto de un autor regional
La foto de un autor regional
 
Az web company profiling example
Az web   company profiling exampleAz web   company profiling example
Az web company profiling example
 
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015 NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
NY EDEN for Municipal Clerks - Cornell Clerks institute 2015
 
Sevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OSSevillajs: Una tarde con Firefox OS
Sevillajs: Una tarde con Firefox OS
 

Similar to XML::Writer::Simple

Lecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPyucefmerhi
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertextfrankieroberto
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemasMetosin Oy
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPPJack Moffitt
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...Codemotion
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009David Pollak
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0Yaser Zhian
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetSamuel Lampa
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdatedoscon2007
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeStephen Darlington
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Raffi Krikorian
 
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perlJoe Jiang
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01google
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryTricode (part of Dept)
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python scriptsaniac
 

Similar to XML::Writer::Simple (20)

Lecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITPLecture 4 - Comm Lab: Web @ ITP
Lecture 4 - Comm Lab: Web @ ITP
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 
Odp
OdpOdp
Odp
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
 
The bones of a nice Python script
The bones of a nice Python scriptThe bones of a nice Python script
The bones of a nice Python script
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 

More from Alberto Simões

Language Identification: A neural network approach
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approachAlberto Simões
 
Making the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryAlberto Simões
 
Dictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationAlberto Simões
 
EMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesAlberto Simões
 
Aula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAlberto Simões
 
Aula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAlberto Simões
 
Aula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAlberto Simões
 
Aula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAlberto Simões
 
Building C and C++ libraries with Perl
Building C and C++ libraries with PerlBuilding C and C++ libraries with Perl
Building C and C++ libraries with PerlAlberto Simões
 
Processing XML: a rewriting system approach
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approachAlberto Simões
 
Arquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaAlberto Simões
 

More from Alberto Simões (20)

Source Code Quality
Source Code QualitySource Code Quality
Source Code Quality
 
Language Identification: A neural network approach
Language Identification: A neural network approachLanguage Identification: A neural network approach
Language Identification: A neural network approach
 
Google Maps JS API
Google Maps JS APIGoogle Maps JS API
Google Maps JS API
 
Making the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionaryMaking the most of a 100-year-old dictionary
Making the most of a 100-year-old dictionary
 
Dictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry TranslationDictionary Alignment by Rewrite-based Entry Translation
Dictionary Alignment by Rewrite-based Entry Translation
 
EMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized DictionariesEMLex-A5: Specialized Dictionaries
EMLex-A5: Specialized Dictionaries
 
Modelação de Dados
Modelação de DadosModelação de Dados
Modelação de Dados
 
Aula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de SequênciaAula 04 - Introdução aos Diagramas de Sequência
Aula 04 - Introdução aos Diagramas de Sequência
 
Aula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de AtividadeAula 03 - Introdução aos Diagramas de Atividade
Aula 03 - Introdução aos Diagramas de Atividade
 
Aula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de RequisitosAula 02 - Engenharia de Requisitos
Aula 02 - Engenharia de Requisitos
 
Aula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de InformaçãoAula 01 - Planeamento de Sistemas de Informação
Aula 01 - Planeamento de Sistemas de Informação
 
Building C and C++ libraries with Perl
Building C and C++ libraries with PerlBuilding C and C++ libraries with Perl
Building C and C++ libraries with Perl
 
PLN em Perl
PLN em PerlPLN em Perl
PLN em Perl
 
Classification Systems
Classification SystemsClassification Systems
Classification Systems
 
Redes de Pert
Redes de PertRedes de Pert
Redes de Pert
 
Dancing Tutorial
Dancing TutorialDancing Tutorial
Dancing Tutorial
 
Processing XML: a rewriting system approach
Processing XML: a rewriting system approachProcessing XML: a rewriting system approach
Processing XML: a rewriting system approach
 
Sistemas de Numeração
Sistemas de NumeraçãoSistemas de Numeração
Sistemas de Numeração
 
Álgebra de Boole
Álgebra de BooleÁlgebra de Boole
Álgebra de Boole
 
Arquitecturas de Tradução Automática
Arquitecturas de Tradução AutomáticaArquitecturas de Tradução Automática
Arquitecturas de Tradução Automática
 

Recently uploaded

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 

Recently uploaded (20)

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 

XML::Writer::Simple

  • 1. XML::Writer::Simple Alberto Sim˜es o ambs@cpan.org Portuguese Perl Workshop 2008 Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 2. Why? XML wasn’t designed to be written manually; So, we normally generate XML; But then, we need to write it (in programs) And we do not want to do that! Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 3. Typical Java Code System.out.println(quot; <agenda>quot;); while(contact.next()) { System.out.println(quot;<contact>quot;); System.out.println(quot; <name>quot;+contact.name()+quot;</name>quot;); System.out.println(quot; <email>quot;+contact.mail()+quot;</email>quot;); System.out.println(quot; <tel>quot;+contact.tel()+quot;</tel>quot;); System.out.println(quot;</contact>quot;); } System.out.println(quot; </agenda>quot;); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 4. Possible Perl code print quot; <agenda>nquot;; for $contact (@contacts) { print quot;<contact>nquot;; print quot; <name>$contact->{name}</name>nquot;; print quot; <email>$contact->{mail}</email>nquot;; print quot; <tel>$contact->{tel}</tel>nquot;; print quot;</contact>nquot;; } print quot; </agenda>nquot;; Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 5. Using XML::Writer::Simple print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Yeah, stolen from CGI! Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 6. What tags to use? we want a function for each tag: easy for HTML! and for XML? what are the valid tags? who tell us? Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 7. Full XML::Writer::Simple example use XML::Writer::Simple tags => [qw/agenda contact name email tel/]; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 8. Full XML::Writer::Simple example using a DTD use XML::Writer::Simple dtd => quot;agenda.dtdquot;; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 9. Full XML::Writer::Simple example using a sample file use XML::Writer::Simple xml => [qw/mycontacts.xml morecontacts.xml/]; print agenda( map { contact( name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 10. And about attributes? they do not need to be declared! just use them as you would under CGI. that is, use as first parameter an hash reference. use XML::Writer::Simple xml => [qw/mycontacts.xml morecontacts.xml/]; print agenda( map { contact( { owner => quot;ambs@di.uminho.ptquot; }, name($_->{name}), email($_->{mail}), tel($_->{tel})) } @contacts ) Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 11. And more! PowerTags PowerTags: apply more than one XML tag; follow the Perl data structure; PowerTag by example: ul_li(quot;aquot;,quot;bquot;,quot;cquot;) <ul><li>a</li><li>b</li><li>c</li></ul> ul_li({attr=>quot;valquot;},quot;aquot;,quot;bquot;) <ul attr=quot;valquot;><li>a</li><li>b</li></ul> or yet... table_tr_td( [quot;aquot;,quot;bquot;,quot;cquot;],[quot;dquot;,quot;equot;,quot;fquot;] ); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 12. PowerTags — How to define them? n levels; Can be declared... use XML::Writer::Simple powertags=>[qw/ul_li ol_li/]; Can be created in runtime... powertag(quot;tablequot;,quot;trquot;,quot;tdquot;); Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple
  • 13. Five Minutes Yet? Alberto Sim˜es ambs@cpan.org o XML::Writer::Simple