Hi all,

   I having a problem with validating xml file against a schema due to some
namespace reference in the xml. I am using the <xs:anyAttribute
namespace="##other"/>     to define that a element can have any atrribute
from any other namespace. In the xml file i have attribute for this element
say mynamespace:name="XML Bible". When i try to validate the xml file
against the schema it give me a error name is not defined.

 The schema(sample.xsd) is like this

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified">
        <xs:element name="booklist">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="book"
maxOccurs="unbounded">
                                        <xs:complexType>
                                                <!-- book can have
anyattribute from another namespace -->
                                                <xs:anyAttribute
namespace="##other"/>    
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
</xs:schema>

The xml file(sample.xml) is 

<?xml version="1.0" encoding="UTF-8"?>
<booklist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:mynamespace="http://www.sample.com/sample";
xsi:noNamespaceSchemaLocation="E:\xmlfiles\sample.xsd">
        <book mynamespace:name="XML Bible"/> 
</booklist>

When i tried to run the sample program sax2print -f sample.xml

it throws me a error 

         Attribute '{http://www.sample.com/sample}name' is not declared for
element 'book'

But when i tried to validate it using msxml parser no such error was thrown.

What i am trying to define is that element book can contain any attribute
from any namespace. Is it a constraint that i should have a definition for
the attribute.

Thanks in advance
Vivekanand

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to