tags:

views:

84

answers:

1

I have a class library that stores several XSD files. When creating an XmlSchema class in the same library, I would like to know how to get the URI to the XSD file.

The library is being deployed with a web application. Is there a way to get the URI from the web application as well?

Thanks.

A: 

The URI to the XSD schema is usually shown in the SchemaLocation="" attribute. This attribute is made of pairs of strings separated by at least one whitespace character; the first string in each pair is the NameSpace and the second string the URI to the XSD schema.

This URI can point to any location accessible to the consumers of your XML. Serving them as static files in a separate directory of the web site seems to be a good choice.

For example

<MyFancyType
  xmlns="http://www.mydomain.com/Fancy"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.mydomain.com/Fancy
  http://appserver.mydomain.com/XmlStuff/FancyTypes.xsd"
 >

  <!-- here for this class's contents -->

</MyFancyType>
mjv