473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

'Attribute not allowed to appear in element' error

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 xmlns:xs="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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="blah.xsd">
<pq>
<!-- snipped -->
</pq>
</questionFeed>
Jul 20 '05 #1
4 22013


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 xmlns:xs="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/
Jul 20 '05 #2
/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
Jul 20 '05 #3
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


Jul 20 '05 #4
/ma*****@talk21.com/:
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
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
2
by: piraticman | last post by:
Hi. I have some code for a javascript jump menu... It validated with HTML 4.0 but now does not validate with XHTML strict 1.0. I have used name atributes in my code which aparantly are not...
4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
8
by: Stan Brown | last post by:
http://oakroadsystems.com/nonce/zonk.htm (12 lines) >...
4
by: Manuel Faux | last post by:
Hello! I used the "File Upload - Validator" and the result is like the following: Line 13, column 204: there is no attribute "border" ....irefox!" title="Get Firefox!" border="0" /></a></p>...
0
by: Himmat Dhange | last post by:
Hi, I am using .Net Framework 1.0 for Web service development. I use XMLValidatingReader for SOAP request validations. If request contains "encodingStyle" attribute on SOAP Envelope element...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
0
by: Aray | last post by:
Let us see the test file following: -------file nowork.xsd begin----------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
3
by: jlauman | last post by:
I'm getting an error on line 6 of the code shown below. The error is: Value 'unbounded' is not allowed for attribute 'maxOccurs' I'd appreciate any help in resolving this. Thanks, Jack ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.