(self, document, fragment)
return document
Resolve a ``fragment`` within the referenced ``document``.

        Arguments:

            document:

                The referent document

            fragment (str):

                a URI fragment to resolve within it
Resolve a ``fragment`` within the referenced ``document``.
Resolve a fragment within the referenced document .
def resolve_fragment(self, document, fragment):
        """
        Resolve a ``fragment`` within the referenced ``document``.

        Arguments:

            document:

                The referent document

            fragment (str):

                a URI fragment to resolve within it
        """

        fragment = fragment.lstrip("/")

        if not fragment:
            return document

        if document is self.referrer:
            find = self._find_in_referrer
        else:

            def find(key):
                yield from _search_schema(document, _match_keyword(key))

        for keyword in ["$anchor", "$dynamicAnchor"]:
            for subschema in find(keyword):
                if fragment == subschema[keyword]:
                    return subschema
        for keyword in ["id", "$id"]:
            for subschema in find(keyword):
                if "#" + fragment == subschema[keyword]:
                    return subschema

        # Resolve via path
        parts = unquote(fragment).split("/") if fragment else []
        for part in parts:
            part = part.replace("~1", "/").replace("~0", "~")

            if isinstance(document, Sequence):
                # Array indexes should be turned into integers
                try:
                    part = int(part)
                except ValueError:
                    pass
            try:
                document = document[part]
            except (TypeError, LookupError):
                raise exceptions.RefResolutionError(
                    f"Unresolvable JSON pointer: {fragment!r}",
                )

        return document
def resolve_fragment ( self , document , fragment ) : fragment = fragment . lstrip ( "/" ) if not fragment : return document if document is self . referrer : find = self . _find_in_referrer else : def find ( key ) : yield from _search_schema ( document , _match_keyword ( key ) ) for keyword in [ "$anchor" , "$dynamicAnchor" ] : for subschema in find ( keyword ) : if fragment == subschema [ keyword ] : return subschema for keyword in [ "id" , "$id" ] : for subschema in find ( keyword ) : if "#" + fragment == subschema [ keyword ] : return subschema # Resolve via path parts = unquote ( fragment ) . split ( "/" ) if fragment else [ ] for part in parts : part = part . replace ( "~1" , "/" ) . replace ( "~0" , "~" ) if isinstance ( document , Sequence ) : # Array indexes should be turned into integers try : part = int ( part ) except ValueError : pass try : document = document [ part ] except ( TypeError , LookupError ) : raise exceptions . RefResolutionError ( f"Unresolvable JSON pointer: {fragment!r}" , ) return document