コード例 #1
0
 private bool CompareFragment(XQueryContext context, string sourceFile, XQueryNodeIterator iter, XmlSpace space)
 {
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("<?xml version='1.0'?>");
     sb.Append("<root>");
     TextReader textReader = new StreamReader(sourceFile, true);
     sb.Append(textReader.ReadToEnd());
     textReader.Close();
     sb.Append("</root>");
     XmlReaderSettings settings = context.GetSettings();
     XmlReader reader = XmlReader.Create(new StringReader(sb.ToString()), settings);
     XQueryDocument doc1 = new XQueryDocument(reader, space);
     doc1.Fill();
     context.AddDocument(doc1);
     XQueryDocument doc2 = context.CreateDocument();
     XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc2);
     builder.WriteStartDocument();
     builder.WriteStartElement("root", "");
     Core.WriteNode(context.Engine, builder, iter.Clone());
     builder.WriteEndElement();
     XQueryNodeIterator iter1 = new NodeIterator(new XPathItem[] { doc1.CreateNavigator() });
     XQueryNodeIterator iter2 = new NodeIterator(new XPathItem[] { doc2.CreateNavigator() });
     TreeComparer comparer = new TreeComparer();
     comparer.IgnoreWhitespace = true;
     bool res = comparer.DeepEqual(iter1, iter2);
     return res;
 }
コード例 #2
0
 private bool CompareXML(XQueryContext context, string sourceFile, XQueryNodeIterator iter)
 {
     IXPathNavigable doc = context.OpenDocument(sourceFile);
     XQueryNodeIterator src = new NodeIterator(new XPathItem[] { doc.CreateNavigator() });
     TreeComparer comparer = new TreeComparer();
     comparer.IgnoreWhitespace = true;
     return comparer.DeepEqual(src, new NodeIterator(DocumentIterator(context, iter)));
 }