Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > 'Attribute not allowed to appear in element' error

Reply
Thread Tools

'Attribute not allowed to appear in element' error

 
 
matt hegarty
Guest
Posts: n/a
 
      01-10-2005
Hi
I am relatively new to XML, but am having problems with a validation
issue.

When the XML is parsed and validated using Xerces, the following error
is seen:

cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is
not allowed to appear in element 'questionFeed'.

This error does not appear when the file is validated against the
schema using the XMLSpy tool. The file passes validation when the
'noNamespaceSchemaLocation' entry in the XML is removed. So I guess
the question is: how can I structure my schema so that this error is
not seen? Incidentally, the 'noNamespaceSchemaLocation' is
irrelevant in the XML - I validate programmatically.

Snippets of both schema and XML are attached:

== SCHEMA FILE ===

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="nonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="questionFeed">
<!-- snipped -->
</xs:element>
</xs:schema>


== XML FILE ===

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v5 rel. 4 U
(http://www.xmlspy.com)-->
<questionFeed xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="blah.xsd">
<pq>
<!-- snipped -->
</pq>
</questionFeed>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-10-2005


matt hegarty wrote:


> When the XML is parsed and validated using Xerces, the following error
> is seen:
>
> cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is
> not allowed to appear in element 'questionFeed'.


> <xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">


Maybe Xerces complains as you have elementFormDefault="qualified", try with
elementFormDefault="unqualified"
which seems to be what you want anyway as you do not use a target
namespace and your XML instance doesn't have a namespace on the elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-11-2005
/matt hegarty/:

> cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is
> not allowed to appear in element 'questionFeed'.


Make sure you turn namespaces support of your parser on. If you
obtain your parser instance through JAXP you should call
setNamespaceAware(true) on the parser factory instance.

--
Stanimir
 
Reply With Quote
 
mash101@talk21.com
Guest
Posts: n/a
 
      01-11-2005
Thanks for the responses.
I followed Stanimir's suggestion and this seems to have solved the
problem.

Matt

Stanimir Stamenkov wrote:
> /matt hegarty/:
>
> > cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation'

is
> > not allowed to appear in element 'questionFeed'.

>
> Make sure you turn namespaces support of your parser on. If you
> obtain your parser instance through JAXP you should call
> setNamespaceAware(true) on the parser factory instance.
>
> --
> Stanimir


 
Reply With Quote
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      01-11-2005
//:
> Stanimir Stamenkov wrote:
>> /matt hegarty/:
>>
>>> cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation'
>>> is not allowed to appear in element 'questionFeed'.

>>
>> Make sure you turn namespaces support of your parser on. If you
>> obtain your parser instance through JAXP you should call
>> setNamespaceAware(true) on the parser factory instance.

>
> I followed Stanimir's suggestion and this seems to have solved the
> problem.


Alternatively (I haven't tested it though), if you're going to
validate documents which elements doesn't have namespace, using such
XML Schema that doesn't specify 'targetNamespace', you could not
include the 'noNamespaceSchemaLocation' attribute and set the schema
location through the parser factory properties:

"Properties for enabling schema validation" in the JAXP 1.2
specification <http://java.sun.com/xml/downloads/jaxp.html>.

You could get immediate online information from:

http://java.sun.com/xml/jaxp/change-requests-12.html

--
Stanimir
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why defining a constant in a method is not allowed but usingself.class.const_set is allowed? IƱaki Baz Castillo Ruby 13 05-01-2011 06:09 PM
Msgbox Error? Text and Button Text does not appear B. J. Betts ASP .Net 2 07-24-2006 03:16 PM
Weird error - Literal content is not allowed within a 'skin file' Alan Silver ASP .Net 1 01-26-2006 10:43 PM
Error: Content is not allowed between the opening and closing tags for element Allan Ebdrup ASP .Net 0 01-26-2006 08:45 AM
VS 2005 web site web.config rejected by IIS as badly formed. "Child Nodes not allowed" error given. Eric ASP .Net 1 11-17-2005 07:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57