def fromXML(cls, elem):
        if not ElementTree.iselement(elem):
            raise TypeError("Expecting %r input type for parsing; got %r" %
                            (ElementTree.Element, elem))

        if QName.getLocalPart(elem.tag) != cls.DEFAULT_ELEMENT_LOCAL_NAME:
            raise XMLTypeParseError("No \"%s\" element found" %
                                    cls.DEFAULT_ELEMENT_LOCAL_NAME)

        authzDecisionStatement = XACMLAuthzDecisionStatement()

        for childElem in elem:
            localName = QName.getLocalPart(childElem.tag)
            if localName == Response.ELEMENT_LOCAL_NAME:
                # Create XACML context request from Response element.
                authzDecisionStatement.xacmlContextResponse = \
                    ResponseElementTree.fromXML(childElem)

            elif localName == Request.ELEMENT_LOCAL_NAME:
                # Create XACML context request from Request element.
                authzDecisionStatement.xacmlContextRequest = \
                    RequestElementTree.fromXML(childElem)

            else:
                raise XMLTypeParseError("Unrecognised XACMLAuthzDecisionQuery child "
                                        "element \"%s\"" % localName)

        return authzDecisionStatement
    def toXML(cls, xacmlAuthzDecisionStatement):
        if not isinstance(xacmlAuthzDecisionStatement,
                          XACMLAuthzDecisionStatement):
            raise TypeError("Expecting %r class got %r" %
                            (XACMLAuthzDecisionStatement, 
                            type(xacmlAuthzDecisionStatement)))

        if not xacmlAuthzDecisionStatement.xacmlContextResponse:
            raise AttributeError("No xacmlContextResponse has been set for the "
                                 "XACMLAuthzDecisionStatement")

        tag = str(QName.fromGeneric(cls.DEFAULT_ELEMENT_NAME))
        elem = etree.makeEtreeElement(tag, cls.DEFAULT_ELEMENT_NAME.prefix,
                                      cls.DEFAULT_ELEMENT_NAME.namespaceURI)

        xacmlContextResponseElem = ResponseElementTree.toXML(
                            xacmlAuthzDecisionStatement.xacmlContextResponse)
        elem.append(xacmlContextResponseElem)

        if xacmlAuthzDecisionStatement.xacmlContextRequest:
            xacmlContextRequestElem = RequestElementTree.toXML(
                                xacmlAuthzDecisionStatement.xacmlContextRequest)
            elem.append(xacmlContextRequestElem)

        return elem