def resolve_fragment(self, document, fragment):
fragment = fragment.lstrip(u"<STR_LIT:/>")<EOL>parts = unquote(fragment).split(u"<STR_LIT:/>") if fragment else []<EOL>for part in parts:<EOL><INDENT>part = part.replace(u"<STR_LIT>", u"<STR_LIT:/>").replace(u"<STR_LIT>", u"<STR_LIT>")<EOL>if isinstance(document, Sequence):<EOL><INDENT>try:<EOL><INDENT>part = int(part)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>try:<EOL><INDENT>document = document[part]<EOL><DEDENT>except (TypeError, LookupError):<EOL><INDENT>raise exceptions.RefResolutionError(<EOL>"<STR_LIT>" % fragment<EOL>)<EOL><DEDENT><DEDENT>return document<EOL>
Resolve a ``fragment`` within the referenced ``document``.

Arguments:

    document:

        The referent document

    fragment (str):

        a URI fragment to resolve within it