xml versus the new kids on the block (zc10 2010-11-03)
DESCRIPTION
Presentation given at ZendCon 2010.TRANSCRIPT
![Page 1: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/1.jpg)
XMLVS.
THE NEW KIDS ON THE BLOCK
![Page 2: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/2.jpg)
David Zülke
![Page 3: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/3.jpg)
David Zuelke
![Page 4: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/4.jpg)
![Page 5: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/5.jpg)
![Page 6: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/6.jpg)
http://en.wikipedia.org/wiki/File:EU-Germany.svg
![Page 7: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/7.jpg)
http://en.wikipedia.org/wiki/File:München_Panorama.JPG
![Page 8: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/8.jpg)
Founder
![Page 10: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/10.jpg)
Lead Developer
![Page 13: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/13.jpg)
TODAY'S MENU
• XML (and where it took a wrong turn)
• HTML 5 (and why it makes me very, very angry)
• JSON (and why it's not always as useful as you may think)
• YAML (and why it makes my eyes bleed)
![Page 14: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/14.jpg)
but first
![Page 15: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/15.jpg)
I'd like to hear from you, dear audience
![Page 16: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/16.jpg)
what do you love, hate, adore or loathe with a passion?
![Page 17: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/17.jpg)
XMLeXtensible Markup Language
![Page 18: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/18.jpg)
"extensible" mostly refers to the Namespaces concept
![Page 19: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/19.jpg)
VALIDATION
• XML Schema (validates the grammar of a document)
• RELAX NG (like XML Schema, just full of win)
• Except it's so awesome it sucks at reporting errors :(
• Schematron (validates the semantics of a document)
•DTD (RRRRRRRAAAAAAAAAAAAAAAAAGGGGEEEE)
![Page 20: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/20.jpg)
OTHER GOODIES
• XPath and XQuery for querying documents
• XPath is an expression syntax, XQuery a full query language
• XSLT to transform documents to XML, HTML, text, ...
•Makes heavy use of XPath
• XIncludes
• Allow re-use of content within and across documents
![Page 21: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/21.jpg)
READING AND WRITING
• Push Parsing, uses events to notify app during parsing
• Example: SAX
• Pull Parsing, allows app to retrieve or skip elements
• Example: PHP's ext/xmlreader
•DOM, constructs an object representation of the tree
• Example: DOM (duh)
![Page 22: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/22.jpg)
but most importantly
![Page 23: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/23.jpg)
Mixed Content!
![Page 24: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/24.jpg)
<?xml version="1.0" encoding="utf-‐8"?><products xmlns="http://acme.com/shop/products"> <product id="123"> <name>Bacon</name> <price>5.99</price> </product></products>
![Page 25: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/25.jpg)
<?xml version="1.0" encoding="utf-‐8"?><products xmlns="http://acme.com/shop/products"> <product id="123"> <name>Bacon</name> <price>5.99</price> OMNOMNOM Bacon </product></products>
![Page 26: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/26.jpg)
and you can add elements without changing the structure
![Page 27: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/27.jpg)
<?xml version="1.0" encoding="utf-‐8"?><products xmlns="http://acme.com/shop/products"> <product id="123"> <name>Bacon</name> <price>5.99</price> </product></products>
![Page 28: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/28.jpg)
<?xml version="1.0" encoding="utf-‐8"?><products xmlns="http://acme.com/shop/products"> <product id="123"> <name xml:lang="en">Bacon</name> <name xml:lang="de">Speck</name> <price>5.99</price> </product></products>
![Page 29: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/29.jpg)
<?xml version="1.0" encoding="utf-‐8"?><products xmlns="http://acme.com/shop/products"> <product id="123"> <name xml:lang="en">Bacon</name> <name xml:lang="de">Speck</name> <price>5.99</price> <link rel="category" href="..." /> </product></products>
![Page 30: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/30.jpg)
XML: doing it right
![Page 31: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/31.jpg)
<?xml version="1.0" encoding="utf-‐8" standalone="yes"?><search> <total_results>6</total_results> <items_per_page>2</items_per_page> <start_index>1</start_index> <link href="http://openapi.lovefilm.com/catalog/games?start_index=1&items_per_page=2&term=old" rel="self" title="self"/> <link href="http://openapi.lovefilm.com/catalog/games?start_index=3&items_per_page=2&term=old" rel="next" title="next"/> <link href="http://openapi.lovefilm.com/catalog/games?start_index=5&items_per_page=2&term=old" rel="last" title="last"/> <catalog_title> <can_rent>true</can_rent> <release_date>2003-‐09-‐12</release_date> <title full="Star Wars: Knights of the Old Republic" clean="Star Wars: Knights of the Old Republic"/> <id>http://openapi.lovefilm.com/catalog/title/59643</id> <adult>false</adult> <number_of_ratings>574</number_of_ratings> <rating>4</rating> <category scheme="http://openapi.lovefilm.com/categories/catalog" term="games"/> <category scheme="http://openapi.lovefilm.com/categories/format" term="Xbox"/> <category scheme="http://openapi.lovefilm.com/categories/genres" term="Adventure"/> <category scheme="http://openapi.lovefilm.com/categories/genres" term="Role-‐playing"/> <category scheme="http://openapi.lovefilm.com/categories/certificates/bbfc" term="TBC"/> <link href="http://openapi.lovefilm.com/catalog/title/59643/synopsis" rel="http://schemas.lovefilm.com/synopsis" title="synopsis"/> <link href="http://openapi.lovefilm.com/catalog/title/59643/reviews" rel="http://schemas.lovefilm.com/reviews" title="reviews"/> <link href="http://www.lovefilm.com/product/59643-‐Star-‐Wars-‐Knights-‐of-‐the-‐Old-‐Republic.html?cid=LFAPI" rel="alternate" title="web page"/> </catalog_title></search>
![Page 32: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/32.jpg)
which brings me to...
![Page 33: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/33.jpg)
HATEOAS AND HYPERMEDIAThe Main Ingredient For Your REST API
![Page 34: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/34.jpg)
XML: doing it wrong
![Page 35: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/35.jpg)
<?xml version="1.0" encoding="UTF-‐8"?><!DOCTYPE plist PUBLIC "-‐//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-‐1.0.dtd"><plist version="1.0"><dict> <key>DefaultProfileChoices</key> <dict> <key>AC Power</key> <integer>2</integer> <key>Battery Power</key> <integer>1</integer> <key>UPS Power</key> <integer>1</integer> </dict> <key>SystemProfileDefaults</key> <array><!-‐-‐ Profile 0 -‐-‐> <dict><!-‐-‐ AC Power -‐ unused -‐-‐> <key>AC Power</key> <dict> <!-‐-‐ ... -‐-‐> </dict> </dict> </array></dict></plist>
![Page 36: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/36.jpg)
but pleasedo not serialize objects to XML
(I'm looking at you, SOAP)
![Page 37: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/37.jpg)
HTML 5Such a mess :(
![Page 38: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/38.jpg)
HTML 5
•Neither SGML nor XML
• so browser vendors need to write new (inefficient) parsers
•Does not have a DTD anymore
• how could it, given how it's not SGML...
• Completely idiotic stuff like data-* attributes
• And they're even proud of it...
![Page 39: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/39.jpg)
<li class="user" data-‐name="John Resig" data-‐city="Boston" data-‐lang="js" data-‐food="Bacon"> <b>John says:</b> <span>Hello, how are you?</span></li>
![Page 40: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/40.jpg)
but that's already possible in XML!
![Page 41: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/41.jpg)
<li class="user" xmlns:myapp="http://myapp.com/v1" myapp:name="John Resig" myapp:city="Boston" myapp:lang="js" myapp:food="Bacon"> <b>John says:</b> <span>Hello, how are you?</span></li>
![Page 42: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/42.jpg)
JSONJavaScript Object Notation
![Page 43: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/43.jpg)
JSON PROS AND CONS
•Quite efficient, simple, universally supported in many languages
• Very good for serializing objects
• Built-in types, do not need explicit declaration
•No schemas
•No mixed content
![Page 44: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/44.jpg)
win: store arbitrary keys and values
![Page 45: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/45.jpg)
{ "_id" : "bc2a41170621c326ec68382f846d5764", "_rev" : "2612672603", "item" : "orange", "prices" : { "Fresh Mart" : 1.99, "Price Max" : 3.19, "Citrus Circus" : 1.09 }}
![Page 46: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/46.jpg)
fail: use it as query language for your pile of crap database
![Page 47: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/47.jpg)
{ foo: "bar" }
{ x : 3, y : "foo" }
{ $or : [ { a : 1 } , { b : 2 } ] }
{ j : { $ne: 3 }, k : { $gt: 10 } }
{ x : 3 }, { z : 1 }
{ j : { $in : [2,4,6] } }
{ "author.name" : "joe" }
![Page 48: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/48.jpg)
YAMLYet Another Markup Language
![Page 49: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/49.jpg)
YAMLYet Another Markup LanguageYAML Ain't Markup Language
![Page 50: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/50.jpg)
recursive acronyms are cool
![Page 51: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/51.jpg)
YAML also was cool at some point
![Page 52: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/52.jpg)
a simple markup language, perfect for configuration files
![Page 53: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/53.jpg)
autoload: # plugins plugins_lib: name: plugins lib path: %SF_PLUGINS_DIR%/*/lib recursive: true exclude: []
plugins_module_lib: name: plugins module lib path: %SF_PLUGINS_DIR%/*/modules/*/lib prefix: 2 recursive: true exclude: []
# project project: name: project path: %SF_LIB_DIR% recursive: true exclude: [model, symfony, deprecated]
![Page 54: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/54.jpg)
but then...
![Page 55: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/55.jpg)
foo: | -‐-‐-‐ foo: bar -‐-‐-‐ yo: bazbar: | fooness clipped: | This has one newline.
same as "clipped" above: "This has one newline.\n"
stripped: |-‐ This has no newline.
same as "stripped" above: "This has no newline."
kept: |+ This has four newlines.
same as "kept" above: "This has four newlines.\n\n\n\n"
-‐ &showell Steve-‐ Clark -‐ Brian -‐ Oren -‐ *showell
![Page 56: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/56.jpg)
YAML DRAWBACKS
•Makes your eyes bleed
•No schemas or other forms of validation
• Forget a newline somewhere and the parser might look at you, helpless, like a deer in headlights
•No mixed content
![Page 57: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/57.jpg)
CONCLUSION
• XML for hypermedia, documents, your new REST API
• JSON for serializing objects and storing them in e.g. CouchDB
• YAML for your configuration files
![Page 58: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/58.jpg)
!e End
![Page 59: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/59.jpg)
Questions?
![Page 60: XML Versus the New Kids on the Block (ZC10 2010-11-03)](https://reader034.vdocuments.us/reader034/viewer/2022051611/54b7a7914a79594b258b45b3/html5/thumbnails/60.jpg)
THANK YOU!This was
http://joind.in/2269by
@dzuelke