Rongas
asked on
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
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>
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
http://www.w3schools.com/schema/schema_schema.asp
http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html
> 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
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Once you have elements in a namespace, try to have all of them in a namespace
ASKER
perfect... :-) sorry for the delay on answering
welcome
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