Abhinav <ma************@yahoo.dot.com> wrote in message news:<P3*************@news.oracle.com>...
Zombie wrote: Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread2.arcor-online.net>...
Zombie wrote:
Can I have 2 namespaces in the same XML schema?
You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.
Do you mean to say that 1 schema file can contain only 1 namespace?
Actually, 'import' is exactly what I want to avoid. That is why in the
OP, I explicitly mentioned that I want 1 schema in 1 xsd file
containing 2 namespaces.
Any way to do that?
Does this help ?
(This is an example given to me by Zafar Abbas at the newsgroup
microsoft.public.xml. Google for "Schema - Definition for checking part of
schema?")
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:group ref = "allowAny"/>
<xs:element name="aa" />
<xs:group ref = "allowAny"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="allowAny">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" />
</xs:sequence>
</xs:group>
</xs:schema>
The following xml will be valid according to it:
<a xmlns:ns="ns">
<aa>
</aa>
<ns:bb></ns:bb>
<ns:cc></ns:cc>
</a>
Regards
Abhinav, thanks for your effort. Actually, my problem starts right
after this.
Now, I wish to come up with a second schema that will define the "bb"
and "cc" elements so that the above xml gets validated against this
new schema (bb and cc should also get validated now). As you can see,
in the xml, "bb" and "cc" are in a new namespace. So, in the new
schema too, they need to be defined in a new namespace. And that is
exactly what I am unable to do.
I hope you understand my problem.
Thanks again.