Esempio n. 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;
 }
Esempio n. 2
0
 public static object DynCreateElement([Implict] Executive executive, object name, XmlNamespaceManager nsmgr, object body)
 {
     XQueryContext context = (XQueryContext)executive.Owner;
     XQueryDocument doc = context.CreateDocument();
     XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc);
     QNameValue qname = GetQualifiedName(name, nsmgr, nsmgr.DefaultNamespace);
     builder.WriteStartElement(qname.Prefix, qname.LocalName, qname.NamespaceUri);
     if (body != null)
         WriteNode(executive, builder, body);
     builder.WriteEndElement();
     return doc.CreateNavigator();
 }
Esempio n. 3
0
 public static object DynCreateAttribute([Implict] Executive executive, object name, XmlNamespaceManager nsmgr, object value)
 {
     XQueryContext context = (XQueryContext)executive.Owner;
     XQueryDocument doc = context.CreateDocument();
     XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc);
     QNameValue qname = GetQualifiedName(name, nsmgr, "");
     if (qname.Prefix == "xmlns" || (qname.Prefix == "" && qname.LocalName == "xmlns"))
         throw new XQueryException(Properties.Resources.XQDY0044);
     builder.WriteStartElement("dummy");
     builder.WriteStartAttribute(qname.Prefix, qname.LocalName, qname.NamespaceUri);
     string text = value == Undefined.Value ? "" : (string)value;
     builder.WriteString(text);
     builder.WriteEndAttribute();
     builder.WriteEndElement();
     XPathNavigator nav = doc.CreateNavigator();
     return new NodeIterator(XPathFactory.DynAttributeIterator(nav));
 }
Esempio n. 4
0
 public static object DynCreateElement([Implict] Executive executive, QNameValue name, object body)
 {
     XQueryContext context = (XQueryContext)executive.Owner;
     XQueryDocument doc = context.CreateDocument();
     XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc);
     builder.WriteStartElement(name.Prefix, name.LocalName, name.NamespaceUri);
     if (body != null)
         WriteNode(executive, builder, body);
     builder.WriteEndElement();
     return doc.CreateNavigator();
 }