public static object DynCreateText([Implict] Executive executive, object value) { if (value == Undefined.Value) return Undefined.Value; XQueryContext context = (XQueryContext)executive.Owner; XQueryDocument doc = context.CreateDocument(); XQueryDocumentBuilder builder = new XQueryDocumentBuilder(doc); builder.WriteString((string)value); XPathFactory.XQueryDynNodeNavigator nav = new XPathFactory.XQueryDynNodeNavigator(doc); nav.MoveTo(doc.CreateNavigator()); return nav; }
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)); }