Exemplo n.º 1
0
        protected override void ExtractInfo()
        {
            // Extract keyword
            Keyword = Element.Name.LocalName;

            // Check syntax
            IEnumerable <XNode> textNodes = Element.Nodes()
                                            .Where(n => n.NodeType == XmlNodeType.Text);

            if (textNodes.Any())
            {
                string        text     = Element.Value.Trim().Ellipses(25);
                string        fmt      = Resources.SyntaxExceptionXmlUnexpectedText;
                XNode         textNode = textNodes.ElementAt(0);
                ISourceEntity src      = new XmlSourceEntity(textNode);
                throw LayoutScriptException.Create <SyntaxException>(null, src, fmt, text, Keyword);
            }

            // Extract parameters
            foreach (XAttribute attr in Element.Attributes())
            {
                SetParameter(attr.Name.LocalName, attr.Value);
            }

            // Parse nested statements
            foreach (XElement elem in Element.Elements())
            {
                AddNestedStatement(XmlStatement.Parse(elem));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="XmlStatement"/> using the specified <see cref="XElement"/>.
        /// </summary>
        /// <param name="elem">The XML element to parse.</param>
        /// <returns>The new <see cref="XmlStatement"/> object.</returns>
        /// <exception cref="SyntaxException">
        /// Thrown if the specified <see cref="XElement"/> is malformatted
        /// (such as a text node being included inside the element).
        /// </exception>
        public static XmlStatement Parse(XElement elem)
        {
            XmlStatement stmt = new XmlStatement(elem);

            stmt.Parse();

            return(stmt);
        }