/// <summary> /// Processes the element. /// </summary> /// <param name="nodeList">The element.</param> /// <returns></returns> public void DispatchProcessAll(IXmlProcessorNodeList nodeList) { while(nodeList.MoveNext()) { DispatchProcessCurrent(nodeList); } }
/// <summary> /// Processes the element. /// </summary> /// <param name="nodeList">The element.</param> /// <returns></returns> public void DispatchProcessAll(IXmlProcessorNodeList nodeList) { while (nodeList.MoveNext()) { DispatchProcessCurrent(nodeList); } }
/// <summary> /// /// </summary> /// <param name="nodeList"></param> /// <param name="engine"></param> /// <example> /// <code> /// <properties> /// <attributes> /// <myAttribute>attributeValue</myAttribute> /// </attributes> /// <myProperty>propertyValue</myProperty> /// </properties> /// </code> /// </example> public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; IXmlProcessorNodeList childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); while(childNodes.MoveNext()) { // Properties processing its a little more complicated than usual // since we need to support all special tags (if,else,define...) // plus we need to register any regular element as a property asap // since we should support properties that reference other properties // i.e. <myprop2>#{prop1}</myprop2> if (engine.HasSpecialProcessor(childNodes.Current)) { // Current node its a special element so we bookmark it before processing it... XmlNode current = childNodes.Current; int pos = childNodes.CurrentPosition; engine.DispatchProcessCurrent(childNodes); // ...after processing we need to refresh childNodes // to account for any special element that affects the node tree (if,choose...) childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); // we only care about changes in the tree from the current node and forward // so if the new list is empty or smaller we just exit the loop if (pos < childNodes.Count) { childNodes.CurrentPosition = pos; // if the current node gets replaced in the new list we need to restart processing // otherwise we just continue as usual if (childNodes.Current != current) { childNodes.CurrentPosition -= 1; continue; } } else { break; } } else { engine.DispatchProcessCurrent(childNodes); } if (IgnoreNode(childNodes.Current)) continue; XmlElement elem = GetNodeAsElement(element, childNodes.Current); engine.AddProperty(elem); } RemoveItSelf(element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var node = nodeList.Current as XmlProcessingInstruction; engine.RemoveFlag(node.Data); RemoveItSelf(node); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlProcessingInstruction node = nodeList.Current as XmlProcessingInstruction; engine.RemoveFlag(node.Data); RemoveItSelf(node); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var element = nodeList.Current as XmlElement; var result = ProcessInclude(element, element.GetAttribute("uri"), engine); ReplaceItself(result, element); }
/// <summary> /// Processes the specified node list. /// </summary> /// <param name = "nodeList">The node list.</param> /// <param name = "engine">The engine.</param> public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var element = (XmlElement)nodeList.Current; ProcessAttributes(element, engine); engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(element.ChildNodes)); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; XmlNode result = ProcessInclude(element, element.GetAttribute("uri"), engine); ReplaceItself(result, element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; ProcessAttributes(element, engine); engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(element.ChildNodes)); }
/// <summary> /// Processes the element. /// </summary> /// <param name="nodeList">The element.</param> /// <returns></returns> public void DispatchProcessCurrent(IXmlProcessorNodeList nodeList) { IXmlNodeProcessor processor = GetProcessor(nodeList.Current); if (processor != null) { processor.Process(nodeList, this); } }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var assemblyName = GetRequiredAttribute((XmlElement)nodeList.Current, "assembly"); // that's it, at this point we just load the assembly into the appdomain so that it becomes // available to type matching system. var assembly = ReflectionUtil.GetAssemblyNamed(assemblyName); RemoveItSelf(nodeList.Current); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; String flag = GetRequiredAttribute(element, FlagAttrName); Process(flag, engine); RemoveItSelf(element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; bool processContents = ProcessStatement(element, engine); if (processContents) { XmlDocumentFragment fragment = CreateFragment(element); MoveChildNodes(fragment, element); engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(fragment.ChildNodes)); ReplaceItself(fragment, element); } else { RemoveItSelf(element); } }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var element = nodeList.Current as XmlElement; var fragment = CreateFragment(element); foreach (XmlNode child in element.ChildNodes) { if (IgnoreNode(child)) { continue; } var elem = GetNodeAsElement(element, child); var found = false; if (elem.Name == WhenElemName) { found = ProcessStatement(elem, engine); } else if (elem.Name == OtherwiseElemName) { found = true; } else { throw new XmlProcessorException("'{0} can not contain only 'when' and 'otherwise' elements found '{1}'", element.Name, elem.Name); } if (found) { if (elem.ChildNodes.Count > 0) { MoveChildNodes(fragment, elem); engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(fragment.ChildNodes)); } break; } } ReplaceItself(fragment, element); }
/// <summary> /// /// </summary> /// <param name="nodeList"></param> /// <param name="engine"></param> /// <example> /// <code> /// <properties> /// <attributes> /// <myAttribute>attributeValue</myAttribute> /// </attributes> /// <myProperty>propertyValue</myProperty> /// </properties> /// </code> /// </example> public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; DefaultXmlProcessorNodeList childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); while(childNodes.MoveNext()) { engine.DispatchProcessCurrent(childNodes); if (IgnoreNode(childNodes.Current)) continue; XmlElement elem = GetNodeAsElement(element, childNodes.Current); AppendElementAsAttribute(element.ParentNode, childNodes.Current as XmlElement); } RemoveItSelf(element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; XmlDocumentFragment fragment = CreateFragment(element); foreach (XmlNode child in element.ChildNodes) { if (IgnoreNode(child)) { continue; } XmlElement elem = GetNodeAsElement(element, child); bool found = false; if (elem.Name == WhenElemName) { found = ProcessStatement(elem, engine); } else if (elem.Name == OtherwiseElemName) { found = true; } else { throw new XmlProcessorException("'{0} can not contain only 'when' and 'otherwise' elements found '{1}'", element.Name, elem.Name); } if (found) { if (elem.ChildNodes.Count > 0) { MoveChildNodes(fragment, elem); engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(fragment.ChildNodes)); } break; } } ReplaceItself(fragment, element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlProcessingInstruction node = nodeList.Current as XmlProcessingInstruction; XmlDocumentFragment fragment = CreateFragment(node); string expression = node.Data; // We don't have an expression evaluator right now, so expression will // be just pre-defined literals that we know how to evaluate object evaluated = ""; if (string.Compare(expression, "$basedirectory", true) == 0) { evaluated = AppDomain.CurrentDomain.BaseDirectory; } fragment.AppendChild(node.OwnerDocument.CreateTextNode(evaluated.ToString())); ReplaceNode(node.ParentNode, fragment, node); }
/// <summary> /// /// </summary> /// <param name="nodeList"></param> /// <param name="engine"></param> /// <example> /// <code> /// <properties> /// <attributes> /// <myAttribute>attributeValue</myAttribute> /// </attributes> /// <myProperty>propertyValue</myProperty> /// </properties> /// </code> /// </example> public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlElement element = nodeList.Current as XmlElement; DefaultXmlProcessorNodeList childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); while (childNodes.MoveNext()) { engine.DispatchProcessCurrent(childNodes); if (IgnoreNode(childNodes.Current)) { continue; } XmlElement elem = GetNodeAsElement(element, childNodes.Current); AppendElementAsAttribute(element.ParentNode, childNodes.Current as XmlElement); } RemoveItSelf(element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var node = nodeList.Current as XmlCharacterData; ProcessString(node, node.Value, engine); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlProcessingInstruction node = nodeList.Current as XmlProcessingInstruction; AssertData(node, true); StatementState state = engine.HasFlag(node.Data) ? StatementState.Collect : StatementState.Init; List<XmlNode> nodesToProcess = new List<XmlNode>(); int nestedLevels = 0; RemoveItSelf(nodeList.Current); while(nodeList.MoveNext()) { if (nodeList.Current.NodeType == XmlNodeType.ProcessingInstruction) { XmlProcessingInstruction pi = nodeList.Current as XmlProcessingInstruction; if (pi.Name == EndPiName) { nestedLevels--; if (nestedLevels < 0) { RemoveItSelf(nodeList.Current); break; } } else if (pi.Name == IfPiName) { nestedLevels++; } else if (nestedLevels == 0) { if (pi.Name == ElsePiName || pi.Name == ElsifPiName) { ProcessElseElement(pi, engine, ref state); continue; } } } if (state == StatementState.Collect) { nodesToProcess.Add(nodeList.Current); } else { RemoveItSelf(nodeList.Current); } } if (nestedLevels != -1) { throw new XmlProcessorException("Unbalanced pi if element"); } if (nodesToProcess.Count > 0) { engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(nodesToProcess)); } }
public abstract void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine);
///<summary> ///</summary> ///<param name = "nodeList"></param> ///<param name = "engine"></param> ///<example> /// <code> /// <properties> /// <attributes> /// <myAttribute>attributeValue</myAttribute> /// </attributes> /// <myProperty>propertyValue</myProperty> /// </properties> /// </code> ///</example> public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { var element = nodeList.Current as XmlElement; IXmlProcessorNodeList childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); while (childNodes.MoveNext()) { // Properties processing its a little more complicated than usual // since we need to support all special tags (if,else,define...) // plus we need to register any regular element as a property asap // since we should support properties that reference other properties // i.e. <myprop2>#{prop1}</myprop2> if (engine.HasSpecialProcessor(childNodes.Current)) { // Current node its a special element so we bookmark it before processing it... var current = childNodes.Current; var pos = childNodes.CurrentPosition; engine.DispatchProcessCurrent(childNodes); // ...after processing we need to refresh childNodes // to account for any special element that affects the node tree (if,choose...) childNodes = new DefaultXmlProcessorNodeList(element.ChildNodes); // we only care about changes in the tree from the current node and forward // so if the new list is empty or smaller we just exit the loop if (pos < childNodes.Count) { childNodes.CurrentPosition = pos; // if the current node gets replaced in the new list we need to restart processing // otherwise we just continue as usual if (childNodes.Current != current) { childNodes.CurrentPosition -= 1; continue; } } else { break; } } else { engine.DispatchProcessCurrent(childNodes); } if (IgnoreNode(childNodes.Current)) { continue; } var elem = GetNodeAsElement(element, childNodes.Current); engine.AddProperty(elem); } RemoveItSelf(element); }
public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine) { XmlProcessingInstruction node = nodeList.Current as XmlProcessingInstruction; AssertData(node, true); StatementState state = engine.HasFlag(node.Data) ? StatementState.Collect : StatementState.Init; List <XmlNode> nodesToProcess = new List <XmlNode>(); int nestedLevels = 0; RemoveItSelf(nodeList.Current); while (nodeList.MoveNext()) { if (nodeList.Current.NodeType == XmlNodeType.ProcessingInstruction) { XmlProcessingInstruction pi = nodeList.Current as XmlProcessingInstruction; if (pi.Name == EndPiName) { nestedLevels--; if (nestedLevels < 0) { RemoveItSelf(nodeList.Current); break; } } else if (pi.Name == IfPiName) { nestedLevels++; } else if (nestedLevels == 0) { if (pi.Name == ElsePiName || pi.Name == ElsifPiName) { ProcessElseElement(pi, engine, ref state); continue; } } } if (state == StatementState.Collect) { nodesToProcess.Add(nodeList.Current); } else { RemoveItSelf(nodeList.Current); } } if (nestedLevels != -1) { throw new XmlProcessorException("Unbalanced pi if element"); } if (nodesToProcess.Count > 0) { engine.DispatchProcessAll(new DefaultXmlProcessorNodeList(nodesToProcess)); } }