TODAY'S MENU • XML (and where it took a wrong turn) • HTML 5 (and why it makes me a little bit sad) • JSON (and why it's not as universally useful as you may think) • YAML (and why it makes my eyes bleed)
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) Use XMLReader::expand()
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)
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 <3
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...
JSON KEY FEATURES • 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
foo: | -‐-‐-‐ foo: bar -‐-‐-‐ yo: baz bar: | 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
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
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