In programming languages, I'm used to
namespace foo
{
namespace bar
{
void DoIt()
{
}
}
}
int main()
{
foo::bar::DoIt()
}
In a schema(xsd), I'd like to do similar things when defining complexTypes
<xsd:schema targetNamespace="http://www.stackoverflow.com/foo">
<xsd:complexType name="bar1">
...
</xsd:complexType>
<xsd:complexType name="bar2">
</xsd:complexType>
...
<xsd:complexType name="foo1" type = "bar1">
...
</xsd:complexType>
</xsd:schema>
Conceptually I would like bar1 and bar2 to be nested in a http://www.stackoverflow.com/foo::bar namespace (:: borrowed from C++). I've seen examples of what seems to be a completely second namespace defined for the bar stuff. In these examples, the bar stuff will be defined in a second namespace, "http://www.stackoverflow.com/foo/bar", as in the example below. This is the closest I've seen to a "nested" namespace.
So one thing I can kind of do is import the bar stuff from a different schema
<xsd:schema targetNamespace="http://www.stackoverflow.com/foo"
xmlns:bar = "http://www.stackoverflow.com/foo/bar">
<xsd:schema namespace="http://www.stackoverflow.com/foo/bar"
<xsd:complexType name="foo1">
<xsd:element name="bar1Instance" type="bar:bar1"/>
...
</xsd:complexType>
</xsd:schema>
Part of this is that I'm just trying to grok how namespaces are different in XML vs say C++. Is there a concept of nested namespaces in XML or is each namespace independent? How is the concept of nested namespaces implemented or typically done? Is it done like my example above? Are namespaces completely independent or is there anyway of creating a nesting relationship?