Using the xmlns:xml namespace when validating with xsd

The xml namespace is the default namespace but sometimes you need to define it when working with xsd. The secret here is that the xml namespace only accepts one particular uri (“”). Here is an example of an xsd validation using the xml namespace:
XML to validate

<?xml version="1.0"?>
<books  xmlns=""

		xsi:schemaLocation=" xml.xsd my.xsd"

    <book xml:author="Astrid Lindgren"/>

To validate the xml:author xml we use the schema definition below (xml.xsd):

<?xml version="1.0"?>
<xs:schema xmlns:xs=""
       <xs:attribute name="author" type="xs:string"/>


Notice the “targetNamespace”

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.