>  When i try to validate the xml file
> against the schema it give me a error name is not defined.

That is because.....the "name" is not defined:)
To resolve, you should

1. Provide an XML Schema with targetNamespace=http://www.sample.com/sample
that defines the
   attribute name, and import it in the sample.xsd
  <xs:import schemaLocation="http://www.sample.com/sample sample2.xsd">
or refer to it in the instance document, like:
<book mynamespace:name="XML Bible"
schemaLocation="http://www.sample.com/sample sample2.xsd"/>

2. Specify "lax" in the processContent attribute of your anyAttribute
declaration
<xs:anyAttribute namespace="##other" processContents="lax"/>

It will instruct the parser to validate the attribute if you provide the
corresonding declaration or do not validate
otherwise

Regards,
Peter A. Volchek

P.S.

> But when i tried to validate it using msxml parser no such error was
thrown.
You have found a bug in msxml :)




> 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]
>
>


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

Reply via email to