Represents a GraphML vertex or edge attribute parsed from a GraphML file.
This class is used by GraphMLGraphAdapter while it is parsing a GraphML file.

In GraphML, a "key" XML node defines an edge or vertex attribute, which GraphML calls a "Graph-ML attribute," and a "data" XML node specifies the GraphML-attribute's value for a specific vertex or edge. The constructor parses the "key" XML node, and the GetAttributeValue parses a "data" XML node. provides a default value for the GraphML-attribute, if one was specified.

NodeXL doesn't support the for="graph" or for="all" attribute values allowed by the GraphML specification. The caller should filter out such "key" XML nodes before using this class to parse them.

상속: Object
예제 #1
0
        ParseGraphMLAttributeDefinitions
        (
            XmlNode oGraphMLXmlNode,
            XmlNamespaceManager oXmlNamespaceManager
        )
        {
            Debug.Assert(oGraphMLXmlNode != null);
            Debug.Assert(oXmlNamespaceManager != null);
            AssertValid();

            Dictionary <String, GraphMLAttribute> oGraphMLAttributeDictionary =
                new Dictionary <String, GraphMLAttribute>();

            // Read the GraphML-attribute nodes.

            foreach (XmlNode oKeyXmlNode in oGraphMLXmlNode.SelectNodes(
                         GraphMLPrefix + ":key[@for='node' or @for='edge']",
                         oXmlNamespaceManager))
            {
                GraphMLAttribute oGraphMLAttribute =
                    new GraphMLAttribute(oKeyXmlNode, oXmlNamespaceManager,
                                         GraphMLPrefix);

                String sID = oGraphMLAttribute.ID;

                try
                {
                    oGraphMLAttributeDictionary.Add(sID, oGraphMLAttribute);
                }
                catch (ArgumentException)
                {
                    throw new XmlException(
                              "The key id \"" + sID + "\" exists for two keys.  Key id"
                              + " values must be unique."
                              );
                }
            }

            return(oGraphMLAttributeDictionary);
        }
    ParseGraphMLAttributeDefinitions
    (
        XmlNode oGraphMLXmlNode,
        XmlNamespaceManager oXmlNamespaceManager
    )
    {
        Debug.Assert(oGraphMLXmlNode != null);
        Debug.Assert(oXmlNamespaceManager != null);
        AssertValid();

        Dictionary<String, GraphMLAttribute> oGraphMLAttributeDictionary =
            new Dictionary<String, GraphMLAttribute>();

        // Read the GraphML-attribute nodes.

        foreach ( XmlNode oKeyXmlNode in oGraphMLXmlNode.SelectNodes(
            GraphMLPrefix + ":key[@for='node' or @for='edge']",
            oXmlNamespaceManager) )
        {
            GraphMLAttribute oGraphMLAttribute =
                new GraphMLAttribute(oKeyXmlNode, oXmlNamespaceManager,
                    GraphMLPrefix);

            String sID = oGraphMLAttribute.ID;

            try
            {
                oGraphMLAttributeDictionary.Add(sID, oGraphMLAttribute);
            }
            catch (ArgumentException)
            {
                throw new XmlException(
                    "The key id \"" + sID + "\" exists for two keys.  Key id"
                    + " values must be unique."
                    );
            }
        }

        return (oGraphMLAttributeDictionary);
    }
    CreateGraphMLAttribute
    (
        Boolean bIsForVertex,
        String sAttributeType,
        String sDefaultAttributeValue
    )
    {
        XmlElement oKeyXmlNode = CreateKeyXmlNode(bIsForVertex,
            sAttributeType);

        if (sDefaultAttributeValue != null)
        {
            XmlElement oDefaultXmlNode = m_oXmlDocument.CreateElement(
                "default", GraphMLGraphAdapter.GraphMLNamespaceUri);

            oDefaultXmlNode.InnerText = sDefaultAttributeValue;

            oKeyXmlNode.AppendChild(oDefaultXmlNode);
        }

        m_oGraphMLAttribute = new GraphMLAttribute(oKeyXmlNode,
            m_oXmlNamespaceManager, GraphMLPrefix);

        return (m_oGraphMLAttribute);
    }