<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"):
 """Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable):
 The namespaces to include in the constructed attribute value. If None, all are included. sort (bool):
 Whether the sort the namespace URIs. delim (str):
 The delimiter to use between namespace/schemaloc *pairs*. Returns: str: A schemalocation attribute in the format: """

        if not ns_uris:
            ns_uris = six.iterkeys(self.__ns_uri_map)

        if sort:
            ns_uris = sorted(ns_uris)

        schemalocs = []

        for ns_uri in ns_uris:
            ni = self.__lookup_uri(ns_uri)

            if ni.schema_location:
                schemalocs.append("{0.uri} {0.schema_location}".format(ni))

        if not schemalocs:
            return ""

        return 'xsi:schemaLocation="{0}"'.format(delim.join(schemalocs))