If we encounter those in XSD files, shouldn't we include the XSDs for these namespaces as well?
If in an XSD schema document we encounter a namespace declaration for a namespace N, one of the following will be the case:
- It's the XSD namespace and the prefix declared used on elements in the schema.
- It's the target namespace of the current schema document and the prefix declared is used in references to types, elements, attributes, etc. in the target namespace.
- It's not the target namespace and is used in references to elements, types, attributes, etc.
- It's not used in references to (the schema declarations of) elements, types, attributes, etc., but it is the namespace of some element or attribute used in the schema document itself (e.g. inside an xsd:annotation element, or as a foreign-namespace attribute on an XSD element).
- It's not used in the schema document at all.
If we are seeking to collect a set of schema documents sufficient for validating the elements, attributes, and types defined in the current schema document (or, more or less equivalently, the set of schema documents referred to directly or indirectly, explicitly or implicitly, from the current schema document), then:
- Case 1 is irrelevant: the schema for the XSD namespace is built in to every conforming XSD validator and need not be collected.
- Case 2 requires that we collect the schema document we are currently reading. (Presumably we already knew that, or else why were we reading it in the first place?)
- In case 3, either there is an xsd:import for the namespace, in which case it will be taken care of when we process xsd:import elements, or else there is no such import, in which case the current schema document is non-conforming and will raise an error when a conforming schema processors tries to construct a schema from it.
- In case 4, the namespace is used in the current schema document (e.g. in an HTML passage contained in the xsd:documentation element); we will need a schema document for that namespace if we want to validate the relevant elements or attributes in the current schema document. But there is no indication that the namespace in question can or will be used in documents to be validated against this schema. The only useful indication that it could be used in those documents would be an xsd:import element.
- In case 5, the namespace declaration is cruft and serves no discernible purpose. (It may be part of a schema document template used in an organization because the namespace in question is often used in the organization's schema documents -- my schema documents usually declare a prefix for the XHTML namespace -- but not used in this particular schema document for whatever reason.) No schema documents for this namespace need to be collected.
In the sample document you give, there are four namespace declarations. One falls into case 1:
xmlns:xs="http://www.w3.org/2001/XMLSchema"
One falls into case 2:
xmlns:mcpttgi="urn:3gpp:ns:mcpttGroupInfo:1.0"
Two fall into case 3 (or possibly case 5), and for these there are also xsd:import instructions:
xmlns:oxe="urn:oma:xml:xdm:extensions"
xmlns:rl="urn:ietf:params:xml:ns:resource-lists"
If we drove our collection policy by namespace declarations instead of xsd:import and xsd:include instructions, the difference here would be that we (a) add the schema for XSD schema documents to our collection, and (b) possibly search for other available schema documents for the target namespace of the current schema document. (In some cases, that may be desirable; in others, we have different schemas for the same namespace and collecting all of them will be counterproductive because it will produce a redundant and possibly self-contradictory set of declarations.)