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
    def toXML(cls, xacmlAuthzDecisionQuery):
        """Create an XML representation of the input SAML Authorization
        Decision Query object

        @type xacmlAuthzDecisionQuery: saml.saml2.core.AuthzDecisionQuery
        @param xacmlAuthzDecisionQuery: SAML Authorization Decision Query
        @rtype: ElementTree.Element
        @return: Attribute Query as ElementTree XML element
        """
        if not isinstance(xacmlAuthzDecisionQuery, XACMLAuthzDecisionQuery):
            raise TypeError("Expecting %r class got %r" % (XACMLAuthzDecisionQuery, 
                                                    type(xacmlAuthzDecisionQuery)))

        if not xacmlAuthzDecisionQuery.xacmlContextRequest:
            raise AttributeError("No xacmlContextRequest has been set for the "
                                 "XACMLAuthzDecisionQuery")

        issueInstant = SAMLDateTime.toString(xacmlAuthzDecisionQuery.issueInstant)
        attrib = {
            cls.ID_ATTRIB_NAME: xacmlAuthzDecisionQuery.id,
            cls.ISSUE_INSTANT_ATTRIB_NAME: issueInstant,

            # Nb. Version is a SAMLVersion instance and requires explicit cast
            cls.VERSION_ATTRIB_NAME: str(xacmlAuthzDecisionQuery.version),
        }

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

        issuerElem = IssuerElementTree.toXML(xacmlAuthzDecisionQuery.issuer)
        elem.append(issuerElem)

        requestElem = RequestElementTree.toXML(
                                    xacmlAuthzDecisionQuery.xacmlContextRequest)
        elem.append(requestElem)

        return elem