Pages

Thursday, March 22, 2012

How to reference your XSD without a namespace

For instances where you don't define a specific namespace for your Schema, you can use the noNamespaceSchemaLocation attribute on your top-level element to reference your XSD like so:

<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="topic.xsd">

So, for the <topic> element, we include the xmlns:xsi attribute which points to the standard XML Schema Instance namespace, followed by the noNamespaceSchemaLocation attribute which points to your own Schema. You can put in a full path (URL) if your Schema file is in a different location than your XML file.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.