Example #1
0
    def loadFromXML(rootElement, namespace, version):
        """loadFromXML:
           Function which parses an XML and extract from it
           the definition of a rendering function
           @param rootElement: XML root of the function
           @return an instance of a function
           @throw NameError if XML invalid"""

        # Computes which type is it
        if rootElement.get("{http://www.w3.org/2001/XMLSchema-instance}type", "abstract") == "abstract":
            raise NameError("The parsed xml doesn't represent a valid type of function.")

        functionType = rootElement.get("{http://www.w3.org/2001/XMLSchema-instance}type", "abstract")
        from netzob.Common.Functions.Transformation.CustomFunction import CustomFunction

        if functionType == "netzob:" + CustomFunction.TYPE:
            return CustomFunction.loadFromXML(rootElement, namespace, version)
        else:
            raise NameError("The parsed xml doesn't represent a know type of function.")
Example #2
0
    def loadFromXML(rootElement, namespace, version):
        """loadFromXML:
           Function which parses an XML and extract from it
           the definition of a rendering function
           @param rootElement: XML root of the function
           @return an instance of a function
           @throw NameError if XML invalid"""

        # Computes which type is it
        if rootElement.get("{http://www.w3.org/2001/XMLSchema-instance}type",
                           "abstract") == "abstract":
            raise NameError(
                "The parsed xml doesn't represent a valid type of function.")

        functionType = rootElement.get(
            "{http://www.w3.org/2001/XMLSchema-instance}type", "abstract")
        from netzob.Common.Functions.Transformation.CustomFunction import CustomFunction

        if functionType == "netzob:" + CustomFunction.TYPE:
            return CustomFunction.loadFromXML(rootElement, namespace, version)
        else:
            raise NameError(
                "The parsed xml doesn't represent a know type of function.")