<body>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=10419">bug 10419</a>:
XSLTProcessor transformToFragment fails because of an XML declaration.</p>

<script>

  if (window.testRunner)
    testRunner.dumpAsText();

  try {
    var xml = (new DOMParser()).parseFromString('<doc/>', 'application/xml');
    var xsl = (new DOMParser()).parseFromString(
        '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">' +
        '<xsl:output method="xml" omit-xml-declaration="no"/>' +
        ' <xsl:template match="doc"><p>1</p><p>2</p></xsl:template>' +
        '</xsl:stylesheet>', 
        'application/xml');

    var p = new XSLTProcessor;
    p.importStylesheet(xsl);

    var ownerDocument = document.implementation.createDocument("", "doc", null);
    var f = p.transformToFragment(xml, ownerDocument);
    var result = (new XMLSerializer()).serializeToString(f);
    result = result.substr(0, 16); // remove the trailing newline, if present

    if (result == "<p>1</p><p>2</p>")
        document.write('SUCCESS');
    else
        document.write('<xmp>FAILURE: "' + result + '"</xmp>');

  } catch (ex) {
     document.write('FAILURE: ' + ex);
  }

</script>
</body>
