xsd creation where xml has as multiple namespaces

I luck quite significant knowledge with xsd files. my question may be unclear or silly... but i need help.

i have an xml that loos as below. What i need is that the xsd that i use, allows the node's
<mx:String value="plugins"> .

But, when i try to add an element with name "mx:string" it does not let me..
I have tried to add the namespace of mx inside my xsd but could not... (if this is the correct way, lets discuss how this can be done).
I have tried to create a second xsd, that my xsd will import and use. the second xsd would have namespace mx, but this did not help either (if this is the way, lets talk on how this can be done).

Other ways? Any correct/easy and clean way?

Cheers
<plugin:Plugin>
   <properties>
      bla bla bla
   <properties>
   <toolbar>
      <mx:String value="plugins"> 
      <mx:String value="all">
       ...
   <toolbar>

Open in new window

RongasAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
Well, every namespace in your document should be the targetNamespace of a seperate schema
This implies that you need a seperate schema documument per namespace
and that you need to import the corrct bits at the right place.

It is clean but not so easy. Multiple namespace schemas are a bit advanced
I will show you an example in a minute

Can you show the namespace declarations for the prefixes? That would make the schema more ready to use for you
0
marklorenzCommented:
You have to have a namespace declared for "mx".  Check out the details here:

http://www.w3schools.com/schema/schema_schema.asp
http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html
0
Gertone (Geert Bormans)Information ArchitectCommented:
> I have tried to create a second xsd, that my xsd will import and use. the second xsd would have namespace mx

That is the correct way

See examples in the below code pane
XML
---
<?xml version="1.0" encoding="UTF-8"?>
<toolbar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="toolbar.xsd"
 xmlns:mx="urn:mx"> 
    <mx:String value="plugins"/>  
    <mx:String value="all"/> 
</toolbar>

XSD: toolbar.xsd
----------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:mx="urn:mx">
    <xs:import namespace="urn:mx" schemaLocation="mx.xsd"/>
    <xs:element name="toolbar">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="mx:String" maxOccurs="unbounded"></xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

XSD: mx.xsd
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:mx"
    xmlns:mx="urn:mx">
    <xs:element name="String">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="value"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>
</xs:schema>

Open in new window

0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Gertone (Geert Bormans)Information ArchitectCommented:
In this particular example, toolbar is in the null namespace and String is in the mx namespace,
that is not very good policy.
I suspect toolbar should be in a namespace of its own, though defaulted.

Here are some suggestions for doing that, note that quiet a bit changes
The mx schema is not repeated since it stays the same
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<toolbar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:toolbar toolbar.xsd"
    xmlns:mx="urn:mx"
    xmlns="urn:toolbar"> 
    <mx:String value="plugins"/>  
    <mx:String value="all"/> 
</toolbar>

XSD
---
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:mx="urn:mx"
    xmlns="urn:toolbar"
    targetNamespace="urn:toolbar">
    <xs:import namespace="urn:mx" schemaLocation="mx.xsd"/>
    <xs:element name="toolbar">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="mx:String" maxOccurs="unbounded"></xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
Once you have elements in a namespace, try to have all of them in a namespace
0
RongasAuthor Commented:
perfect... :-) sorry for the delay on answering
0
Gertone (Geert Bormans)Information ArchitectCommented:
welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.