Beispiel #1
0
        public override object Evaluate(BaseIterator iter)
        {
            QName name = XslNameUtil.FromString(arg0.EvaluateString(iter), ctx);

            return(
                (name.Namespace == Compiler.XsltNamespace) &&
                (
                    //
                    // A list of all the instructions (does not include top-level-elements)
                    //
                    name.Name == "apply-imports" ||
                    name.Name == "apply-templates" ||
                    name.Name == "call-template" ||
                    name.Name == "choose" ||
                    name.Name == "comment" ||
                    name.Name == "copy" ||
                    name.Name == "copy-of" ||
                    name.Name == "element" ||
                    name.Name == "fallback" ||
                    name.Name == "for-each" ||
                    name.Name == "message" ||
                    name.Name == "number" ||
                    name.Name == "processing-instruction" ||
                    name.Name == "text" ||
                    name.Name == "value-of" ||
                    name.Name == "variable"
                )
                );
        }
Beispiel #2
0
        public QName [] ParseQNameListAttribute(string localName, string ns)
        {
            string s = GetAttribute(localName, ns);

            if (s == null)
            {
                return(null);
            }

            string [] names = s.Split(new char [] { ' ', '\r', '\n', '\t' });
            int       count = 0;

            for (int i = 0; i < names.Length; i++)
            {
                if (names[i].Length != 0)
                {
                    count++;
                }
            }

            QName [] ret = new QName [count];

            for (int i = 0, j = 0; i < names.Length; i++)
            {
                if (names[i].Length != 0)
                {
                    ret [j++] = XslNameUtil.FromString(names [i], Input);
                }
            }

            return(ret);
        }
Beispiel #3
0
        public bool MatchesKey(XPathNavigator nav, IStaticXsltContext staticContext, string name, string value)
        {
            XmlQualifiedName name2      = XslNameUtil.FromString(name, staticContext);
            KeyIndexTable    indexTable = this.GetIndexTable(name2);

            return(indexTable.Matches(nav, value, this));
        }
Beispiel #4
0
        public bool MatchesKey(XPathNavigator nav,
                               IStaticXsltContext staticContext,
                               string name, string value)
        {
            QName         qname = XslNameUtil.FromString(name, staticContext);
            KeyIndexTable table = GetIndexTable(qname);

            return(table.Matches(nav, value, this));
        }
Beispiel #5
0
        public override object Evaluate(BaseIterator iter)
        {
            string name  = arg0.EvaluateString(iter);
            int    colon = name.IndexOf(':');

            // extension function
            if (colon > 0)
            {
                return((iter.NamespaceManager as XsltCompiledContext).ResolveFunction(
                           XslNameUtil.FromString(name, ctx),
                           null) != null);
            }

            return(
                //
                // XPath
                //
                name == "boolean" ||
                name == "ceiling" ||
                name == "concat" ||
                name == "contains" ||
                name == "count" ||
                name == "false" ||
                name == "floor" ||
                name == "id" ||
                name == "lang" ||
                name == "last" ||
                name == "local-name" ||
                name == "name" ||
                name == "namespace-uri" ||
                name == "normalize-space" ||
                name == "not" ||
                name == "number" ||
                name == "position" ||
                name == "round" ||
                name == "starts-with" ||
                name == "string" ||
                name == "string-length" ||
                name == "substring" ||
                name == "substring-after" ||
                name == "substring-before" ||
                name == "sum" ||
                name == "translate" ||
                name == "true" ||
                // XSLT
                name == "document" ||
                name == "format-number" ||
                name == "function-available" ||
                name == "generate-id" ||
                name == "key" ||
                name == "current" ||
                name == "unparsed-entity-uri" ||
                name == "element-available" ||
                name == "system-property"
                );
        }
Beispiel #6
0
        Expression IStaticXsltContext.TryGetVariable(string nm)
        {
            if (this.curVarScope == null)
            {
                return(null);
            }
            XslLocalVariable xslLocalVariable = this.curVarScope.ResolveStatic(XslNameUtil.FromString(nm, this.Input));

            if (xslLocalVariable == null)
            {
                return(null);
            }
            return(new XPathVariableBinding(xslLocalVariable));
        }
Beispiel #7
0
        Expression IStaticXsltContext.TryGetVariable(string nm)
        {
            if (curVarScope == null)
            {
                return(null);
            }

            XslLocalVariable var = curVarScope.ResolveStatic(XslNameUtil.FromString(nm, Input));

            if (var == null)
            {
                return(null);
            }

            return(new XPathVariableBinding(var));
        }
Beispiel #8
0
        public override object Evaluate(BaseIterator iter)
        {
            QName name = XslNameUtil.FromString(arg0.EvaluateString(iter), ctx);

            if (name.Namespace == Compiler.XsltNamespace)
            {
                switch (name.Name)
                {
                case "version": return("1.0");

                case "vendor": return("Mono");

                case "vendor-url": return("http://www.go-mono.com/");
                }
            }

            return("");
        }
Beispiel #9
0
        public override object Evaluate(BaseIterator iter)
        {
            double d  = arg0.EvaluateNumber(iter);
            string s  = arg1.EvaluateString(iter);
            QName  nm = QName.Empty;

            if (arg2 != null)
            {
                nm = XslNameUtil.FromString(arg2.EvaluateString(iter), ctx);
            }

            try {
                return(((XsltCompiledContext)iter.NamespaceManager).Processor.CompiledStyle
                       .LookupDecimalFormat(nm).FormatNumber(d, s));
            } catch (ArgumentException ex) {
                throw new XsltException(ex.Message, ex, iter.Current);
            }
        }
Beispiel #10
0
        private XmlQualifiedName GetKeyName(IStaticXsltContext staticContext, BaseIterator iter, Expression nameExpr)
        {
            XmlQualifiedName xmlQualifiedName;

            if (nameExpr.HasStaticValue)
            {
                xmlQualifiedName = (XmlQualifiedName)this.keyNameCache[nameExpr];
                if (xmlQualifiedName == null)
                {
                    xmlQualifiedName            = XslNameUtil.FromString(nameExpr.EvaluateString(iter), staticContext);
                    this.keyNameCache[nameExpr] = xmlQualifiedName;
                }
            }
            else
            {
                xmlQualifiedName = XslNameUtil.FromString(nameExpr.EvaluateString(iter), this);
            }
            return(xmlQualifiedName);
        }
Beispiel #11
0
        public override object Evaluate(BaseIterator iter)
        {
            XmlQualifiedName xmlQualifiedName = XslNameUtil.FromString(this.arg0.EvaluateString(iter), this.ctx);

            if (xmlQualifiedName.Namespace == "http://www.w3.org/1999/XSL/Transform")
            {
                string name = xmlQualifiedName.Name;
                switch (name)
                {
                case "version":
                    return("1.0");

                case "vendor":
                    return("Mono");

                case "vendor-url":
                    return("http://www.go-mono.com/");
                }
            }
            return(string.Empty);
        }
        public override object Evaluate(BaseIterator iter)
        {
            double           number  = this.arg0.EvaluateNumber(iter);
            string           pattern = this.arg1.EvaluateString(iter);
            XmlQualifiedName name    = XmlQualifiedName.Empty;

            if (this.arg2 != null)
            {
                name = XslNameUtil.FromString(this.arg2.EvaluateString(iter), this.ctx);
            }
            object result;

            try
            {
                result = ((XsltCompiledContext)iter.NamespaceManager).Processor.CompiledStyle.LookupDecimalFormat(name).FormatNumber(number, pattern);
            }
            catch (ArgumentException ex)
            {
                throw new XsltException(ex.Message, ex, iter.Current);
            }
            return(result);
        }
Beispiel #13
0
        public XmlQualifiedName[] ParseQNameListAttribute(string localName, string ns)
        {
            string attribute = this.GetAttribute(localName, ns);

            if (attribute == null)
            {
                return(null);
            }
            string[] array = attribute.Split(new char[]
            {
                ' ',
                '\r',
                '\n',
                '\t'
            });
            int num = 0;

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].Length != 0)
                {
                    num++;
                }
            }
            XmlQualifiedName[] array2 = new XmlQualifiedName[num];
            int j    = 0;
            int num2 = 0;

            while (j < array.Length)
            {
                if (array[j].Length != 0)
                {
                    array2[num2++] = XslNameUtil.FromString(array[j], this.Input);
                }
                j++;
            }
            return(array2);
        }
        public static XmlQualifiedName[] FromListString(string names, XPathNavigator current)
        {
            string[] array = names.Split(XmlChar.WhitespaceChars);
            int      num   = 0;

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] != string.Empty)
                {
                    num++;
                }
            }
            XmlQualifiedName[] array2 = new XmlQualifiedName[num];
            num = 0;
            for (int j = 0; j < array.Length; j++)
            {
                if (array[j] != string.Empty)
                {
                    array2[num++] = XslNameUtil.FromString(array[j], current, true);
                }
            }
            return(array2);
        }
Beispiel #15
0
        private QName GetKeyName(IStaticXsltContext staticContext,
                                 BaseIterator iter, Expression nameExpr)
        {
            QName name = null;

            if (nameExpr.HasStaticValue)
            {
                name = (QName)keyNameCache [nameExpr];
                if (name == null)
                {
                    name = XslNameUtil.FromString(
                        nameExpr.EvaluateString(iter),
                        staticContext);
                    keyNameCache [nameExpr] = name;
                }
            }
            else
            {
                name = XslNameUtil.FromString(
                    nameExpr.EvaluateString(iter), this);
            }
            return(name);
        }
        private void ProcessAttribute(XPathNavigator nav)
        {
            // skip attributes from non-default namespace
            if (nav.NamespaceURI != string.Empty)
            {
                return;
            }

            string value = nav.Value;

            switch (nav.LocalName)
            {
            case "cdata-section-elements":
                if (value.Length > 0)
                {
                    cdSectsList.AddRange(XslNameUtil.FromListString(value, nav));
                }
                break;

            case "method":
                if (value.Length == 0)
                {
                    break;
                }

                switch (value)
                {
                case "xml":
                    method = OutputMethod.XML;
                    break;

                case "html":
                    omitXmlDeclaration = true;
                    method             = OutputMethod.HTML;
                    break;

                case "text":
                    omitXmlDeclaration = true;
                    method             = OutputMethod.Text;
                    break;

                default:
                    method       = OutputMethod.Custom;
                    customMethod = XslNameUtil.FromString(value, nav);
                    if (customMethod.Namespace == String.Empty)
                    {
                        IXmlLineInfo li = nav as IXmlLineInfo;
                        throw new XsltCompileException(new ArgumentException(
                                                           "Invalid output method value: '" + value + "'. It" +
                                                           " must be either 'xml' or 'html' or 'text' or QName."),
                                                       nav.BaseURI,
                                                       li != null ? li.LineNumber : 0,
                                                       li != null ? li.LinePosition : 0);
                    }
                    break;
                }
                break;

            case "version":
                if (value.Length > 0)
                {
                    this.version = value;
                }
                break;

            case "encoding":
                if (value.Length > 0)
                {
                    try
                    {
                        this.encoding = System.Text.Encoding.GetEncoding(value);
                    }
                    catch (ArgumentException)
                    {
                        // MS.NET just leaves the default encoding when encoding is unknown
                    }
                    catch (NotSupportedException)
                    {
                        // Workaround for a bug in System.Text, it throws invalid exception
                    }
                }
                break;

            case "standalone":
                switch (value)
                {
                case "yes":
                    this.standalone = StandaloneType.YES;
                    break;

                case "no":
                    this.standalone = StandaloneType.NO;
                    break;

                default:
                    if (stylesheetVersion != "1.0")
                    {
                        break;
                    }

                    IXmlLineInfo li = nav as IXmlLineInfo;
                    throw new XsltCompileException(new XsltException(
                                                       "'" + value + "' is an invalid value for 'standalone'" +
                                                       " attribute.", (Exception)null),
                                                   nav.BaseURI,
                                                   li != null ? li.LineNumber : 0,
                                                   li != null ? li.LinePosition : 0);
                }
                break;

            case "doctype-public":
                this.doctypePublic = value;
                break;

            case "doctype-system":
                this.doctypeSystem = value;
                break;

            case "media-type":
                if (value.Length > 0)
                {
                    this.mediaType = value;
                }
                break;

            case "omit-xml-declaration":
                switch (value)
                {
                case "yes":
                    this.omitXmlDeclaration = true;
                    break;

                case "no":
                    this.omitXmlDeclaration = false;
                    break;

                default:
                    if (stylesheetVersion != "1.0")
                    {
                        break;
                    }

                    IXmlLineInfo li = nav as IXmlLineInfo;
                    throw new XsltCompileException(new XsltException(
                                                       "'" + value + "' is an invalid value for 'omit-xml-declaration'" +
                                                       " attribute.", (Exception)null),
                                                   nav.BaseURI,
                                                   li != null ? li.LineNumber : 0,
                                                   li != null ? li.LinePosition : 0);
                }
                break;

            case "indent":
                indent = value;
                if (stylesheetVersion != "1.0")
                {
                    break;
                }
                switch (value)
                {
                case "yes":
                case "no":
                    break;

                default:
                    switch (method)
                    {
                    case OutputMethod.Custom:
                        break;

                    default:
                        throw new XsltCompileException(String.Format("Unexpected 'indent' attribute value in 'output' element: '{0}'", value), null, nav);
                    }
                    break;
                }
                break;

            default:
                if (stylesheetVersion != "1.0")
                {
                    break;
                }

                IXmlLineInfo xli = nav as IXmlLineInfo;
                throw new XsltCompileException(new XsltException(
                                                   "'" + nav.LocalName + "' is an invalid attribute for 'output'" +
                                                   " element.", (Exception)null),
                                               nav.BaseURI,
                                               xli != null ? xli.LineNumber : 0,
                                               xli != null ? xli.LinePosition : 0);
            }
        }
Beispiel #17
0
 QName IStaticXsltContext.LookupQName(string s)
 {
     return(XslNameUtil.FromString(s, Input));
 }
Beispiel #18
0
        private void ProcessAttribute(XPathNavigator nav)
        {
            if (nav.NamespaceURI != string.Empty)
            {
                return;
            }
            string value     = nav.Value;
            string localName = nav.LocalName;

            switch (localName)
            {
            case "cdata-section-elements":
                if (value.Length > 0)
                {
                    this.cdSectsList.AddRange(XslNameUtil.FromListString(value, nav));
                }
                return;

            case "method":
            {
                if (value.Length == 0)
                {
                    return;
                }
                string text = value;
                switch (text)
                {
                case "xml":
                    this.method = OutputMethod.XML;
                    goto IL_269;

                case "html":
                    this.omitXmlDeclaration = true;
                    this.method             = OutputMethod.HTML;
                    goto IL_269;

                case "text":
                    this.omitXmlDeclaration = true;
                    this.method             = OutputMethod.Text;
                    goto IL_269;
                }
                this.method       = OutputMethod.Custom;
                this.customMethod = XslNameUtil.FromString(value, nav);
                if (this.customMethod.Namespace == string.Empty)
                {
                    IXmlLineInfo xmlLineInfo = nav as IXmlLineInfo;
                    throw new XsltCompileException(new ArgumentException("Invalid output method value: '" + value + "'. It must be either 'xml' or 'html' or 'text' or QName."), nav.BaseURI, (xmlLineInfo == null) ? 0 : xmlLineInfo.LineNumber, (xmlLineInfo == null) ? 0 : xmlLineInfo.LinePosition);
                }
IL_269:
                return;
            }

            case "version":
                if (value.Length > 0)
                {
                    this.version = value;
                }
                return;

            case "encoding":
                if (value.Length > 0)
                {
                    try
                    {
                        this.encoding = Encoding.GetEncoding(value);
                    }
                    catch (ArgumentException)
                    {
                    }
                    catch (NotSupportedException)
                    {
                    }
                }
                return;

            case "standalone":
            {
                string text = value;
                if (text != null)
                {
                    if (XslOutput.< > f__switch$map20 == null)
                    {
                        XslOutput.< > f__switch$map20 = new Dictionary <string, int>(2)
                        {
                            {
                                "yes",
                                0
                            },
                            {
                                "no",
                                1
                            }
                        };
                    }
                    int num2;
                    if (XslOutput.< > f__switch$map20.TryGetValue(text, out num2))
                    {
                        if (num2 == 0)
                        {
                            this.standalone = StandaloneType.YES;
                            goto IL_397;
                        }
                        if (num2 == 1)
                        {
                            this.standalone = StandaloneType.NO;
                            goto IL_397;
                        }
                    }
                }
                if (!(this.stylesheetVersion != "1.0"))
                {
                    IXmlLineInfo xmlLineInfo2 = nav as IXmlLineInfo;
                    throw new XsltCompileException(new XsltException("'" + value + "' is an invalid value for 'standalone' attribute.", null), nav.BaseURI, (xmlLineInfo2 == null) ? 0 : xmlLineInfo2.LineNumber, (xmlLineInfo2 == null) ? 0 : xmlLineInfo2.LinePosition);
                }
IL_397:
                return;
            }

            case "doctype-public":
                this.doctypePublic = value;
                return;

            case "doctype-system":
                this.doctypeSystem = value;
                return;

            case "media-type":
                if (value.Length > 0)
                {
                    this.mediaType = value;
                }
                return;

            case "omit-xml-declaration":
            {
                string text = value;
                if (text != null)
                {
                    if (XslOutput.< > f__switch$map21 == null)
                    {
                        XslOutput.< > f__switch$map21 = new Dictionary <string, int>(2)
                        {
                            {
                                "yes",
                                0
                            },
                            {
                                "no",
                                1
                            }
                        };
                    }
                    int num2;
                    if (XslOutput.< > f__switch$map21.TryGetValue(text, out num2))
                    {
                        if (num2 == 0)
                        {
                            this.omitXmlDeclaration = true;
                            goto IL_4AF;
                        }
                        if (num2 == 1)
                        {
                            this.omitXmlDeclaration = false;
                            goto IL_4AF;
                        }
                    }
                }
                if (!(this.stylesheetVersion != "1.0"))
                {
                    IXmlLineInfo xmlLineInfo3 = nav as IXmlLineInfo;
                    throw new XsltCompileException(new XsltException("'" + value + "' is an invalid value for 'omit-xml-declaration' attribute.", null), nav.BaseURI, (xmlLineInfo3 == null) ? 0 : xmlLineInfo3.LineNumber, (xmlLineInfo3 == null) ? 0 : xmlLineInfo3.LinePosition);
                }
IL_4AF:
                return;
            }

            case "indent":
            {
                this.indent = value;
                if (this.stylesheetVersion != "1.0")
                {
                    return;
                }
                string text = value;
                if (text != null)
                {
                    if (XslOutput.< > f__switch$map22 == null)
                    {
                        XslOutput.< > f__switch$map22 = new Dictionary <string, int>(2)
                        {
                            {
                                "yes",
                                0
                            },
                            {
                                "no",
                                0
                            }
                        };
                    }
                    int num2;
                    if (XslOutput.< > f__switch$map22.TryGetValue(text, out num2))
                    {
                        if (num2 == 0)
                        {
                            goto IL_568;
                        }
                    }
                }
                OutputMethod outputMethod = this.method;
                if (outputMethod != OutputMethod.Custom)
                {
                    throw new XsltCompileException(string.Format("Unexpected 'indent' attribute value in 'output' element: '{0}'", value), null, nav);
                }
IL_568:
                return;
            }
            }
            if (!(this.stylesheetVersion != "1.0"))
            {
                IXmlLineInfo xmlLineInfo4 = nav as IXmlLineInfo;
                throw new XsltCompileException(new XsltException("'" + nav.LocalName + "' is an invalid attribute for 'output' element.", null), nav.BaseURI, (xmlLineInfo4 == null) ? 0 : xmlLineInfo4.LineNumber, (xmlLineInfo4 == null) ? 0 : xmlLineInfo4.LinePosition);
            }
        }
Beispiel #19
0
 public QName ParseQNameAttribute(string localName, string ns)
 {
     return(XslNameUtil.FromString(Input.GetAttribute(localName, ns), Input));
 }
        public override object Evaluate(BaseIterator iter)
        {
            XmlQualifiedName xmlQualifiedName = XslNameUtil.FromString(this.arg0.EvaluateString(iter), this.ctx);

            return(xmlQualifiedName.Namespace == "http://www.w3.org/1999/XSL/Transform" && (xmlQualifiedName.Name == "apply-imports" || xmlQualifiedName.Name == "apply-templates" || xmlQualifiedName.Name == "call-template" || xmlQualifiedName.Name == "choose" || xmlQualifiedName.Name == "comment" || xmlQualifiedName.Name == "copy" || xmlQualifiedName.Name == "copy-of" || xmlQualifiedName.Name == "element" || xmlQualifiedName.Name == "fallback" || xmlQualifiedName.Name == "for-each" || xmlQualifiedName.Name == "message" || xmlQualifiedName.Name == "number" || xmlQualifiedName.Name == "processing-instruction" || xmlQualifiedName.Name == "text" || xmlQualifiedName.Name == "value-of" || xmlQualifiedName.Name == "variable"));
        }
 public static XmlQualifiedName FromString(string name, XPathNavigator current)
 {
     return(XslNameUtil.FromString(name, current, false));
 }
Beispiel #22
0
 XmlQualifiedName IStaticXsltContext.LookupQName(string s)
 {
     return(XslNameUtil.FromString(s, this.Input));
 }
Beispiel #23
0
 public XmlQualifiedName ParseQNameAttribute(string localName, string ns)
 {
     return(XslNameUtil.FromString(this.Input.GetAttribute(localName, ns), this.Input));
 }