blob: 55a0ddcc0f8f83a0b38a8dedfd0a791e6da0d837 [file] [log] [blame]
<html>
<head>
</head>
<body id="body">
<p>This tests that XSLT transforms can traverse into XHTML template element content when applying XSL template.
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)
and replaced the spans with divs.</p>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var requester = new XMLHttpRequest();
var processor = new XSLTProcessor();
var serializer = new XMLSerializer();
function getXMLDocument(name)
{
requester.open("GET", name, false);
requester.send(null);
return requester.responseXML;
}
function addStringResult(text)
{
document.writeln("<span>" + text + "</span>");
}
function divChildTextNodes(parent) {
var output = '';
for (var child = parent.firstChild; child; child = child.nextSibling) {
if (child.tagName == 'div') {
output += child.textContent;
}
}
return output;
}
var xml = getXMLDocument("xslt-xhtml-template.xml");
var xsl = getXMLDocument("resources/xhtml-template.xsl");
processor.importStylesheet(xsl);
var ownerDocument = document.implementation.createDocument("", "test", null);
var frag = processor.transformToFragment(xml, ownerDocument);
addStringResult('Body divs: ' + divChildTextNodes(frag.querySelector('body')) +
', Template content divs: ' + divChildTextNodes(frag.querySelector('template').content));
</script>
</body>
</html>