tags:

views:

90

answers:

1

Hi

If i am defining to xsd main.xsd and sub.xsd

Now if i want to import the sub.xsd into main.xsd how can i do it .

<xsd:import
namespace="http://localhost:8080/my-app";
schemaLocation="main.xsd"/>

if both are in same folder ..but i want to give a relative url how do i do it .

A: 

First i would like to say that the "SchemaLocation" attribute is decribed as 'being a hint'. There is nothing in the specification that forces the resolution of that attribute in XML parsers.

That said, if you are using a file based approach, the way to define 'in the same location' would be schemaLocation=".\main.xsd".

However, wether this will work or not depends on the specific implementation of the XML parser you are using.

If you are using .Net i would like to advise you to load both schemas into a XmlSchemaSet. This will be sufficient to validate/code-gen items using that schema set. The resolution is then done on namespace-uri.

If you are using .Net you can also attach a XmlResolver to your application that takes over the resolution of these items.

Have a look at MSDN for more details about this approach

Hope this helps,

Marvin Smit