XML and HTML
Cross-Pollination:
A Bridge Too Far?
Cross-Pollination
- Forget about your angle brackets
- Look at the ideas
XML in the browser
<?xml-stylesheet href="xmltest.css"?>
<doc>
<title>Title</title>
<para xml:id="test">Testing.</para>
</doc>
XML in the browser
- Browser reads XML, renders with CSS
- Works today, mostly:
- Styling a complete vocabulary not so hard
- Images are theoretically possible
XML in the browser: Scripting
<?xml-stylesheet href="xmltest.css"?>
<doc>
<title>Title</title>
<para xml:id="test">Testing.</para>
<script xmlns="http://www.w3.org/1999/xhtml">
//<![CDATA[
var txt = document.createTextNode("Script test");
var p = document.getElementsByTagName("para")[0];
p.replaceChild(text, p.firstChild)
//]]></script>
</doc>
XML in the browser: Scripting (continued)
- HTML scripts are interpreted
- Scripts can access the XML DOM
- The case for
xml-script
(or lack thereof)
XML in the browser: Linking
- Very vocabulary dependent (XLink not widely adopted, Norm: sigh, Robin: yay!)
- Linking can be emulated with script
- Declarative links could be useful
XML in the browser: Accessibility
- Theoretically, at least as good as HTML
- In practice, much worse
XML in the browser
- Hard to justify.
- The browser vendors aren't interested.
- Most developers aren't interested.
- Use a tool designed for it, such as Saxon-CE
XPointer and CSS
- XPointer can point inside documents
- CSS can select nodes inside documents
- Maybe the two can meet?
- http://simonstl.com/articles/cssFragID.html
XPointer and CSS: Examples
- http://example.org/foo/#css(.rfc2119)
- http://example.org/foo/#css(section>h2)
- http://example.org/foo/#css(article p:nth-child(3))
Implementing FO
- pdf.js supports PDF directly in the browser
- It has helped improve browsers in finding gaps
- What's missing to implement FO?
- It would be much nicer than using PDF...
Compilation to JS
- Saxon Client Edition
- XML Pipeline Processing in the Browser
SVG's Switch
- SVG was absorbed into HTML (including syntax-wise)
- What are the results?
- Should it go further?
Distributed Extensibility
- XML had potential for DE that was almost never used
- HTML is blamed for not having DE
- But is it true?
JS-SLT
- Javascript has proven powerful at markup transformation
- So has XSLT, with a seductive model
- Could we marry these two?
JS-SLT: Code
var sheet = require("jaspilite").sheet()
, $ = require("jquery");
sheet.template("section", function () {
return $(this)
.apply()
.wrapIn("<div class='section'/>");
});
var $out = sheet.run("my-document.html");
console.log($out.html());
Schemata on the Web
- HTML has a limited validation ecosystem
- But it could be useful at times
- We always need more schema languages
CSS Schema: Code
@rule head {
title {
assert: "Page does not have a title.";
}
}
@rule body {
:scope > div.std-top {
assert: "Missing page top component.";
}
}
Conclusions
- Characterizing the relationship between the XML and HTML communities
is largely a matter of perspective
- Far enough away: they're nearly indistinguishable
- Close enough: there's almost no common ground
Conclusions (2)
- Forget: XML on the Web
- Embrace: XML's good ideas on the Web