5 <p>This tests that XSLT transforms can traverse into XHTML template element content when applying XSL template.
6 If 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)
7 and replaced the spans with divs.
</p>
10 testRunner
.dumpAsText();
12 var requester
= new XMLHttpRequest();
13 var processor
= new XSLTProcessor();
14 var serializer
= new XMLSerializer();
16 function getXMLDocument(name
)
18 requester
.open("GET", name
, false);
20 return requester
.responseXML
;
23 function addStringResult(text
)
25 document
.writeln("<span>" + text
+ "</span>");
28 function divChildTextNodes(parent
) {
31 for (var child
= parent
.firstChild
; child
; child
= child
.nextSibling
) {
32 if (child
.tagName
== 'div') {
33 output
+= child
.textContent
;
40 var xml
= getXMLDocument("xslt-xhtml-template.xml");
41 var xsl
= getXMLDocument("resources/xhtml-template.xsl");
43 processor
.importStylesheet(xsl
);
45 var ownerDocument
= document
.implementation
.createDocument("", "test", null);
46 var frag
= processor
.transformToFragment(xml
, ownerDocument
);
48 addStringResult('Body divs: ' + divChildTextNodes(frag
.querySelector('body')) +
49 ', Template content divs: ' + divChildTextNodes(frag
.querySelector('template').content
));