1<html>
2<head>
3</head>
4<body id="body">
5<p>This tests that XSLT transforms can traverse into XHTML template element content when applying XSL template.
6If the test succeeds, the transform will have swapped the position of the body spans (A and B) with the template content spans (C and D)
7and replaced the spans with divs.</p>
8<script>
9if (window.testRunner)
10 testRunner.dumpAsText();
11
12var requester = new XMLHttpRequest();
13var processor = new XSLTProcessor();
14var serializer = new XMLSerializer();
15
16function getXMLDocument(name)
17{
18 requester.open("GET", name, false);
19 requester.send(null);
20 return requester.responseXML;
21}
22
23function addStringResult(text)
24{
25 document.writeln("<span>" + text + "</span>");
26}
27
28function divChildTextNodes(parent) {
29 var output = '';
30
31 for (var child = parent.firstChild; child; child = child.nextSibling) {
32 if (child.tagName == 'div') {
33 output += child.textContent;
34 }
35 }
36
37 return output;
38}
39
40var xml = getXMLDocument("xslt-xhtml-template.xml");
41var xsl = getXMLDocument("resources/xhtml-template.xsl");
42
43processor.importStylesheet(xsl);
44
45var ownerDocument = document.implementation.createDocument("", "test", null);
46var frag = processor.transformToFragment(xml, ownerDocument);
47
48addStringResult('Body divs: ' + divChildTextNodes(frag.querySelector('body')) +
49 ', Template content divs: ' + divChildTextNodes(frag.querySelector('template').content));
50
51</script>
52</body>
53</html>