SlideShare a Scribd company logo
Validating XML - Avoiding the pain

        Arne Blankerts <arne@thephp.cc>, TobiasSchlitt <toby@php.net>

                                                       IPC 2009


                                                   2009-11-17




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   1 / 18
Outline




 1 Welcome


 2 Introduction


 3 Schema formats


 4 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   2 / 18
Arne Blankerts




         Arne Blankerts <arne@thephp.cc>
         PHP since 1999 (10 years of PHP!)
         Co-Founder of thePHP.cc
         ballyhoo. werbeagentur.
         Open source addicted
                 Inventor and lead developer of fCMS site
                 system
                 Contributor and translator for the PHP manual




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   3 / 18
Tobias Schlitt



         Tobias Schlitt <toby@php.net>
         PHP since 2001
         Freelancing consultant
         Qualified IT Specialist
         Studying CS at TU Dortmund
         (finishing 2010)
         OSS addicted
                 PHP
                 eZ Components
                 PHPUnit




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   4 / 18
Outline




 1 Welcome


 2 Introduction
          Why the hell validate?
          Validation basics

 3 Schema formats


 4 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   5 / 18
XML is everywhere




          On your HD
          On the web
          In your app




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   6 / 18
XML is everywhere




          On your HD
          On the web
          In your app




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   6 / 18
XML is everywhere




          On your HD
          On the web
          In your app




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   6 / 18
XML comes from everywhere




          From the web
          From your app
          From your users
          From 3rd parties




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   7 / 18
XML comes from everywhere




          From the web
          From your app
          From your users
          From 3rd parties




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   7 / 18
XML comes from everywhere




          From the web
          From your app
          From your users
          From 3rd parties




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   7 / 18
XML comes from everywhere




          From the web
          From your app
          From your users
          From 3rd parties




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   7 / 18
So why validate?



          Broken incoming data breaks your app
          Broken outgoing data breaks other apps
          You test code, why not test XML?




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   8 / 18
So why validate?



          Broken incoming data breaks your app
          Broken outgoing data breaks other apps
          You test code, why not test XML?




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   8 / 18
So why validate?



          Broken incoming data breaks your app
          Broken outgoing data breaks other apps
          You test code, why not test XML?




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   8 / 18
So why validate?



          Broken incoming data breaks your app
          Broken outgoing data breaks other apps
          You test code, why not test XML?




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   8 / 18
What is a XML schema?




          Defines the structure of data
          Possibly defines data types
          Used to validate correctness
          Helpful as documentation
          Similar to database schemas!




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   9 / 18
When to use it?




          On XML generation in your app
          Before your app consumes XML
          In your tests
          Give to your XML consumers




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   10 / 18
Outline



 1 Welcome


 2 Introduction


 3 Schema formats
          Overview
          DTD
          XML Schema

 4 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   11 / 18
XML schema formats




              DTD
               XSD
    RELAX NG




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   12 / 18
XML schema formats




              DTD               Document Type Definition
                                Part of the XML specification
                                Allows definition of entities
                                No advanced type support
                                Does not support different types for same element name
               XSD
    RELAX NG




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   12 / 18
XML schema formats




              DTD
               XSD              XML Schema
                                W3C recommendation since May 2001
                                Advanced type support
                                Support for keys and key references
                                No support for entities
    RELAX NG




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   12 / 18
XML schema formats




              DTD
               XSD
    RELAX NG                    Regular Language for XML Next Generation
                                Defined by OASIS, ISO/IEC 19757
                                Generally more powerful than XSD
                                No support for entities
                                Not (yet?) as popular as XSD




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   12 / 18
DTD




 Let’s dig into the code. . .
         Schema definitions
         Entities




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   13 / 18
DTD




 Let’s dig into the code. . .
         Schema definitions
         Advanced types
         Key and key-ref




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   14 / 18
XSD goodies




          Qualified / unqualified
          <any> namespace handling
          Validation of external elements/attributes
          Abstract types and inheritance
          Nillable




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   15 / 18
XSD goodies




          Qualified / unqualified
          <any> namespace handling
                  ##any
                  ##other
                  ##local
          Validation of external elements/attributes
          Abstract types and inheritance
          Nillable




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   15 / 18
XSD goodies




          Qualified / unqualified
          <any> namespace handling
          Validation of external elements/attributes
                  strict
                  skip
                  lax
          Abstract types and inheritance
          Nillable




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   15 / 18
XSD goodies




          Qualified / unqualified
          <any> namespace handling
          Validation of external elements/attributes
          Abstract types and inheritance
          Nillable




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   15 / 18
XSD goodies




          Qualified / unqualified
          <any> namespace handling
          Validation of external elements/attributes
          Abstract types and inheritance
          Nillable




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   15 / 18
Outline




 1 Welcome


 2 Introduction


 3 Schema formats


 4 The end




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   16 / 18
Q/A




          Are there any questions left?
          Please give us some feedback!




Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   17 / 18
The end




          We hope you enjoyed the session!
          Slides and material:
                  Delivered by Software & Support
                  http://schlitt.info/opensource
                  On Slideshare (http://slideshare.net)
          Contact us:
                  Arne Blankerts <arne@thephp.cc>
                  Tobias Schlitt <toby@php.net>
          Give us feedback on http://joind.in/1043

Arne Blankerts, Tobias Schlitt (IPC 2009)   Validating XML - Avoiding the pain   2009-11-17   18 / 18

More Related Content

Similar to Validating XML - Avoiding the pain (20)

PDF
XPath - A practical guide
Tobias Schlitt
 
PDF
Validating Xml
LiquidHub
 
PDF
XML in software development
Lars Marius Garshol
 
PDF
XML and XPath with PHP
Tobias Schlitt
 
PPTX
Agile xml
Richard Winslow
 
DOCX
Bt0078 website design
smumbahelp
 
PPT
Lecture 1 - Getting to know XML
phanleson
 
PDF
Why XML is important for everyone, especially technical communicators
ECM-Search Consultant - EContent Magazine
 
PPTX
Xml presentation
Miguel Angel Teheran Garcia
 
PPT
Xml 215-presentation
Simsima Tchakma
 
PDF
QueryPath: It's like PHP jQuery in Drupal!
Matt Butcher
 
PPTX
XML1.pptx
53ShaikhImadoddin
 
PDF
XML Schema Patterns for Databinding
Paul Downey
 
PPT
Xml nisha dwivedi
NIIT
 
XPath - A practical guide
Tobias Schlitt
 
Validating Xml
LiquidHub
 
XML in software development
Lars Marius Garshol
 
XML and XPath with PHP
Tobias Schlitt
 
Agile xml
Richard Winslow
 
Bt0078 website design
smumbahelp
 
Lecture 1 - Getting to know XML
phanleson
 
Why XML is important for everyone, especially technical communicators
ECM-Search Consultant - EContent Magazine
 
Xml presentation
Miguel Angel Teheran Garcia
 
Xml 215-presentation
Simsima Tchakma
 
QueryPath: It's like PHP jQuery in Drupal!
Matt Butcher
 
XML Schema Patterns for Databinding
Paul Downey
 
Xml nisha dwivedi
NIIT
 

Recently uploaded (20)

PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Ad

Validating XML - Avoiding the pain

  • 1. Validating XML - Avoiding the pain Arne Blankerts <[email protected]>, TobiasSchlitt <[email protected]> IPC 2009 2009-11-17 Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 1 / 18
  • 2. Outline 1 Welcome 2 Introduction 3 Schema formats 4 The end Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 2 / 18
  • 3. Arne Blankerts Arne Blankerts <[email protected]> PHP since 1999 (10 years of PHP!) Co-Founder of thePHP.cc ballyhoo. werbeagentur. Open source addicted Inventor and lead developer of fCMS site system Contributor and translator for the PHP manual Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 3 / 18
  • 4. Tobias Schlitt Tobias Schlitt <[email protected]> PHP since 2001 Freelancing consultant Qualified IT Specialist Studying CS at TU Dortmund (finishing 2010) OSS addicted PHP eZ Components PHPUnit Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 4 / 18
  • 5. Outline 1 Welcome 2 Introduction Why the hell validate? Validation basics 3 Schema formats 4 The end Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 5 / 18
  • 6. XML is everywhere On your HD On the web In your app Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 6 / 18
  • 7. XML is everywhere On your HD On the web In your app Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 6 / 18
  • 8. XML is everywhere On your HD On the web In your app Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 6 / 18
  • 9. XML comes from everywhere From the web From your app From your users From 3rd parties Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 7 / 18
  • 10. XML comes from everywhere From the web From your app From your users From 3rd parties Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 7 / 18
  • 11. XML comes from everywhere From the web From your app From your users From 3rd parties Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 7 / 18
  • 12. XML comes from everywhere From the web From your app From your users From 3rd parties Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 7 / 18
  • 13. So why validate? Broken incoming data breaks your app Broken outgoing data breaks other apps You test code, why not test XML? Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 8 / 18
  • 14. So why validate? Broken incoming data breaks your app Broken outgoing data breaks other apps You test code, why not test XML? Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 8 / 18
  • 15. So why validate? Broken incoming data breaks your app Broken outgoing data breaks other apps You test code, why not test XML? Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 8 / 18
  • 16. So why validate? Broken incoming data breaks your app Broken outgoing data breaks other apps You test code, why not test XML? Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 8 / 18
  • 17. What is a XML schema? Defines the structure of data Possibly defines data types Used to validate correctness Helpful as documentation Similar to database schemas! Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 9 / 18
  • 18. When to use it? On XML generation in your app Before your app consumes XML In your tests Give to your XML consumers Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 10 / 18
  • 19. Outline 1 Welcome 2 Introduction 3 Schema formats Overview DTD XML Schema 4 The end Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 11 / 18
  • 20. XML schema formats DTD XSD RELAX NG Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 12 / 18
  • 21. XML schema formats DTD Document Type Definition Part of the XML specification Allows definition of entities No advanced type support Does not support different types for same element name XSD RELAX NG Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 12 / 18
  • 22. XML schema formats DTD XSD XML Schema W3C recommendation since May 2001 Advanced type support Support for keys and key references No support for entities RELAX NG Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 12 / 18
  • 23. XML schema formats DTD XSD RELAX NG Regular Language for XML Next Generation Defined by OASIS, ISO/IEC 19757 Generally more powerful than XSD No support for entities Not (yet?) as popular as XSD Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 12 / 18
  • 24. DTD Let’s dig into the code. . . Schema definitions Entities Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 13 / 18
  • 25. DTD Let’s dig into the code. . . Schema definitions Advanced types Key and key-ref Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 14 / 18
  • 26. XSD goodies Qualified / unqualified <any> namespace handling Validation of external elements/attributes Abstract types and inheritance Nillable Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 15 / 18
  • 27. XSD goodies Qualified / unqualified <any> namespace handling ##any ##other ##local Validation of external elements/attributes Abstract types and inheritance Nillable Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 15 / 18
  • 28. XSD goodies Qualified / unqualified <any> namespace handling Validation of external elements/attributes strict skip lax Abstract types and inheritance Nillable Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 15 / 18
  • 29. XSD goodies Qualified / unqualified <any> namespace handling Validation of external elements/attributes Abstract types and inheritance Nillable Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 15 / 18
  • 30. XSD goodies Qualified / unqualified <any> namespace handling Validation of external elements/attributes Abstract types and inheritance Nillable Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 15 / 18
  • 31. Outline 1 Welcome 2 Introduction 3 Schema formats 4 The end Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 16 / 18
  • 32. Q/A Are there any questions left? Please give us some feedback! Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 17 / 18
  • 33. The end We hope you enjoyed the session! Slides and material: Delivered by Software & Support http://schlitt.info/opensource On Slideshare (http://slideshare.net) Contact us: Arne Blankerts <[email protected]> Tobias Schlitt <[email protected]> Give us feedback on http://joind.in/1043 Arne Blankerts, Tobias Schlitt (IPC 2009) Validating XML - Avoiding the pain 2009-11-17 18 / 18