473,761 Members | 4,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'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:noNamespac eSchemaLocation ' 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
'noNamespaceSch emaLocation' 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 'noNamespaceSch emaLocation' is
irrelevant in the XML - I validate programmaticall y.

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"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
<xs:simpleTyp e name="nonEmptyS tring">
<xs:restricti on base="xs:string ">
<xs:minLength value="1"/>
<xs:whiteSpac e value="collapse "/>
</xs:restriction>
</xs:simpleType>
<xs:element name="questionF eed">
<!-- 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:noNamespace SchemaLocation= "blah.xsd">
<pq>
<!-- snipped -->
</pq>
</questionFeed>
Jul 20 '05 #1
4 22152


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:noNamespac eSchemaLocation ' is
not allowed to appear in element 'questionFeed'. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">


Maybe Xerces complains as you have elementFormDefa ult="qualified" , try with
elementFormDefa ult="unqualifie d"
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:noNamespac eSchemaLocation ' 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
setNamespaceAwa re(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:noNamespac eSchemaLocation ' 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
setNamespaceAwa re(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:noNamespac eSchemaLocation '
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
setNamespaceAwa re(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 'targetNamespac e', you could not
include the 'noNamespaceSch emaLocation' 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
2935
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 defined in a different namespace from the element.
2
2878
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 allowed now. I have spent all day trying to figure out a solution with no luck. I have tried document.forms and various other things but havent known exactly what to do with them and couldn't get them to work. Below I will show you my current code and...
4
21298
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. http://validator.w3.org/check?uri=http://www-thaihydro.geog.cam.ac.uk/riverslice/&ss=1&verbose=1 (e.g. see line 77) suggests that it is valid, but the spec suggests that it is not. More detail:
8
12618
by: Stan Brown | last post by:
http://oakroadsystems.com/nonce/zonk.htm (12 lines) > http://validator.w3.org/check?charset=%28detect+automatically%29&doctype=Inline&uri=http%3A%2F%2Foakroadsystems.com%2Fnonce%2Fzonk.htm&outline=x The W3C validator says "INPUT is not allowed here". I'm sure my mistake is really obvious, but I just can't see it. I'd appreciate another pair of eyes pointing out the problem. For convenience, here's the entire file. I've stripped it...
4
15786
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> You have used the attribute named above in your document, but the document type you are using does not support that attribute for this
0
1710
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 then I get following SOAP fault message The 'http://schemas.xmlsoap.org/soap/envelope/:encodingStyl e' attribute is not allowed.
10
42967
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, the XML specification seems a little ambiguous on this, so I defer to the XML authorities. Refer to sections 2.4 and 2.7 (it all hinges on if CDATA attribute values are part of markup or not.) Thanks.
0
1662
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" xmlns="http://www.bonc.com.cn" targetNamespace="http://www.bonc.com.cn" elementFormDefault="qualified"> <xs:attribute name="testAttribute" type="xs:string"/> <xs:attributeGroup name="testAttributeGroup"> <xs:attribute ref="testAttribute"/>
3
3203
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 <-- SNIP -->
0
9522
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7327
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.