Exemplo n.º 1
0
 private IEnumerable<XPathItem> DocumentIterator(XQueryContext context, XQueryNodeIterator iter)
 {
     foreach (XPathItem item in iter)
     {
         XPathNavigator nav = item as XPathNavigator;
         if (nav != null && nav.NodeType != XPathNodeType.Root)
         {
             XQueryDocument doc = context.CreateDocument();
             XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc);
             builder.WriteStartDocument();
             Core.WriteNode(context.Engine, builder, nav);
             yield return doc.CreateNavigator();
         }
         else
             yield return item;
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public static object DynCreateDocument([Implict] Executive executive, object body)
 {
     XQueryContext context = (XQueryContext)executive.Owner;
     XQueryDocument doc = context.CreateDocument();
     XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc);
     builder.WriteStartDocument();
     if (body != null)
         WriteNode(executive, builder, body);
     return doc.CreateNavigator();
 }