Bug 788290 - Rewrite some XUL template tests to use DOM rather than E4X. r=enn
authorJason Orendorff <jorendorff@mozilla.com>
Mon, 10 Dec 2012 09:02:00 -0500
changeset 115501 ed76f1a61dce41edc2b796bfe25a8d0856620d0d
parent 115500 d6dd73183bce274301d260a60f73f86078faeb8c
child 115502 100a1ea225f34f674ec74387463549d03d934feb
push id19374
push userryanvm@gmail.com
push dateMon, 10 Dec 2012 14:06:34 +0000
treeherdermozilla-inbound@21d667b49f3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn
bugs788290
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 788290 - Rewrite some XUL template tests to use DOM rather than E4X. r=enn
content/xul/templates/tests/chrome/templates_shared.js
content/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
content/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
content/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
content/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
content/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
content/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
content/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
content/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
content/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
content/xul/templates/tests/chrome/test_tmpl_gridelement.xul
content/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
content/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
content/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
content/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
content/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
content/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
content/xul/templates/tests/chrome/test_tmpl_menuelement.xul
content/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
content/xul/templates/tests/chrome/test_tmpl_noaction.xul
content/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
content/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
content/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
content/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
content/xul/templates/tests/chrome/test_tmpl_query3triples.xul
content/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
content/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
content/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
content/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
content/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
content/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
content/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
content/xul/templates/tests/chrome/test_tmpl_querysetone.xul
content/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
content/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
content/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
content/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
content/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
content/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
content/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
content/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
content/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
content/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
content/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
content/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
content/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
content/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
content/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
content/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
content/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
content/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
content/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
content/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
content/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
content/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
content/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
content/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
content/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
content/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
content/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
content/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
content/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul
content/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul
content/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul
content/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul
content/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul
content/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul
content/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul
content/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul
content/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontains.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul
content/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul
content/xul/templates/tests/chrome/test_tmpl_whereendswith.xul
content/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul
content/xul/templates/tests/chrome/test_tmpl_whereequals.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul
content/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul
content/xul/templates/tests/chrome/test_tmpl_wheregreater.xul
content/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul
content/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul
content/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul
content/xul/templates/tests/chrome/test_tmpl_whereless.xul
content/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul
content/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul
content/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul
content/xul/templates/tests/chrome/test_tmpl_wherenorel.xul
content/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul
content/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul
content/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul
content/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul
content/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul
content/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul
--- a/content/xul/templates/tests/chrome/templates_shared.js
+++ b/content/xul/templates/tests/chrome/templates_shared.js
@@ -23,22 +23,22 @@
  * children within it must all appear to match, but may appear in any order.
  * If the unordered attribute is not set, the children must appear in the same
  * order.
  *
  * If the 'changes' array is used, it should be an array of functions. Each
  * function will be called in order and a comparison of the output will be
  * performed. This allows changes to be made to the datasource to ensure that
  * the generated template output has been updated. Within the expected output
- * e4x data, the step attribute may be set to a number on an element to
- * indicate that an element only applies before or after a particular change.
- * If step is set to a positive number, that element will only exist after
- * that step in the list of changes made. If step is set to a negative number,
- * that element will only exist until that step. Steps are numbered starting
- * at 1. For example:
+ * XML, the step attribute may be set to a number on an element to indicate
+ * that an element only applies before or after a particular change. If step
+ * is set to a positive number, that element will only exist after that step in
+ * the list of changes made. If step is set to a negative number, that element
+ * will only exist until that step. Steps are numbered starting at 1. For
+ * example:
  *   <label value="Cat"/>
  *   <label step="2" value="Dog"/>
  *   <label step="-5" value="Mouse"/>
  * The first element will always exist. The second element will only appear
  * after the second change is made. The third element will only appear until
  * the fifth change and it will no longer be present at later steps.
  *
  * If the anyid attribute is set to true on an element in the expected output,
@@ -133,26 +133,27 @@ function iterateChanged(root, ds)
     root.open = false;
   if (expectedConsoleMessages.length)
     compareConsoleMessages();
   SimpleTest.finish();
 }
 
 function checkResults(root, step)
 {
-  var output = expectedOutput.copy();
+  var output = expectedOutput.cloneNode(true);
   setForCurrentStep(output, step);
 
   var error;
   var actualoutput = root;
   if (isTreeBuilder) {
     // convert the tree's view data into the equivalent DOM structure
     // for easier comparison
     actualoutput = treeViewToDOM(root);
-    error = compareOutput(actualoutput, output.treechildren, false);
+    var treechildrenElements = [e for (e of output.children) if (e.localName === "treechildren")];
+    error = compareOutput(actualoutput, treechildrenElements[0], false);
   }
   else {
     error = compareOutput(actualoutput, output, true);
   }
 
   var adjtestid = testid;
   if (step > 0)
     adjtestid += " dynamic step " + step;
@@ -173,169 +174,162 @@ function checkResults(root, step)
         serializedXML += ((new XMLSerializer()).serializeToString(node));
     }
 
     // remove the XUL namespace declarations to make the output more readable
     const nsrepl = new RegExp("xmlns=\"" + XUL_NS + "\" ", "g");
     serializedXML = serializedXML.replace(nsrepl, "");
     if (debug)
       dump("-------- " + adjtestid + "  " + error + ":\n" + serializedXML + "\n");
-    if (error)
+    if (!stilltodo && error)
       is(serializedXML, "Same", "Error is: " + error);
   }
 }
 
 /**
  * Adjust the expected output to acccount for any step attributes.
  */
 function setForCurrentStep(content, currentStep)
 {
   var todelete = [];
-  for each (var child in content) {
-    var stepstr = child.@step.toString();
-    var stepsarr = stepstr.split(",");
-    for (var s = 0; s < stepsarr.length; s++) {
-      var step = parseInt(stepsarr[s]);
-      if ((step > 0 && step > currentStep) ||
-          (step < 0 && -step <= currentStep)) {
+  for (var child of content.childNodes) {
+    if (child.nodeType === Node.ELEMENT_NODE) {
+      var stepstr = child.getAttribute("step") || "";
+      var stepsarr = stepstr.split(",");
+      for (var s = 0; s < stepsarr.length; s++) {
+        var step = parseInt(stepsarr[s]);
+        if ((step > 0 && step > currentStep) ||
+            (step < 0 && -step <= currentStep)) {
+          todelete.push(child);
+        }
+      }
+    } else if (child.nodeType === Node.TEXT_NODE) {
+      // Drop empty text nodes.
+      if (child.nodeValue.trim() === "")
         todelete.push(child);
-      }
     }
   }
 
-  // delete node using this bizarre syntax, because e4x has a non-sensical api
-  for (var d = 0; d < todelete.length; d++)
-    delete content.*[todelete[d].childIndex()];
-  
-  for each (var child in content) {
-    delete child.@step;
+  for (var e of todelete)
+    content.removeChild(e);
+
+  for (var child of content.children) {
+    child.removeAttribute("step");
     setForCurrentStep(child, currentStep);
   }
 }
 
 /**
  * Compares the 'actual' DOM output with the 'expected' output. This function
  * is called recursively, with isroot true if actual refers to the root of the
  * template. Returns a null string if they are equal and an error string if
  * they are not equal. This function is called recursively as it iterates
  * through each node in the DOM tree.
  */
 function compareOutput(actual, expected, isroot)
 {
-  // The expected output may be enclosed in an <output> element if it contains
-  // several nodes. However, the <output> element may be omitted if there is
-  // only one node.
-  if (expected.localName() != "output" && isroot) {
-    // If there is no <output> element then only one node should have been
-    // generated by the template. The number of children should be one
-    // <template> node and one generated node.
-    if (actual.childNodes.length != 2)
-      return "incorrect child node count of root " +
-             (actual.childNodes.length - 1) + " expected 1";
-    return compareOutput(actual.lastChild, expected, false);
-  }
+  if (isroot && expected.localName != "data")
+    return "expected must be a <data> element";
 
   var t;
 
   // compare text nodes
-  if (expected.nodeKind() == "text") {
-    if (actual.nodeValue != expected.toString())
-      return "Text " + actual.nodeValue + " doesn't match " + expected.toString();
+  if (expected.nodeType == Node.TEXT_NODE) {
+    if (actual.nodeValue !== expected.nodeValue.trim())
+      return "Text " + actual.nodeValue + " doesn't match " + expected.nodeValue;
     return "";
   }
 
   if (!isroot) {
     var anyid = false;
     // make sure that the tags match
-    if (actual.localName != expected.localName())
-      return "Tag name " + expected.localName() + " not found";
+    if (actual.localName != expected.localName)
+      return "Tag name " + expected.localName + " not found";
 
     // loop through the attributes in the expected node and compare their
     // values with the corresponding attribute on the actual node
 
-    var expectedAttrs = expected.attributes();
-    for (var a = 0; a < expectedAttrs.length(); a++) {
+    var expectedAttrs = expected.attributes;
+    for (var a = 0; a < expectedAttrs.length; a++) {
       var attr = expectedAttrs[a];
-      expectedAttrs.length(); // not having this causes a script error
-      var expectval = "" + attr;
+      var expectval = attr.value;
       // skip checking the id when anyid="true", however make sure to
       // ensure that the id is actually present.
-      if (attr.name() == "anyid" && expectval == "true") {
+      if (attr.name == "anyid" && expectval == "true") {
         anyid = true;
         if (!actual.hasAttribute("id"))
           return "expected id attribute";
       }
-      else if (actual.getAttribute(attr.name()) != expectval) {
-        return "attribute " + attr.name() + " is '" +
-               actual.getAttribute(attr.name()) + "' instead of  '" + expectval + "'";
+      else if (actual.getAttribute(attr.name) != expectval) {
+        return "attribute " + attr.name + " is '" +
+               actual.getAttribute(attr.name) + "' instead of '" + expectval + "'";
       }
     }
 
     // now loop through the actual attributes and make sure that there aren't
     // any extra attributes that weren't expected
     var length = actual.attributes.length;
     for (t = 0; t < length; t++) {
       var aattr = actual.attributes[t];
-      var expectval = "" + expected.@[aattr.name];
+      var expectval = expected.getAttribute(aattr.name);
       // ignore some attributes that don't matter
       if (expectval != actual.getAttribute(aattr.name) &&
           aattr.name != "staticHint" && aattr.name != "xmlns" &&
           (aattr.name != "id" || !anyid))
         return "extra attribute " + aattr.name;
     }
   }
 
   // ensure that the node has the right number of children. Subtract one for
   // the root node to account for the <template> node.
   length = actual.childNodes.length - (isroot ? 1 : 0);
-  if (length != expected.children().length())
+  if (length != expected.childNodes.length)
     return "incorrect child node count of " + actual.localName + " " + length +
-           " expected " + expected.children().length();
+           " expected " + expected.childNodes.length;
 
-  // if <output unordered="true"> is used, then the child nodes may be in any order
-  var unordered = (expected.localName() == "output" && expected.@unordered == "true");
+  // if <data unordered="true"> is used, then the child nodes may be in any order
+  var unordered = (expected.localName == "data" && expected.getAttribute("unordered") == "true");
 
   // next, loop over the children and call compareOutput recursively on each one
   var adj = 0;
   for (t = 0; t < actual.childNodes.length; t++) {
     var actualnode = actual.childNodes[t];
     // skip the <template> element, and add one to the indices when looking
     // at the later nodes to account for it
     if (isroot && actualnode.localName == "template") {
       adj++;
     }
     else {
       var output = "unexpected";
       if (unordered) {
-        var expectedChildren = expected.children();
-        for (var e = 0; e < expectedChildren.length(); e++) {
+        var expectedChildren = expected.childNodes;
+        for (var e = 0; e < expectedChildren.length; e++) {
           output = compareOutput(actualnode, expectedChildren[e], false);
           if (!output)
             break;
         }
       }
       else {
-        output = compareOutput(actualnode, expected.children()[t - adj], false);
+        output = compareOutput(actualnode, expected.childNodes[t - adj], false);
       }
 
       // an error was returned, so return early
       if (output)
         return output;
     }
   }
 
   return "";
 }
 
 /*
  * copy the datasource into an in-memory datasource so that it can be modified
  */
 function copyRDFDataSource(root, sourceds)
 {
-  var sourceds;
   var dsourcesArr = [];
   var composite = root.database;
   var dsources = composite.GetDataSources();
   while (dsources.hasMoreElements()) {
     sourceds = dsources.getNext().QueryInterface(Components.interfaces.nsIRDFDataSource);
     dsourcesArr.push(sourceds);
   }
 
--- a/content/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah "/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah Yarmouth"/>
+    <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="bindings - extended syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah "/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah Yarmouth"/>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
                       RDF.GetResource(ZOO_NS + 'rdf#lastName'),
                       RDF.GetLiteral('Sanderson'), true);
   },
--- a/content/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
@@ -9,40 +9,41 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" label="Arachnids  "/>
+    <button step="-2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah "/>
+    <button step="2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah Yarmouth"/>
+    <button step="-1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert Sanderson"/>
+    <button step="1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert "/>
+    <button id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" label="Fish  "/>
+    <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals  "/>
+    <button step="-1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert Sanderson"/>
+    <button step="1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="bindings - multiple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" label="Arachnids  "/>
-  <button step="-2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah "/>
-  <button step="2" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" label="Birds Sarah Yarmouth"/>
-  <button step="-1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert Sanderson"/>
-  <button step="1" id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans Robert "/>
-  <button id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" label="Fish  "/>
-  <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals  "/>
-  <button step="-1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert Sanderson"/>
-  <button step="1" id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" label="Reptiles Robert "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
                       RDF.GetResource(ZOO_NS + 'rdf#lastName'),
                       RDF.GetLiteral('Sanderson'), true);
   },
--- a/content/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: Yarmouth"/>
+    <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: Sanderson"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="bindings - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: Yarmouth"/>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: Sanderson"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
                       RDF.GetResource(ZOO_NS + 'rdf#lastName'),
                       RDF.GetLiteral('Sanderson'), true);
   },
--- a/content/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
+    <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="bindings - reversed";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
-  <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template id="template">
 <query>
--- a/content/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
+    <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="bindings - same as triple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="First Name: Sarah  Last Name: "/>
-  <label id="http://www.some-fictitious-zoo.com/humans/robert" value="First Name: Robert  Last Name: "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template id="template">
 <query>
--- a/content/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/wren"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emu"/>
+    <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/barnowl"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/raven"/>
+    <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/archaeopteryx"/>
+    <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emperorpenguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="container and member variable changed";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/wren"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emu"/>
-  <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/barnowl"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/raven"/>
-  <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/archaeopteryx"/>
-  <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="http://www.some-fictitious-zoo.com/birds http://www.some-fictitious-zoo.com/birds/emperorpenguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds "/>
+    <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds "/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="container variable changed";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds "/>
-  <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds "/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds "/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template container="?parent">
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
@@ -9,36 +9,37 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <checkbox step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" label="Tarantula"/>
+    <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/reptiles/anaconda" label="Anaconda"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/reptiles/chameleon" label="Chameleon"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="containment attribute";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <checkbox step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" label="Tarantula"/>
-  <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/reptiles/anaconda" label="Anaconda"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/reptiles/chameleon" label="Chameleon"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
                       RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
                       RDF.GetResource(ZOO_NS + 'arachnids/tarantula'), true);
   },
--- a/content/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="default container variable is ?uri";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template>
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
@@ -9,30 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax - empty conditions";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax - other ref variable";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
@@ -9,32 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax, remove unmatched";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert Sanderson"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template id="template">
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value=""/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax - simple variable substitution";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value=""/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
@@ -9,44 +9,45 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <vbox id="http://www.some-fictitious-zoo.com/humans/sarah">
+      <label value="The favorite animals of Sarah"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/emu" class="indent" value="Emu which belongs to the class Birds"/>
+      <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" class="indent" value="Polar Bear which belongs to the class Mammals"/>
+      <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
+    </vbox>
+    <vbox id="http://www.some-fictitious-zoo.com/humans/robert">
+      <label value="The favorite animals of Robert"/>
+      <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
+      <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" class="indent" value="Anaconda which belongs to the class Reptiles"/>
+      <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" class="indent" value="Chameleon which belongs to the class Reptiles"/>
+      <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" class="indent" value="African Elephant which belongs to the class Mammals"/>
+    </vbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax - two rules recurse";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <vbox id="http://www.some-fictitious-zoo.com/humans/sarah">
-    <label value="The favorite animals of Sarah"/>
-    <label id="http://www.some-fictitious-zoo.com/birds/emu" class="indent" value="Emu which belongs to the class Birds"/>
-    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" class="indent" value="Polar Bear which belongs to the class Mammals"/>
-    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
-  </vbox>
-  <vbox id="http://www.some-fictitious-zoo.com/humans/robert">
-    <label value="The favorite animals of Robert"/>
-    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" class="indent" value="Tarantula which belongs to the class Arachnids"/>
-    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" class="indent" value="Anaconda which belongs to the class Reptiles"/>
-    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" class="indent" value="Chameleon which belongs to the class Reptiles"/>
-    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" class="indent" value="African Elephant which belongs to the class Mammals"/>
-  </vbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template>
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
@@ -9,34 +9,37 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <groupbox>
+      <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+    </groupbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended syntax using an intervening container";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<groupbox>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-</groupbox>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula?  - TarantulaTarantula^ Test"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="extended variable substitution";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula?  - TarantulaTarantula^ Test"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_gridelement.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_gridelement.xul
@@ -9,52 +9,53 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <columns>
+      <column/>
+      <column/>
+    </columns>
+    <rows>
+      <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="The coolest animal is: Wren"/>
+      <row id="http://www.some-fictitious-zoo.com/birds/emu">
+        <label value="Emu"/>
+        <label value="Birds"/>
+      </row>
+      <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="The coolest animal is: Barn Owl"/>
+      <row id="http://www.some-fictitious-zoo.com/birds/raven">
+        <label value="Raven"/>
+        <label value="Birds"/>
+      </row>
+      <row step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+        <label value="Archaeopteryx"/>
+        <label value="Birds"/>
+      </row>
+      <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="The coolest animal is: Emperor Penguin"/>
+    </rows>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="grid element";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <columns>
-    <column/>
-    <column/>
-  </columns>
-  <rows>
-    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="The coolest animal is: Wren"/>
-    <row id="http://www.some-fictitious-zoo.com/birds/emu">
-      <label value="Emu"/>
-      <label value="Birds"/>
-    </row>
-    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="The coolest animal is: Barn Owl"/>
-    <row id="http://www.some-fictitious-zoo.com/birds/raven">
-      <label value="Raven"/>
-      <label value="Birds"/>
-    </row>
-    <row step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
-      <label value="Archaeopteryx"/>
-      <label value="Birds"/>
-    </row>
-    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="The coolest animal is: Emperor Penguin"/>
-  </rows>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
@@ -9,64 +9,65 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/lion" title="Lion">
+      <html:em step="-2">4</html:em>
+      <html:em step="2">9</html:em>
+    </html:div>
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" title="HIPPOPOTAMUS">
+      <html:em>2</html:em>
+    </html:div>
+    <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+      African Elephant
+      <html:span title="14"/>
+    </html:p>
+    <html:p step="4" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">
+      Chimpanzee
+      <html:span step="-5"/>
+      <html:span step="5" title="3"/>
+    </html:p>
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/llama" title="LLAMA">
+      <html:em>5</html:em>
+    </html:div>
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/polarbear" title="Polar Bear">
+      <html:em step="-1">20</html:em>
+      <html:em step="1">5</html:em>
+    </html:div>
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/aardvark" title="aardvark">
+      <html:em>2</html:em>
+    </html:div>
+    <html:p step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+      Nine-banded Armadillo
+      <html:span title="1"/>
+    </html:p>
+    <html:div id="http://www.some-fictitious-zoo.com/mammals/gorilla" title="Gorilla">
+      <html:em>7</html:em>
+    </html:div>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="html element - extended syntax with binding";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output xmlns:html="http://www.w3.org/1999/xhtml">
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/lion" title="Lion">
-    <html:em step="-2">4</html:em>
-    <html:em step="2">9</html:em>
-  </html:div>
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" title="HIPPOPOTAMUS">
-    <html:em>2</html:em>
-  </html:div>
-  <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
-    African Elephant
-    <html:span title="14"/>
-  </html:p>
-  <html:p step="4" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">
-    Chimpanzee
-    <html:span step="-5"/>
-    <html:span step="5" title="3"/>
-  </html:p>
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/llama" title="LLAMA">
-    <html:em>5</html:em>
-  </html:div>
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/polarbear" title="Polar Bear">
-    <html:em step="-1">20</html:em>
-    <html:em step="1">5</html:em>
-  </html:div>
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/aardvark" title="aardvark">
-    <html:em>2</html:em>
-  </html:div>
-  <html:p step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
-    Nine-banded Armadillo
-    <html:span title="1"/>
-  </html:p>
-  <html:div id="http://www.some-fictitious-zoo.com/mammals/gorilla" title="Gorilla">
-    <html:em>7</html:em>
-  </html:div>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
--- a/content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
@@ -9,46 +9,47 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+    <html:strong id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">Arachnids</html:strong>
+    <html:strong step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      Birds
+      <html:span id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:span>
+    </html:strong>
+    <html:strong step="1" id="http://www.some-fictitious-zoo.com/insects">Insects</html:strong>
+    <html:strong id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+      Mammals
+      <html:span id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
+      <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
+      <html:span step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">Koala</html:span>
+      <html:span id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
+      <html:span id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
+      <html:span id="http://www.some-fictitious-zoo.com/mammals/gorilla">Gorilla</html:span>
+    </html:strong>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="html element - query syntax recursive";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output xmlns:html="http://www.w3.org/1999/xhtml">
-  <html:strong id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">Arachnids</html:strong>
-  <html:strong step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    Birds
-    <html:span id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:span>
-  </html:strong>
-  <html:strong step="1" id="http://www.some-fictitious-zoo.com/insects">Insects</html:strong>
-  <html:strong id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
-    Mammals
-    <html:span id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
-    <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
-    <html:span step="2" id="http://www.some-fictitious-zoo.com/mammals/koala">Koala</html:span>
-    <html:span id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
-    <html:span id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
-    <html:span id="http://www.some-fictitious-zoo.com/mammals/gorilla">Gorilla</html:span>
-  </html:strong>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'insects');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Insects'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
@@ -9,52 +9,53 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+    <html:span step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
+    <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
+    <vbox>
+      <html:p step="2" id="http://www.some-fictitious-zoo.com/mammals/lion">
+        <html:span title="Lion"/>
+      </html:p>
+      <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
+        <html:span title="African Elephant"/>
+      </html:p>
+      <html:p step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+        <html:span title="Polar Bear"/>
+      </html:p>
+      <html:p id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+        <html:span title="Gorilla"/>
+      </html:p>
+    </vbox>
+    <html:span step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">Chimpanzee</html:span>
+    <html:span id="http://www.some-fictitious-zoo.com/mammals/llama">LLAMA</html:span>
+    <html:span step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
+    <html:span id="http://www.some-fictitious-zoo.com/mammals/aardvark">aardvark</html:span>
+    <html:span step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="html element - query syntax with multiple rules";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = true;
 var notWorkingYetDynamic = true;
-var expectedOutput =
-<output xmlns:html="http://www.w3.org/1999/xhtml">
-  <html:span step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion">Lion</html:span>
-  <html:span id="http://www.some-fictitious-zoo.com/mammals/hippopotamus">HIPPOPOTAMUS</html:span>
-  <vbox>
-    <html:p step="2" id="http://www.some-fictitious-zoo.com/mammals/lion">
-      <html:span title="Lion"/>
-    </html:p>
-    <html:p id="http://www.some-fictitious-zoo.com/mammals/africanelephant">
-      <html:span title="African Elephant"/>
-    </html:p>
-    <html:p step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">
-      <html:span title="Polar Bear"/>
-    </html:p>
-    <html:p id="http://www.some-fictitious-zoo.com/mammals/gorilla">
-      <html:span title="Gorilla"/>
-    </html:p>
-  </vbox>
-  <html:span step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee">Chimpanzee</html:span>
-  <html:span id="http://www.some-fictitious-zoo.com/mammals/llama">LLAMA</html:span>
-  <html:span step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear">Polar Bear</html:span>
-  <html:span id="http://www.some-fictitious-zoo.com/mammals/aardvark">aardvark</html:span>
-  <html:span step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">Nine-banded Armadillo</html:span>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
--- a/content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+    <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren" title="Wren"/>
+    <html:p id="http://www.some-fictitious-zoo.com/birds/emu" title="Emu"/>
+    <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" title="Barn Owl"/>
+    <html:p id="http://www.some-fictitious-zoo.com/birds/raven" title="Raven"/>
+    <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" title="Archaeopteryx"/>
+    <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" title="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="html element - simple syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output xmlns:html="http://www.w3.org/1999/xhtml">
-  <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren" title="Wren"/>
-  <html:p id="http://www.some-fictitious-zoo.com/birds/emu" title="Emu"/>
-  <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" title="Barn Owl"/>
-  <html:p id="http://www.some-fictitious-zoo.com/birds/raven" title="Raven"/>
-  <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" title="Archaeopteryx"/>
-  <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" title="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" xmlns:html="http://www.w3.org/1999/xhtml">
+    <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</html:p>
+    <html:p id="http://www.some-fictitious-zoo.com/birds/emu">Emu</html:p>
+    <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:p>
+    <html:p id="http://www.some-fictitious-zoo.com/birds/raven">Raven</html:p>
+    <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</html:p>
+    <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</html:p>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="html element - simple syntax using a textnode";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output xmlns:html="http://www.w3.org/1999/xhtml">
-  <html:p step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</html:p>
-  <html:p id="http://www.some-fictitious-zoo.com/birds/emu">Emu</html:p>
-  <html:p step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</html:p>
-  <html:p id="http://www.some-fictitious-zoo.com/birds/raven">Raven</html:p>
-  <html:p step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</html:p>
-  <html:p step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</html:p>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="invalid syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput = <output/>;
+var expectedOutput = document.getElementById("output");
 
 Components.classes["@mozilla.org/consoleservice;1"].
            getService(Components.interfaces.nsIConsoleService).reset();
 expectedConsoleMessages.push("Error parsing template: querytype attribute doesn't specify a valid query processor");
 
 var changes = [];
 ]]>
 </script>
--- a/content/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
@@ -9,59 +9,60 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <listcols>
+      <listcol flex="1"/>
+      <listcol flex="1"/>
+    </listcols>
+    <listitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+      <listcell label="Wren"/>
+      <listcell label=""/>
+    </listitem>
+    <listitem id="http://www.some-fictitious-zoo.com/birds/emu">
+      <listcell label="Emu"/>
+      <listcell label="Dromaius novaehollandiae"/>
+    </listitem>
+    <listitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <listcell label="Barn Owl"/>
+      <listcell label="Tyto alba"/>
+    </listitem>
+    <listitem id="http://www.some-fictitious-zoo.com/birds/raven">
+      <listcell label="Raven"/>
+      <listcell label="Corvus corax"/>
+    </listitem>
+    <listitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+      <listcell label="Archaeopteryx"/>
+      <listcell label=""/>
+    </listitem>
+    <listitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+      <listcell label="Emperor Penguin"/>
+      <listcell label=""/>
+    </listitem>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="listbox element";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <listcols>
-    <listcol flex="1"/>
-    <listcol flex="1"/>
-  </listcols>
-  <listitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
-    <listcell label="Wren"/>
-    <listcell label=""/>
-  </listitem>
-  <listitem id="http://www.some-fictitious-zoo.com/birds/emu">
-    <listcell label="Emu"/>
-    <listcell label="Dromaius novaehollandiae"/>
-  </listitem>
-  <listitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <listcell label="Barn Owl"/>
-    <listcell label="Tyto alba"/>
-  </listitem>
-  <listitem id="http://www.some-fictitious-zoo.com/birds/raven">
-    <listcell label="Raven"/>
-    <listcell label="Corvus corax"/>
-  </listitem>
-  <listitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
-    <listcell label="Archaeopteryx"/>
-    <listcell label=""/>
-  </listitem>
-  <listitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
-    <listcell label="Emperor Penguin"/>
-    <listcell label=""/>
-  </listitem>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
@@ -9,30 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="literal as member";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds/emu Emu"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds/barnowl Barn Owl"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds/raven Raven"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="member variable changed";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="http://www.some-fictitious-zoo.com/birds/emu Emu"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="http://www.some-fictitious-zoo.com/birds/barnowl Barn Owl"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="http://www.some-fictitious-zoo.com/birds/raven Raven"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template member="?child">
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="member variable substitution";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="http://www.some-fictitious-zoo.com/arachnids/tarantula"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <rule id="rule">
--- a/content/xul/templates/tests/chrome/test_tmpl_menuelement.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_menuelement.xul
@@ -9,37 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <menupopup>
+      <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+      <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+      <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+      <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+    </menupopup>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="menu element";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = true;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<menupopup>
-  <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-  <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
-  <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
-</menupopup>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
@@ -9,47 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template()"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <menupopup>
+      <menuitem id="http://www.some-fictitious-zoo.com/arachnids" label="Arachnids" container="true" empty="false"/>
+      <menu step="-2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false"/>
+      <menu step="2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false" open="true">
+        <menupopup>
+          <menuitem step="4" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+          <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+          <menuitem step="-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+          <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+          <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+          <menuitem id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+        </menupopup>
+      </menu>
+      <menuitem id="http://www.some-fictitious-zoo.com/crustaceans" label="Crustaceans" container="true" empty="true"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/fish" label="Fish" container="true" empty="false"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/mammals" label="Mammals" container="true" empty="false"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/reptiles" label="Reptiles" container="true" empty="false"/>
+    </menupopup>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="menu element recursive";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = true;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<menupopup>
-  <menuitem id="http://www.some-fictitious-zoo.com/arachnids" label="Arachnids" container="true" empty="false"/>
-  <menu step="-2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false"/>
-  <menu step="2" id="http://www.some-fictitious-zoo.com/birds" label="Birds" container="true" empty="false" open="true">
-    <menupopup>
-      <menuitem step="4" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
-      <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-      <menuitem step="-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-      <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-      <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
-      <menuitem id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
-    </menupopup>
-  </menu>
-  <menuitem id="http://www.some-fictitious-zoo.com/crustaceans" label="Crustaceans" container="true" empty="true"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/fish" label="Fish" container="true" empty="false"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/mammals" label="Mammals" container="true" empty="false"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/reptiles" label="Reptiles" container="true" empty="false"/>
-</menupopup>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     // nothing should change at this step as the submenu is not open
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
--- a/content/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
@@ -9,37 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="$('root').selectedItem = null; test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <menupopup>
+      <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+      <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+      <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+      <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+      <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+    </menupopup>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="menulist element";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<menupopup>
-  <menuitem step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-  <menuitem step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-  <menuitem id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  <menuitem step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
-  <menuitem step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
-</menupopup>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+    <button id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="mixed syntax - iscontainer";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
-  <button id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" label="Crustaceans"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
                       RDF.GetResource(ZOO_NS + 'rdf#pets'),
                       RDF.GetResource(ZOO_NS + 'sarahs-pets'), true);
   }
--- a/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+    <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="mixed syntax - iscontainer isempty";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <checkbox id="http://www.some-fictitious-zoo.com/humans/sarah" label="Sarah"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
-  <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse">
 <template id="template">
 <rule id="rule1" iscontainer="true" isempty="true">
--- a/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
+    <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="mixed syntax - isempty";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" label="Mammals"/>
-  <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/marked" flags="dont-recurse">
 <template id="template">
 <rule id="rule1" isempty="true">
--- a/content/xul/templates/tests/chrome/test_tmpl_noaction.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_noaction.xul
@@ -9,30 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="no action";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template>
 <query>
--- a/content/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
@@ -9,32 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label value="Tarantula"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="no action uri attribute";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label value="Tarantula"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
@@ -9,51 +9,52 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <box step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <label value="Birds"/>
+      <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+      <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    </box>
+    <box step="1" id="http://www.some-fictitious-zoo.com/insects">
+      <label value="Insects"/>
+    </box>
+    <box id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+      <label value="Crustaceans"/>
+    </box>
+    <box id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+      <label value="Mammals"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+      <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+    </box>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="parent - conditions";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <box step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <label value="Birds"/>
-    <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  </box>
-  <box step="1" id="http://www.some-fictitious-zoo.com/insects">
-    <label value="Insects"/>
-  </box>
-  <box id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
-    <label value="Crustaceans"/>
-  </box>
-  <box id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
-    <label value="Mammals"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-    <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-  </box>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'insects');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Insects'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
@@ -9,51 +9,52 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <groupbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <caption value="Birds"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    </groupbox>
+    <groupbox step="1" id="http://www.some-fictitious-zoo.com/insects">
+      <caption value="Insects"/>
+    </groupbox>
+    <groupbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+      <caption value="Crustaceans"/>
+    </groupbox>
+    <groupbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+      <caption value="Mammals"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+      <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+      <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+    </groupbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="parent - content tag";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <groupbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <caption value="Birds"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  </groupbox>
-  <groupbox step="1" id="http://www.some-fictitious-zoo.com/insects">
-    <caption value="Insects"/>
-  </groupbox>
-  <groupbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
-    <caption value="Crustaceans"/>
-  </groupbox>
-  <groupbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
-    <caption value="Mammals"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-    <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
-    <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-  </groupbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'insects');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Insects'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
@@ -9,55 +9,56 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <label value="Birds"/>
+      <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+      <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+      <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    </hbox>
+    <hbox step="1" id="http://www.some-fictitious-zoo.com/insects">
+      <label value="Insects"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
+      <label value="Crustaceans"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
+      <label value="Mammals"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+      <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+      <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="parent - simple syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox step="-3" id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <label value="Birds"/>
-    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-    <button id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  </hbox>
-  <hbox step="1" id="http://www.some-fictitious-zoo.com/insects">
-    <label value="Insects"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true">
-    <label value="Crustaceans"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false">
-    <label value="Mammals"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-    <button step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" label="Koala"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
-    <button id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'insects');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Insects'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_query3triples.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_query3triples.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Robert likes Anacondas"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Robert likes Chameleons"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - 3 triples";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Robert likes Anacondas"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Robert likes Chameleons"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - 3 triples - where contains";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Robert likes Tarantulas"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="Robert likes African Elephants"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Arctic Hare'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Sarah likes Emus"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Sarah likes Polar Bears"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - member, 3 triples - where equals";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Sarah likes Emus"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Sarah likes Polar Bears"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - member and two triples";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label step="-1" id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - member, triple, member, triple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/sarah'),
                       RDF.GetResource(ZOO_NS + 'rdf#pets'),
                       RDF.GetResource(ZOO_NS + 'sarahs-pets'), true);
   }
--- a/content/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Arachnids"/>
+    <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
+    <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+    <label id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" value="Fish"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - resource match";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Arachnids"/>
-  <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
-  <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
-  <label id="http://www.some-fictitious-zoo.com/fish" container="true" empty="false" value="Fish"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
+    <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - reverse triple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/reptiles" container="true" empty="false" value="Reptiles"/>
-  <label id="http://www.some-fictitious-zoo.com/crustaceans" container="true" empty="true" value="Crustaceans"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - self with triple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/mammals" container="true" empty="false" value="Mammals"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals">
 <template>
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querysetone.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysetone.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+    <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+    <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="queryset - one";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-  <button step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
-  <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+    <checkbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
+    <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="queryset - two";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button step="3" id="http://www.some-fictitious-zoo.com/birds/wren" label="Wren"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-  <checkbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Barn Owl"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  <button step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" label="Archaeopteryx"/>
-  <button step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" label="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
@@ -9,50 +9,51 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox step="-6" id="http://www.some-fictitious-zoo.com/birds/emu">
+      <label value="Emu"/>
+      <label value="Dromaius novaehollandiae"/>
+    </hbox>
+    <button step="6" id="http://www.some-fictitious-zoo.com/birds/emu" label="No Emus Currently"/>
+    <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+      <label value="Archaeopteryx"/>
+      <label value="Archaeopteryx lithographica"/>
+    </hbox>
+    <hbox step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+      <label value="Tyto alba"/>
+    </hbox>
+    <button step="-5" id="http://www.some-fictitious-zoo.com/birds/raven" label="No Ravens Currently"/>
+    <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/raven">
+      <label step="-7" value="Raven"/>
+      <label step="7" value="Crow"/>
+      <label value="Corvus corax"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="queryset - two with condition";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox step="-6" id="http://www.some-fictitious-zoo.com/birds/emu">
-    <label value="Emu"/>
-    <label value="Dromaius novaehollandiae"/>
-  </hbox>
-  <button step="6" id="http://www.some-fictitious-zoo.com/birds/emu" label="No Emus Currently"/>
-  <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
-    <label value="Archaeopteryx"/>
-    <label value="Archaeopteryx lithographica"/>
-  </hbox>
-  <hbox step="-2" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-    <label value="Tyto alba"/>
-  </hbox>
-  <button step="-5" id="http://www.some-fictitious-zoo.com/birds/raven" label="No Ravens Currently"/>
-  <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/raven">
-    <label step="-7" value="Raven"/>
-    <label step="7" value="Crow"/>
-    <label value="Corvus corax"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/archaeopteryx');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Archaeopteryx'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
@@ -9,42 +9,43 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query syntax - multiple rules";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-2" id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
--- a/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query syntax - multiple rules first condition all";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" label="Nine-banded Armadillo"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals">
 <template id="template">
 <query>
--- a/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
+    <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
+    <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query syntax - multiple rules two conditions";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <checkbox step="2" id="http://www.some-fictitious-zoo.com/mammals/lion" label="Lion"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/chimpanzee" value="Chimpanzee"/>
-  <checkbox step="-1" id="http://www.some-fictitious-zoo.com/mammals/polarbear" label="Polar Bear"/>
-  <label step="-3" id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <checkbox id="http://www.some-fictitious-zoo.com/mammals/gorilla" label="Gorilla"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'mammals/polarbear');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimens');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'mammals/polarbear'),
--- a/content/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - triple and member merge";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
+    <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - triple object to subject";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = true;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/humans/robert" value="Robert"/>
-  <label id="http://www.some-fictitious-zoo.com/humans/sarah" value="Sarah"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     targetds.Unassert(RDF.GetResource(ZOO_NS + 'humans/robert'),
                       RDF.GetResource(ZOO_NS + 'rdf#favoriteAnimal'),
                       RDF.GetResource(ZOO_NS + 'arachnids/tarantula'), true);
   },
--- a/content/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
@@ -9,50 +9,51 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+    <label id="http://www.some-fictitious-zoo.com/fish/cod" value="Cod"/>
+    <label id="http://www.some-fictitious-zoo.com/fish/swordfish" value="Swordfish"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - two members";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-  <label id="http://www.some-fictitious-zoo.com/fish/cod" value="Cod"/>
-  <label id="http://www.some-fictitious-zoo.com/fish/swordfish" value="Swordfish"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
@@ -9,32 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="Mammals"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - two members filtered";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="Mammals"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/all-animals">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - two triples";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
@@ -9,34 +9,35 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/marked" container="true" empty="false" value="Marked"/>
+    <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
+    <label id="http://www.some-fictitious-zoo.com/sarahs-pets" container="true" empty="false" value="Sarah's Pets"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - upwards member";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/marked" container="true" empty="false" value="Marked"/>
-  <label id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false" value="Birds"/>
-  <label id="http://www.some-fictitious-zoo.com/sarahs-pets" container="true" empty="false" value="Sarah's Pets"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds/emu" flags="dont-recurse">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output" unordered="true">
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query - upwards member, triple and filtering triple";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output unordered="true">
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans/robert">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
@@ -9,43 +9,44 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="query with empty conditions";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Arctic Hare'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Tarantula"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Hairy Spider"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="reference as member";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Tarantula"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false" value="Hairy Spider"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="self generation - extended syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Hairy Spider"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
@@ -9,30 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="self generation - simple syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox>
+      <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+      <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+      <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+      <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax enclosed in a container";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox>
-    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-    <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-    <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
@@ -9,41 +9,42 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+      <label value="Emu"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+      <label value="Raven"/>
+    </hbox>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax enclosed in a container with a rule";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
-    <label value="Emu"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
-    <label value="Raven"/>
-  </hbox>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template id="template">
 <rule>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax - filter";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template zoo:name="Barn Owl" xmlns:zoo="http://www.some-fictitious-zoo.com/rdf#">
 <label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
@@ -9,38 +9,39 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
+    <label step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <button step="4,-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <button step="1,-3" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
+    <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl" value="Barn Owl"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax - filter with multiple rules";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button id="http://www.some-fictitious-zoo.com/birds/emu" label="Emu"/>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <button step="4,-5" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <button step="1,-3" id="http://www.some-fictitious-zoo.com/birds/barnowl" label="Spooky Bird"/>
-  <button id="http://www.some-fictitious-zoo.com/birds/raven" label="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl" value="Barn Owl"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
@@ -9,40 +9,41 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+    </hbox>
+    <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+    </hbox>
+    <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl">
+      <label value="Barn Owl"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax - filter with rule";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox step="-1" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-  </hbox>
-  <hbox step="5" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-  </hbox>
-  <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/syntheticbarnowl">
-    <label value="Barn Owl"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'birds/barnowl');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'birds/barnowl'),
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax iterating over a single value";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
@@ -9,37 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <groupbox>
+      <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+      <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
+      <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
+      <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
+      <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
+    </groupbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using an intervening container";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<groupbox>
-  <label step="3" id="http://www.some-fictitious-zoo.com/birds/wren" value="Wren"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl" value="Barn Owl"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/raven" value="Raven"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx" value="Archaeopteryx"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin" value="Emperor Penguin"/>
-</groupbox>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <description step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</description>
+    <description id="http://www.some-fictitious-zoo.com/birds/emu">Emu</description>
+    <description step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</description>
+    <description id="http://www.some-fictitious-zoo.com/birds/raven">Raven</description>
+    <description step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</description>
+    <description step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</description>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using a textnode";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <description step="3" id="http://www.some-fictitious-zoo.com/birds/wren">Wren</description>
-  <description id="http://www.some-fictitious-zoo.com/birds/emu">Emu</description>
-  <description step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">Barn Owl</description>
-  <description id="http://www.some-fictitious-zoo.com/birds/raven">Raven</description>
-  <description step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">Archaeopteryx</description>
-  <description step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">Emperor Penguin</description>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template id="template">
 <description uri="rdf:*"><textnode value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/></description>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+      <label value="Wren"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+      <label value="Emu"/>
+    </hbox>
+    <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+      <label value="Raven"/>
+    </hbox>
+    <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+      <label value="Archaeopteryx"/>
+    </hbox>
+    <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+      <label value="Emperor Penguin"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using container as the generation element";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
-    <label value="Wren"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
-    <label value="Emu"/>
-  </hbox>
-  <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
-    <label value="Raven"/>
-  </hbox>
-  <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
-    <label value="Archaeopteryx"/>
-  </hbox>
-  <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
-    <label value="Emperor Penguin"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+      <label value="Arachnids"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <label value="Birds"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using dont-recurse";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
-    <label value="Arachnids"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <label value="Birds"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/some-animals" flags="dont-recurse">
 <template id="template">
 <hbox uri="rdf:*">
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
@@ -9,58 +9,59 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+      <label value="Arachnids"/>
+      <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+        <label value="Tarantula"/>
+      </hbox>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <label value="Birds"/>
+      <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
+        <label value="Wren"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+        <label value="Emu"/>
+      </hbox>
+      <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
+        <label value="Barn Owl"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+        <label value="Raven"/>
+      </hbox>
+      <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
+        <label value="Archaeopteryx"/>
+      </hbox>
+      <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
+        <label value="Emperor Penguin"/>
+      </hbox>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using recursive generation";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
-    <label value="Arachnids"/>
-    <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
-      <label value="Tarantula"/>
-    </hbox>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <label value="Birds"/>
-    <hbox step="3" id="http://www.some-fictitious-zoo.com/birds/wren">
-      <label value="Wren"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
-      <label value="Emu"/>
-    </hbox>
-    <hbox step="-4" id="http://www.some-fictitious-zoo.com/birds/barnowl">
-      <label value="Barn Owl"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
-      <label value="Raven"/>
-    </hbox>
-    <hbox step="2" id="http://www.some-fictitious-zoo.com/birds/archaeopteryx">
-      <label value="Archaeopteryx"/>
-    </hbox>
-    <hbox step="1" id="http://www.some-fictitious-zoo.com/birds/emperorpenguin">
-      <label value="Emperor Penguin"/>
-    </hbox>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'birds/emperorpenguin');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Emperor Penguin'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
+      <label value="Arachnids"/>
+      <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
+        <label value="Tarantula"/>
+      </hbox>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
+      <label value="Birds"/>
+      <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+        <label value="Emu"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+        <label value="Barn Owl"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+        <label value="Raven"/>
+      </hbox>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax using recursive generation again";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/arachnids" container="true" empty="false">
-    <label value="Arachnids"/>
-    <hbox id="http://www.some-fictitious-zoo.com/arachnids/tarantula">
-      <label value="Tarantula"/>
-    </hbox>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds" container="true" empty="false">
-    <label value="Birds"/>
-    <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
-      <label value="Emu"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
-      <label value="Barn Owl"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
-      <label value="Raven"/>
-    </hbox>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/some-animals">
 <template id="template">
 <hbox uri="rdf:*">
--- a/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
@@ -9,43 +9,44 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
+      <label value="Emu"/>
+      <label value="12"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
+      <label value="Barn Owl"/>
+      <label value="4"/>
+    </hbox>
+    <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
+      <label value="Raven"/>
+      <label value="0"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple syntax with two variables used";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/emu">
-    <label value="Emu"/>
-    <label value="12"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/barnowl">
-    <label value="Barn Owl"/>
-    <label value="4"/>
-  </hbox>
-  <hbox id="http://www.some-fictitious-zoo.com/birds/raven">
-    <label value="Raven"/>
-    <label value="0"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/birds">
 <template id="template">
 <hbox uri="rdf:*">
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="^^Before Tarantula^"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - carets at beginning and end";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="^^Before Tarantula^"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="^^Before rdf:http://www.some-fictitious-zoo.com/rdf#name^^"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula^ and^^ lots ^ more"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - caret substitution";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula^ and^^ lots ^ more"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name^^ and^^ lots ^ more"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - no variable";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="Name"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is "/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - question mark as part of variable";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is "/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="Name is rdf:http://www.some-fictitious-zoo.com/rdf#name?"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Tarantula  ?"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Hairy Spider  ?"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - question mark substitution";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Tarantula  ?"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Are you a Hairy Spider  ?"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
@@ -9,33 +9,34 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Tarantula the Spider"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Hairy Spider the Spider"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - text and variable";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Tarantula the Spider"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Name is Hairy Spider the Spider"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'arachnids/tarantula');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#name');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(RDF.GetResource(ZOO_NS + 'arachnids/tarantula'),
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="The Tarantula's Nest"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - variable and text concatenated";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="The Tarantula's Nest"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="The rdf:http://www.some-fictitious-zoo.com/rdf#name^'s Nest"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
@@ -9,30 +9,33 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula3"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="simple variable substitution - variables concatenated";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula3"/>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/arachnids">
 <template id="template">
 <label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name^rdf:http://www.some-fictitious-zoo.com/rdf#specimens"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
@@ -9,40 +9,41 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label step="-1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort ascending - integers";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label step="-1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var subject = RDF.GetResource(ZOO_NS + 'mammals/llama');
     var predicate = RDF.GetResource(ZOO_NS + 'rdf#specimensAsString');
     var oldval = targetds.GetTarget(subject, predicate, true);
     targetds.Change(subject, predicate, oldval, RDF.GetLiteral('12'), true);
--- a/content/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
@@ -9,43 +9,44 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Arctic Hare'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort ascending two rules - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
@@ -9,47 +9,48 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+      <label value="Nine-banded Armadillo"/>
+    </hbox>
+    <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+    <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
+      <label value="Lion"/>
+    </hbox>
+    <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+    <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+      <label value="Gorilla"/>
+    </hbox>
+    <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+    <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+      <label value="Polar Bear"/>
+    </hbox>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort ascending two rules with container - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
-    <label value="Nine-banded Armadillo"/>
-  </hbox>
-  <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
-  <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
-    <label value="Lion"/>
-  </hbox>
-  <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
-  <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
-    <label value="Gorilla"/>
-  </hbox>
-  <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-  <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
-    <label value="Polar Bear"/>
-  </hbox>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <vbox>
+      <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
+        <label value="Nine-banded Armadillo"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
+        <label value="Lion"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
+        <label value="Gorilla"/>
+      </hbox>
+      <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
+        <label value="Polar Bear"/>
+      </hbox>
+    </vbox>
+    <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
+    <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort ascending two rules with different container - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <vbox>
-    <hbox id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo">
-      <label value="Nine-banded Armadillo"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/mammals/lion">
-      <label value="Lion"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/mammals/gorilla">
-      <label value="Gorilla"/>
-    </hbox>
-    <hbox id="http://www.some-fictitious-zoo.com/mammals/polarbear">
-      <label value="Polar Bear"/>
-    </hbox>
-  </vbox>
-  <button id="http://www.some-fictitious-zoo.com/mammals/aardvark" label="aardvark"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" label="HIPPOPOTAMUS"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/llama" label="LLAMA"/>
-  <button id="http://www.some-fictitious-zoo.com/mammals/africanelephant" label="African Elephant"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="ascending" sort="?specimens ?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
@@ -9,43 +9,44 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Arctic Hare'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
+    <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
+    <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort query - member and two triples";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/anaconda" value="Anaconda"/>
-  <label id="http://www.some-fictitious-zoo.com/reptiles/chameleon" value="Chameleon"/>
-  <label id="http://www.some-fictitious-zoo.com/birds/emu" value="Emu"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/arachnids/tarantula" value="Tarantula"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/humans" sortDirection="ascending" sort="?name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource2 descending - simple syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="descending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource2 set to predicate ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="ascending" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource2 set to predicate descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="descending" sortResource2="http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="?name" sortDirection="ascending">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="?name" sortDirection="descending">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource set to predicate ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="ascending">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sortResource set to predicate descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortResource="http://www.some-fictitious-zoo.com/rdf#specimens" sortDirection="descending">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort two resources as string set to predicate descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="descending" sort="http://www.some-fictitious-zoo.com/rdf#specimensAsString http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort two resources set to predicate ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="ascending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
@@ -9,43 +9,44 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
+    <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
+    <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort two variables ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = true;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label step="5" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label step="-4" id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label step="1" id="http://www.some-fictitious-zoo.com/mammals/arctichare" value="Arctic Hare"/>
-  <label step="2" id="http://www.some-fictitious-zoo.com/mammals/koala" value="Koala"/>
-  <label step="3" id="http://www.some-fictitious-zoo.com/mammals/zebra" value="Zebra"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [
   // step 1
   function(targetds, root) {
     var newnode = RDF.GetResource(ZOO_NS + 'mammals/arctichare');
     targetds.Assert(newnode, RDF.GetResource(ZOO_NS + 'rdf#name'),
                     RDF.GetLiteral('Arctic Hare'), true);
     var container = ContainerUtils.MakeSeq(targetds,
--- a/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort two variables ascending - simple syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="ascending" sort="http://www.some-fictitious-zoo.com/rdf#specimens http://www.some-fictitious-zoo.com/rdf#name">
 <template id="template">
 <label uri="rdf:*" value="rdf:http://www.some-fictitious-zoo.com/rdf#name"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort two variables descending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sortDirection="descending" sort="?specimens ?name">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
@@ -9,39 +9,40 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
+    <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="sort unknown ascending - query syntax";
 var queryType = "rdf";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <label id="http://www.some-fictitious-zoo.com/mammals/lion" value="Lion"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/hippopotamus" value="HIPPOPOTAMUS"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/africanelephant" value="African Elephant"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/llama" value="LLAMA"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/polarbear" value="Polar Bear"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/aardvark" value="aardvark"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/ninebandedarmadillo" value="Nine-banded Armadillo"/>
-  <label id="http://www.some-fictitious-zoo.com/mammals/gorilla" value="Gorilla"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" datasources="rdf:null" ref="http://www.some-fictitious-zoo.com/mammals" sort="?other">
 <template id="template">
 <query id="query">
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage listbox with bad query parameters";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput = <output></output>;
+var expectedOutput = document.getElementById("output");
 
 
 Components.classes["@mozilla.org/consoleservice;1"]
           .getService(Components.interfaces.nsIConsoleService)
           .reset();
 
 copyToProfile('animals.sqlite');
 expectedConsoleMessages.push("Error parsing template: the given named parameter is unknown in the SQL query");
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage listbox with bad query parameters";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput = <output></output>;
+var expectedOutput = document.getElementById("output");
 
 
 Components.classes["@mozilla.org/consoleservice;1"]
           .getService(Components.interfaces.nsIConsoleService)
           .reset();
 
 copyToProfile('animals.sqlite');
 
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage listbox with bad query parameters";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput = <output></output>;
+var expectedOutput = document.getElementById("output");
 
 
 Components.classes["@mozilla.org/consoleservice;1"]
           .getService(Components.interfaces.nsIConsoleService)
           .reset();
 
 copyToProfile('animals.sqlite');
 
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage bad datasource";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =<output></output>;
+var expectedOutput = document.getElementById("output");
 
 Components.classes["@mozilla.org/consoleservice;1"]
           .getService(Components.interfaces.nsIConsoleService)
           .reset();
 
 expectedConsoleMessages.push("Error parsing template: only profile: or file URI are allowed");
 
 
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
@@ -9,29 +9,31 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage bad query";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =<output></output>;
+var expectedOutput = document.getElementById("output");
 
 Components.classes["@mozilla.org/consoleservice;1"]
           .getService(Components.interfaces.nsIConsoleService)
           .reset();
 
 copyToProfile('animals.sqlite');
 
 expectedConsoleMessages.push("Error parsing template: syntax error in the SQL query");
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
@@ -9,62 +9,63 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_storage_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output"/>
+
+  <data id="rebuilt-output">
+    <listitem anyid="true" label="Barn Owl"/>
+    <listitem anyid="true" label="Emu"/>
+    <listitem anyid="true" label="Raven"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 function test_storage_template()
 {
   var root = document.getElementById("root");
-  expectedOutput = <output></output>;
+  expectedOutput = document.getElementById("output");
   checkResults(root, 0);
 
   document.getElementById("species-id").textContent = '2';
   root.builder.addListener(myBuilderListener);
   root.builder.rebuild();
 }
 
 var myBuilderListener = {
 
    willRebuild: function(aBuilder) {
 
    },
    didRebuild: function (aBuilder) {
         var root = document.getElementById("root");
-        expectedOutput = <output>
-            <listitem anyid="true" label="Barn Owl"/>
-            <listitem anyid="true" label="Emu"/>
-            <listitem anyid="true" label="Raven"/>
-        </output>;
+        expectedOutput = document.getElementById("rebuilt-output");
         checkResults(root, 0);
         SimpleTest.finish();
    }
 }
 
 var testid ="storage listbox with dynamic query parameters";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <listbox  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
               flex="1"  datasources="profile:animals.sqlite" ref="." querytype="storage">
     <template>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
@@ -9,36 +9,37 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <listitem anyid="true" label="Barn Owl"/>
+      <listitem anyid="true" label="Emu"/>
+      <listitem anyid="true" label="Raven"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage simple listbox";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <listitem anyid="true" label="Barn Owl"/>
-    <listitem anyid="true" label="Emu"/>
-    <listitem anyid="true" label="Raven"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <listbox  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
               flex="1" rows="8"
               datasources="profile:animals.sqlite" ref="." querytype="storage">
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
@@ -9,44 +9,45 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <listitem anyid="true" label="Mammal: African Elephant"/>
+      <listitem anyid="true" label="Mammal: Gorilla" style="font-weight:bold"/>
+      <listitem anyid="true" label="Mammal: HIPPOPOTAMUS"/>
+      <listitem anyid="true" label="Mammal: LAMA"/>
+      <listitem anyid="true" label="Mammal: Lion"/>
+      <listitem anyid="true" label="Mammal: Nine-banded Armadillo" style="font-weight:bold"/>
+      <listitem anyid="true" label="Mammal: Polar Bear"/>
+      <listitem anyid="true" label="Mammal: aardvark"/>
+      <listitem anyid="true" label="Bird: Barn Owl" style="font-style:italic"/>
+      <listitem anyid="true" label="Bird: Emu"/>
+      <listitem anyid="true" label="Bird: Raven"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage listbox with multiqueries";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <listitem anyid="true" label="Mammal: African Elephant"/>
-    <listitem anyid="true" label="Mammal: Gorilla" style="font-weight:bold"/>
-    <listitem anyid="true" label="Mammal: HIPPOPOTAMUS"/>
-    <listitem anyid="true" label="Mammal: LAMA"/>
-    <listitem anyid="true" label="Mammal: Lion"/>
-    <listitem anyid="true" label="Mammal: Nine-banded Armadillo" style="font-weight:bold"/>
-    <listitem anyid="true" label="Mammal: Polar Bear"/>
-    <listitem anyid="true" label="Mammal: aardvark"/>
-    <listitem anyid="true" label="Bird: Barn Owl" style="font-style:italic"/>
-    <listitem anyid="true" label="Bird: Emu"/>
-    <listitem anyid="true" label="Bird: Raven"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <listbox  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
               flex="1"  datasources="profile:animals.sqlite" ref="." querytype="storage">
     <template>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
@@ -9,46 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_storage_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output-birds">
+    <listitem anyid="true" label="Barn Owl"/>
+    <listitem anyid="true" label="Emu"/>
+    <listitem anyid="true" label="Raven"/>
+  </data>
+
+  <data id="output-L">
+    <listitem anyid="true" label="LAMA"/>
+    <listitem anyid="true" label="Lion"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 
 copyToProfile('animals.sqlite');
 SimpleTest.waitForExplicitFinish();
 
 
 function test_storage_template()
 {
   var root = document.getElementById("root1");
-  expectedOutput = <output>
-    <listitem anyid="true" label="Barn Owl"/>
-    <listitem anyid="true" label="Emu"/>
-    <listitem anyid="true" label="Raven"/>
-</output>;
+  expectedOutput = document.getElementById("output-birds");
   checkResults(root, 0);
 
 root = document.getElementById("root2");
 checkResults(root, 0);
 
 root = document.getElementById("root6");
 checkResults(root, 0);
 
 root = document.getElementById("root3");
-expectedOutput = <output>
-    <listitem anyid="true" label="LAMA"/>
-    <listitem anyid="true" label="Lion"/>
-</output>;
+expectedOutput = document.getElementById("output-L");
 checkResults(root, 0);
 
 root = document.getElementById("root4");
 checkResults(root, 0);
 
 root = document.getElementById("root5");
 checkResults(root, 0);
 
@@ -57,27 +61,17 @@ SimpleTest.finish();
 
 
 var testid ="storage listbox with query parameters";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <listitem anyid="true" label="African Elephant"/>
-    <listitem anyid="true" label="Gorilla"/>
-    <listitem anyid="true" label="HIPPOPOTAMUS"/>
-    <listitem anyid="true" label="LAMA"/>
-    <listitem anyid="true" label="Lion"/>
-    <listitem anyid="true" label="Nine-banded Armadillo"/>
-    <listitem anyid="true" label="Polar Bear"/>
-    <listitem anyid="true" label="aardvark"/>
-</output>;
+var expectedOutput;
 
 var changes = [];
 ]]>
 </script>
 
 <listbox  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root1" 
               flex="1"  datasources="profile:animals.sqlite" ref="." querytype="storage">
     <template>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
@@ -9,37 +9,38 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <listitem anyid="true" label="Gorilla"/>
+      <listitem anyid="true" label="Nine-banded Armadillo"/>
+      <listitem anyid="true" label="Polar Bear"/>
+      <listitem anyid="true" label="aardvark"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 copyToProfile('animals.sqlite');
 
 var testid ="storage listbox with rule";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <listitem anyid="true" label="Gorilla"/>
-    <listitem anyid="true" label="Nine-banded Armadillo"/>
-    <listitem anyid="true" label="Polar Bear"/>
-    <listitem anyid="true" label="aardvark"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <listbox  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
               flex="1" rows="8"
               datasources="profile:animals.sqlite" ref="." querytype="storage">
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
@@ -9,35 +9,36 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <button anyid="true" label="Barn Owl / Tyto alba"/>
+    <button anyid="true" label="Emu / Dromaius novaehollandiae"/>
+    <button anyid="true" label="Raven / Corvus corax"/>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 copyToProfile('animals.sqlite');
 SimpleTest.waitForExplicitFinish();
 
 var testid ="storage simple";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <button anyid="true" label="Barn Owl / Tyto alba"/>
-  <button anyid="true" label="Emu / Dromaius novaehollandiae"/>
-  <button anyid="true" label="Raven / Corvus corax"/>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
       datasources="profile:animals.sqlite" querytype="storage" ref=".">
 <template>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+    <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
+    <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
+    <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
+    <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
+    <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
+    <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
+    <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
+    <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
+    <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
+    <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
+    <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
+    <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
+    <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
+    <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
+    <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
+    <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage sort integer asc";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-  <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
-  <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
-  <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
-  <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
-  <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
-  <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
-  <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
-  <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
-  <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
-  <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
-  <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
-  <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
-  <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
-  <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
-  <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
-  <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
     <columns>
         <column flex="1"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
+      <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
+      <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
+      <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
+      <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
+      <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
+      <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
+      <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
+      <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
+      <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
+      <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
+      <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
+      <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
+      <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
+      <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
+      <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage sort integer desc";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
-    <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
-    <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
-    <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
-    <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
-    <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
-    <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
-    <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
-    <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
-    <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
-    <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
-    <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
-    <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
-    <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
-    <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
-    <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
     <columns>
         <column flex="1"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
+      <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
+      <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
+      <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
+      <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
+      <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
+    <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
+    <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
+    <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
+    <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
+    <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
+    <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
+    <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
+    <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
+    <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
+    <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage sort string asc";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
-    <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
-    <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
-    <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
-    <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
-    <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
-  <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
-  <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
-  <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
-  <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
-  <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
-  <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
-  <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
-  <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
-  <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
-  <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
     <columns>
         <column flex="1"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
@@ -9,49 +9,50 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
+      <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
+      <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
+      <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
+      <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
+      <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
+      <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
+      <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
+      <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
+      <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
+      <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
+      <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
+      <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
+      <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
+      <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
+      <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage sort string desc";
 var queryType = "storage";
 var isTreeBuilder = false;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <row anyid="true">  <label value="1"/>  <label value="Tarantula"/> </row>
-    <row anyid="true">  <label value="6"/>  <label value="Swordfish"/>  </row>
-    <row anyid="true">  <label value="4"/>  <label value="Raven"/>  </row>
-    <row anyid="true">  <label value="11"/>  <label value="Polar Bear"/>  </row>
-    <row anyid="true">  <label value="13"/>  <label value="Nine-banded Armadillo"/>  </row>
-    <row anyid="true">  <label value="7"/>  <label value="Lion"/>  </row>
-    <row anyid="true">  <label value="10"/>  <label value="LAMA"/>  </row>
-    <row anyid="true">  <label value="8"/>  <label value="HIPPOPOTAMUS"/>  </row>
-    <row anyid="true">  <label value="14"/>  <label value="Gorilla"/>  </row>
-    <row anyid="true">  <label value="2"/>  <label value="Emu"/> </row>
-    <row anyid="true">  <label value="5"/>  <label value="Cod"/>  </row>
-    <row anyid="true">  <label value="16"/>  <label value="Chameleon"/>  </row>
-    <row anyid="true">  <label value="3"/>  <label value="Barn Owl"/>  </row>
-    <row anyid="true">  <label value="15"/>  <label value="Anaconda"/>  </row>
-    <row anyid="true">  <label value="9"/>  <label value="African Elephant"/>  </row>
-    <row anyid="true">  <label value="12"/>  <label value="aardvark"/>  </row>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
     <columns>
         <column flex="1"/>
--- a/content/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
@@ -9,89 +9,90 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">
+      <treecols orient="horizontal">
+          <treecol id="species" primary="true" label="Species" flex="2" ordinal="1"/>
+          <treecol id="name" label="Common name" flex="2" ordinal="3"/>
+          <treecol id="specimen" label="Specimen" flex="3" ordinal="5"/>
+          <treecol id="id" label="id" flex="1" ordinal="7"/>
+      </treecols>
+    <treechildren>
+        <treeitem anyid="true"> <treerow>
+                <treecell label="arachnids" /> <treecell label="Tarantula"/>  <treecell label="Avicularia avicularia" /> <treecell label="1"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="birds" /> <treecell label="Barn Owl"/> <treecell label="Tyto alba" /> <treecell label="3"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="birds" /> <treecell label="Emu"/> <treecell label="Dromaius novaehollandiae" /> <treecell label="2"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="birds" /> <treecell label="Raven"/>  <treecell label="Corvus corax" /> <treecell label="4"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="fish" /> <treecell label="Cod"/> <treecell label="Gadus morhua" /> <treecell label="5"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+                <treecell label="fish" /> <treecell label="Swordfish"/>   <treecell label="Xiphias gladius" /> <treecell label="6"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="African Elephant"/> <treecell label="Loxodonta africana" /> <treecell label="9"/>
+        </treerow> </treeitem>
+       <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="Gorilla"/>  <treecell label="Gorilla gorilla" /> <treecell label="14"/>
+        </treerow> </treeitem>
+       <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="HIPPOPOTAMUS"/> <treecell label="Hippopotamus amphibius" /> <treecell label="8"/>
+       </treerow> </treeitem>
+       <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="LAMA"/>  <treecell label="Lama glama" /> <treecell label="10"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+                <treecell label="mammals" /> <treecell label="Lion"/>  <treecell label="Panthera leo" /> <treecell label="7"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="Nine-banded Armadillo"/>  <treecell label="Dasypus novemcinctus" /> <treecell label="13"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="Polar Bear"/>  <treecell label="Thalarctos maritimus" /> <treecell label="11"/>
+        </treerow> </treeitem>
+       <treeitem anyid="true"> <treerow>
+            <treecell label="mammals" /> <treecell label="aardvark"/> <treecell label="Orycteropus afer" /> <treecell label="12"/>
+        </treerow> </treeitem>
+        <treeitem anyid="true"> <treerow>
+                <treecell label="reptiles" /> <treecell label="Anaconda"/> <treecell label="Eunectes murinus" /> <treecell label="15"/>
+        </treerow> </treeitem>
+       <treeitem anyid="true"> <treerow>
+            <treecell label="reptiles" /> <treecell label="Chameleon"/> <treecell label="Chamaeleo chamaelon" /> <treecell label="16"/>
+        </treerow> </treeitem>
+    </treechildren>
+  </data>
+
 <script src="templates_shared.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 copyToProfile('animals.sqlite');
 
 var testid ="storage tree";
 var queryType = "storage";
 var isTreeBuilder = true;
 var needsOpen = false;
 var notWorkingYet = false;
 var notWorkingYetDynamic = false;
-var expectedOutput =
-<output>
-    <treecols orient="horizontal">
-        <treecol id="species" primary="true" label="Species" flex="2" ordinal="1"/>
-        <treecol id="name" label="Common name" flex="2" ordinal="3"/>
-        <treecol id="specimen" label="Specimen" flex="3" ordinal="5"/>
-        <treecol id="id" label="id" flex="1" ordinal="7"/>
-    </treecols>
-  <treechildren>
-      <treeitem anyid="true"> <treerow>
-              <treecell label="arachnids" /> <treecell label="Tarantula"/>  <treecell label="Avicularia avicularia" /> <treecell label="1"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="birds" /> <treecell label="Barn Owl"/> <treecell label="Tyto alba" /> <treecell label="3"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="birds" /> <treecell label="Emu"/> <treecell label="Dromaius novaehollandiae" /> <treecell label="2"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="birds" /> <treecell label="Raven"/>  <treecell label="Corvus corax" /> <treecell label="4"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="fish" /> <treecell label="Cod"/> <treecell label="Gadus morhua" /> <treecell label="5"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-              <treecell label="fish" /> <treecell label="Swordfish"/>   <treecell label="Xiphias gladius" /> <treecell label="6"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="African Elephant"/> <treecell label="Loxodonta africana" /> <treecell label="9"/>
-      </treerow> </treeitem>
-     <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="Gorilla"/>  <treecell label="Gorilla gorilla" /> <treecell label="14"/>
-      </treerow> </treeitem>
-     <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="HIPPOPOTAMUS"/> <treecell label="Hippopotamus amphibius" /> <treecell label="8"/>
-     </treerow> </treeitem>
-     <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="LAMA"/>  <treecell label="Lama glama" /> <treecell label="10"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-              <treecell label="mammals" /> <treecell label="Lion"/>  <treecell label="Panthera leo" /> <treecell label="7"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="Nine-banded Armadillo"/>  <treecell label="Dasypus novemcinctus" /> <treecell label="13"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="Polar Bear"/>  <treecell label="Thalarctos maritimus" /> <treecell label="11"/>
-      </treerow> </treeitem>
-     <treeitem anyid="true"> <treerow>
-          <treecell label="mammals" /> <treecell label="aardvark"/> <treecell label="Orycteropus afer" /> <treecell label="12"/>
-      </treerow> </treeitem>
-      <treeitem anyid="true"> <treerow>
-              <treecell label="reptiles" /> <treecell label="Anaconda"/> <treecell label="Eunectes murinus" /> <treecell label="15"/>
-      </treerow> </treeitem>
-     <treeitem anyid="true"> <treerow>
-          <treecell label="reptiles" /> <treecell label="Chameleon"/> <treecell label="Chamaeleo chamaelon" /> <treecell label="16"/>
-      </treerow> </treeitem>
-  </treechildren>
-</output>;
+var expectedOutput = document.getElementById("output");
 
 var changes = [];
 ]]>
 </script>
 
 <tree   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="root" 
         flex="1" datasources="profile:animals.sqlite" ref="*" querytype="storage" flags="dont-build-content">
     <treecols>
--- a/content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
+++ b/content/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
@@ -9,65 +9,66 @@
 <window title="XUL Template Tests" width="500" height="600"
         onload="test_template();"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
+  <data id="output">