コード例 #1
0
        private void decodeSourceNode(XmlNode node, HTMLParserContext context)
        {
            if (node.Attributes != null)
            {
                foreach (XmlAttribute attribute in node.Attributes)
                {
                    AttributeProperties overridableNameAndDefaultValue = new AttributeProperties();
                    if (attribute.Value.Contains("#"))
                    {
                        string attributeValue = attribute.Value;
                        attributeValue = attributeValue.Substring(attributeValue.IndexOf("#") + 1);
                        string[] splitAttributeValues = attributeValue.Split('#'); //0 will be the name of the attribute to get from the childNode, 1 is the default value if it exists which is used if the value is not overriden in the childnode
                        if (splitAttributeValues.Length > 1)
                        {
                            overridableNameAndDefaultValue.m_overrideableAttributeName = splitAttributeValues[0];
                            overridableNameAndDefaultValue.m_defaultAttributeValue = splitAttributeValues[1];
                        }
                        else
                        {
                            overridableNameAndDefaultValue.m_overrideableAttributeName = splitAttributeValues[0];
                            overridableNameAndDefaultValue.m_defaultAttributeValue = "";
                        }
                    }
                    else
                    {
                        //This node is an override of something else so store the actual attribute value
                        overridableNameAndDefaultValue.m_overrideableAttributeName = attribute.Value;
                        overridableNameAndDefaultValue.m_defaultAttributeValue = attribute.Value;
                    }

                    m_attributes.Add(attribute.Name, overridableNameAndDefaultValue);
                }
            }
            //Should deal with inner text here that has no nodes in it. so we can replace this stuff too important for text as that is just a div

            if (node.ChildNodes != null)
            {

                foreach (XmlNode childNode in node.ChildNodes)
                {
                    m_subNodes.Add(new HTMLDefinitionNode(childNode, context));
                }
            }

            for (int counter = 0; counter < m_subNodes.Count; ++counter )
            {
                //Need to check whether subnodes are definition nodes if they are we need to copy that node and deal with the attributes of that node.
                HTMLDefinitionNode subNode = m_subNodes[counter] as HTMLDefinitionNode;
                if (context.hasDefinition(subNode.m_name))
                {
                    var newSubNode = context.getDefinitionNode(subNode.m_name).Clone(context);
                    foreach (XmlAttribute attribute in subNode.m_sourceNode.Attributes) //Still some issues here definitions in definitions are still broken
                    {
                        newSubNode.FillOutAttribute(attribute);
                        m_subNodes[counter] = newSubNode;
                    }

                }
            }
        }
コード例 #2
0
        private void decodeSourceNode(XmlNode node, HTMLParserContext context)
        {
            if (node.Attributes != null)
            {
                foreach (XmlAttribute attribute in node.Attributes)
                {
                    AttributeProperties overridableNameAndDefaultValue = new AttributeProperties();
                    if (attribute.Value.Contains("#"))
                    {
                        string attributeValue = attribute.Value;
                        attributeValue = attributeValue.Substring(attributeValue.IndexOf("#") + 1);
                        string[] splitAttributeValues = attributeValue.Split('#'); //0 will be the name of the attribute to get from the childNode, 1 is the default value if it exists which is used if the value is not overriden in the childnode
                        if (splitAttributeValues.Length > 1)
                        {
                            overridableNameAndDefaultValue.m_overrideableAttributeName = splitAttributeValues[0];
                            overridableNameAndDefaultValue.m_defaultAttributeValue = splitAttributeValues[1];
                        }
                        else
                        {
                            overridableNameAndDefaultValue.m_overrideableAttributeName = splitAttributeValues[0];
                            overridableNameAndDefaultValue.m_defaultAttributeValue = "";
                        }
                    }
                    else
                    {
                        //This node is an override of something else so store the actual attribute value
                        overridableNameAndDefaultValue.m_overrideableAttributeName = attribute.Value;
                        overridableNameAndDefaultValue.m_defaultAttributeValue = attribute.Value;
                    }

                    m_attributes.Add(attribute.Name, overridableNameAndDefaultValue);
                }
            }
            //Should deal with inner text here that has no nodes in it. so we can replace this stuff too important for text as that is just a div

            if (node.ChildNodes != null)
            {

                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if (context.hasDefinition(childNode.Name))
                    {
                        HTMLDefinitionNode defNode = context.getDefinitionNode(childNode.Name).Clone(context);
                        //Need to fill out definition node here
                        foreach (XmlAttribute attribute in defNode.SourceNode.Attributes)
                        {
                            defNode.FillOutAttribute(attribute);
                        }
                        m_subNodes.Add(defNode);
                    }
                    else
                    {
                        m_subNodes.Add(new HTMLDefinitionNode(childNode, context));
                    }
                }
            }
        }