Ejemplo n.º 1
0
        //--- Class Methods ---
        private static void AppendXmlStart(DekiScriptOutputBuffer buffer, XmlNode element) {
            string prefix = element.Prefix;
            string name = element.LocalName;
            Dictionary<string, string> namespaces = null;
            List<Tuplet<string, string, string>> attributes = null;

            // loop over all attributes
            foreach(XmlAttribute attribute in element.Attributes) {
                string attrPrefix = attribute.Prefix;
                string attrName = attribute.LocalName;
                string attrValue = attribute.Value;
                bool isNamespaceDeclaration = string.IsNullOrEmpty(attrPrefix) ? attrName.EqualsInvariant(XMLNS) : attrPrefix.EqualsInvariant(XMLNS);

                // check if attribute is a namespace declaration
                if(isNamespaceDeclaration) {

                    // add attribute to namespace declarations
                    namespaces = namespaces ?? new Dictionary<string, string>();

                    // check if the default namespace is being defined
                    if(string.IsNullOrEmpty(attrPrefix)) {
                        namespaces.Add(string.Empty, attrValue);
                    } else {
                        namespaces.Add(attrName, attrValue);
                    }
                } else {

                    // add attribute to list of attributes
                    attributes = attributes ?? new List<Tuplet<string, string, string>>();
                    attributes.Add(new Tuplet<string, string, string>(attrPrefix, attrName, attrValue));
                }
            }
            buffer.PushXmlStart(prefix, name, namespaces, attributes);
        }
Ejemplo n.º 2
0
        //--- Class Methods ---
        private static void AppendXmlStart(DekiScriptOutputBuffer buffer, XmlNode element)
        {
            string prefix = element.Prefix;
            string name   = element.LocalName;
            Dictionary <string, string>             namespaces = null;
            List <Tuplet <string, string, string> > attributes = null;

            // loop over all attributes
            foreach (XmlAttribute attribute in element.Attributes)
            {
                string attrPrefix             = attribute.Prefix;
                string attrName               = attribute.LocalName;
                string attrValue              = attribute.Value;
                bool   isNamespaceDeclaration = string.IsNullOrEmpty(attrPrefix) ? attrName.EqualsInvariant(XMLNS) : attrPrefix.EqualsInvariant(XMLNS);

                // check if attribute is a namespace declaration
                if (isNamespaceDeclaration)
                {
                    // add attribute to namespace declarations
                    namespaces = namespaces ?? new Dictionary <string, string>();

                    // check if the default namespace is being defined
                    if (string.IsNullOrEmpty(attrPrefix))
                    {
                        namespaces.Add(string.Empty, attrValue);
                    }
                    else
                    {
                        namespaces.Add(attrName, attrValue);
                    }
                }
                else
                {
                    // add attribute to list of attributes
                    attributes = attributes ?? new List <Tuplet <string, string, string> >();
                    attributes.Add(new Tuplet <string, string, string>(attrPrefix, attrName, attrValue));
                }
            }
            buffer.PushXmlStart(prefix, name, namespaces, attributes);
        }