Example #1
0
        public static XmlElement XslForEachGroup(this XmlElement element, XPathExpr selectXPath)
        {
            XmlElement copyOfElement = element.XslElement("for-each-group");

            copyOfElement.AddAttributeWithValue("select", selectXPath);
            return(copyOfElement);
        }
Example #2
0
        public static XmlElement XslIf(this XmlElement element, XPathExpr test)
        {
            XmlElement valueOfElement = element.XslElement("if");

            valueOfElement.AddAttributeWithValue("test", test);
            return(valueOfElement);
        }
Example #3
0
        public static XmlElement XslValueOf(this XmlElement element, XPathExpr selectXPath)
        {
            XmlElement valueOfElement = element.XslElement("value-of");

            valueOfElement.AddAttributeWithValue("select", selectXPath);
            return(valueOfElement);
        }
Example #4
0
        public static XmlElement XslForEach(this XmlElement element, XPathExpr selectXPath)
        {
            XmlElement forEachElement = element.XslElement("for-each");

            forEachElement.AddAttributeWithValue("select", selectXPath);
            return(forEachElement);
        }
Example #5
0
        public static XmlElement XslCopyOf(this XmlElement element, XPathExpr selectXPath)
        {
            XmlElement copyOfElement = element.XslElement("copy-of");

            copyOfElement.AddAttributeWithValue("select", selectXPath);
            return(copyOfElement);
        }
Example #6
0
        public static XmlElement XslWhen(this XmlElement element, XPathExpr test)
        {
            XmlElement option = element.XslElement("when");

            option.AddAttributeWithValue("test", test);
            return(option);
        }
Example #7
0
        private XPathExpr make_convert_operand(XPathExpr arg1, XPathExpr arg2)
        {
            throw new Exception();
            //var args = new ArrayList();
            //args.Add(arg1);
            //args.Add(arg2);

            //return make_function(new QName("fs", "convert-operand", OpFunctionLibrary.XPATH_OP_NS), args);
        }
Example #8
0
        public static XmlElement XslVariable(this XmlElement element, string name, XPathExpr selectXPath)
        {
            XmlElement variableElement = element.XslElement("variable");

            variableElement.AddAttributeWithValue("name", name);
            if (selectXPath != null)
            {
                variableElement.AddAttributeWithValue("select", selectXPath);
            }
            return(variableElement);
        }
Example #9
0
 public override object visit(XPathExpr e)
 {
     if (e.slashes() > 0)
     {
         throw new XPathParserException("Access to root node is not allowed (set by caller)");
     }
     do
     {
         e.expr().accept(this); // check the single step (may have filter with root access)
         e = e.next();          // follow singly linked list of the path, it's all relative past the first one
     } while (e != null);
     return(null);
 }
Example #10
0
        public static XmlElement XslTemplate(this XmlElement element, XPathExpr matchXPath, params string[] parameters)
        {
            XmlElement templateElement = element.XslElement("template");

            templateElement.AddAttributeWithValue("match", matchXPath);
            if (parameters != null)
            {
                foreach (string parameter in parameters)
                {
                    XmlElement param = templateElement.XslElement("param");
                    param.AddAttributeWithValue("name", parameter);
                }
            }
            return(templateElement);
        }
Example #11
0
        private static XmlElement XslApplyTemplates(this XmlElement element, XPathExpr selectXPath, IEnumerable <TemplateParameter> parameters)
        {
            XmlElement applyTemplatesElement = element.XslElement("apply-templates");

            applyTemplatesElement.AddAttributeWithValue("select", selectXPath);
            if (parameters != null)
            {
                foreach (TemplateParameter keyValuePair in parameters)
                {
                    XmlElement param = applyTemplatesElement.XslElement("with-param");
                    param.AddAttributeWithValue("name", keyValuePair.Name);
                    param.AddAttributeWithValue("select", keyValuePair.Value);
                }
            }
            return(applyTemplatesElement);
        }
Example #12
0
        // fs:fname( fs:convert-operand( fn:data(ARG1), 1.0E0 ),
        // fs:convert-operand( fn:data(ARG2), 1.0E0 )
        // )
        private XPathExpr make_convert_binop(BinExpr e, XPathExpr convarg, QName name)
        {
            throw new Exception();
            //ICollection args = normalize_bin_args(e);
            //XPathExpr[] args_arr = new XPathExpr[2];
            //int j = 0;

            //for (IEnumerator i = args.GetEnumerator(); i.MoveNext();)
            //{
            //	args_arr[j] = (XPathExpr) i.Current;
            //	j++;
            //}

            //var argsfname = new ArrayList();
            //for (j = 0; j < 2; j++)
            //{
            //	XPathExpr arg = make_convert_operand(args_arr[j], convarg);
            //	argsfname.Add(arg);
            //}
            //return make_function(name, argsfname);
        }
Example #13
0
        /// <summary>
        /// Validate an xpath expression.
        /// </summary>
        /// <param name="e">
        ///            is the expression. </param>
        /// <returns> null. </returns>
        public virtual object visit(XPathExpr e)
        {
            XPathExpr xp        = e;
            bool      firstStep = true;

            while (xp != null)
            {
                if (firstStep && xp.slashes() != 0)
                {
                    _rootUsed = true;
                }

                firstStep = false;
                StepExpr se = xp.expr();

                if (se != null)
                {
                    se.accept(this);
                }

                xp = xp.next();
            }
            return(null);
        }
Example #14
0
 public static XmlElement XslApplyTemplates(this XmlElement element, XPathExpr selectXPath, params TemplateParameter[] parameters)
 {
     return(XslApplyTemplates(element, selectXPath, (IEnumerable <TemplateParameter>)parameters));
 }
Example #15
0
 public static XmlAttribute XslGroupStartingWithAttribute(this XmlDocument document, XPathExpr value, bool consequentInOneGroup)
 {
     if (!consequentInOneGroup)
     {
         XmlAttribute xslGroupStartingWithAttribute = document.CreateAttribute("group-starting-with");
         xslGroupStartingWithAttribute.Value = value;
         return(xslGroupStartingWithAttribute);
     }
     else
     {
         XmlAttribute xslGroupStartingWithAttribute = document.CreateAttribute("group-starting-with");
         xslGroupStartingWithAttribute.Value = string.Format("{0}[not(preceding-sibling::{0}[1] is preceding-sibling::*[1])]", value);
         return(xslGroupStartingWithAttribute);
     }
 }
Example #16
0
        /// <param name="e">
        ///            is the xpath expression. </param>
        /// <returns> result. </returns>
        public virtual object visit(XPathExpr e)
        {
            XPathExpr xp     = e;
            int       depth  = 0;      // indicates how many / we traversed
            XPathExpr result = e;

            while (xp != null)
            {
                int      slashes = xp.slashes();
                StepExpr se      = xp.expr();

                if (slashes == 1)
                {
                    // this is a single slash and nothing else...
                    if (se == null)
                    {
                        return(make_root_self_node());
                    }

                    // /RelativePathExpr
                    if (depth == 0)
                    {
                        XPathExpr xpe = make_root_self_node();
                        xpe.set_next(e);

                        result = xpe;
                    }
                }

                if (slashes == 2)
                {
                    // //RelativePathExpr
                    if (depth == 0)
                    {
                        XPathExpr desc = make_descendant_or_self();
                        desc.set_slashes(1);
                        e.set_slashes(1);
                        desc.set_next(e);

                        XPathExpr root_self = make_root_self_node();
                        root_self.set_next(desc);
                        return(root_self);
                    }
                }

                if (se != null)
                {
                    se.accept(this);
                }

                XPathExpr next = xp.next();

                // peek if the next guy will have 2 slashes...
                if (next != null)
                {
                    // StepExpr//StepExpr
                    if (next.slashes() == 2)
                    {
                        // create the node to stick between the
                        // slashes
                        XPathExpr desc = make_descendant_or_self();
                        desc.set_slashes(1);

                        // current node / desc / next
                        xp.set_next(desc);
                        desc.set_next(next);
                        next.set_slashes(1);
                    }
                }
                xp = next;
                depth++;
            }
            return(result);
        }
Example #17
0
 /// <param name="e">
 ///            is the xpath expression. </param>
 /// <returns> result. </returns>
 public virtual object visit(XPathExpr e)
 {
     e.expr().accept(this);
     e.next().accept(this);
     return(null);
 }
Example #18
0
 public TemplateParameter(string name, XPathExpr value) : this()
 {
     Name  = name;
     Value = value;
 }