473,782 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help requested: XML / XSD confusion - "prefix must resolve to a namespace" exception...

Hi
I am trying to use datatypes defined in xml file to check correctness
of input parameter values
To define needed datatypes following schema.xml file was created:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:pd="uri:m yUri.com">
<xsd:simpleTy pe name="pd:width" >
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="4"/>
<xsd:minInclusi ve value="20"/>
<xsd:maxInclusi ve value="2000"/>
</xsd:restriction >
</xsd:simpleType>
<xsd:simpleTy pe name="pd:height ">
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="4"/>
<xsd:minInclusi ve value="20"/>
<xsd:maxInclusi ve value="2000"/>
</xsd:restriction >
</xsd:simpleType>
</xsd:schema>

When I'm trying to run program with types of parameters set to
pd:height and pd:width I get following exception:

org.apache.xpat h.domapi.XPathS tylesheetDOM3Ex ception: Prefix must
resolve to a namespace: xsd

When I'm defining parameter types to be xsd:PositiveInt eger, everything
works fine
But if I only try to use prefix pd: I get that exception.

I went through stack trace but that led me nowhere...
I've used google, read quite a bit, but got to no satisfying
conclusions...
I'm new to xml, and got quite confused
Please help ^^

Sep 4 '06 #1
6 20826
In article <11************ ********@m73g20 00cwd.googlegro ups.com>,
Thea <mo************ ***@gmail.comwr ote:
><?xml version="1.0"?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:pd="uri:m yUri.com">
<xsd:simpleTy pe name="pd:width" >
That's not how you define types. You specify a targetNamespace on
the schema element, and then use unprefixed values in "name" attributes.

-- Richard
Sep 4 '06 #2
That's not how you define types. You specify a targetNamespace on
the schema element, and then use unprefixed values in "name" attributes.
Not sure if I understood corrrectly...
something like:
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:pd="uri:m yUri.com" targetNamespace ="uri:myUri.com ">
and then:
<xsd:simpleTy pe name="width">
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="4"/>
<xsd:minInclusi ve value="20"/>
<xsd:maxInclusi ve value="2000"/>
</xsd:restriction >
</xsd:simpleType>
?

Such code helped a tiny bit...
To be precize changed previous exception into
java.lang.NullP ointerException : XPath query: *[@name='pd:posit iveInt']
failed.
I'm using third party library that actually gets data using
cachedXPath.eva l(contextNode, query, namespaceNode);
or
XPathAPI.eval(c ontextNode, query, namespaceNode);
(depending if there is anything cached)
Independent which eval is used, it returns empty nodeset.
Not null, but empty nodeset, to which library reacts by sending null
upwards...
And whole code to crash...
Is there something about XPath I should know and didn't stumble upon
while googling?

Sep 5 '06 #3
In article <11************ ********@e3g200 0cwe.googlegrou ps.com>,
Thea <mo************ ***@gmail.comwr ote:
>To be precize changed previous exception into
java.lang.Null PointerExceptio n: XPath query: *[@name='pd:posit iveInt']
failed.
That doesn't appear to have anything to do with schemas. You haven't
shown us the document you're querying, so I can't tell what the problem
is.

-- Richard
Sep 5 '06 #4
Whole document I'm using is:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:pd="uri:m yUri.com" targetNamespace ="uri:myUri.com ">
<xsd:simpleTy pe name="positiveI nt">
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="5"/>
</xsd:restriction >
</xsd:simpleType>
<xsd:simpleTy pe name="width">
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="4"/>
<xsd:minInclusi ve value="20"/>
<xsd:maxInclusi ve value="2000"/>
</xsd:restriction >
</xsd:simpleType>
<xsd:simpleTy pe name="height">
<xsd:restrictio n base="xsd:posit iveInteger">
<xsd:maxLengt h value="4"/>
<xsd:minInclusi ve value="20"/>
<xsd:maxInclusi ve value="2000"/>
</xsd:restriction >
</xsd:simpleType>
</xsd:schema>
That's about it... three datatypes defined :)

Sep 5 '06 #5
In article <ed***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>>java.lang.Nul lPointerExcepti on: XPath query: *[@name='pd:posit iveInt']
failed.
I take it from your other message that you are querying the schema
document itself. In the schema you have

<xsd:simpleTy pe name="positiveI nt">

So you need to change your XPath to

*[@name='positive Int']

because you don't have "pd:" on it any more.

-- Richard
Sep 5 '06 #6

Richard Tobin napisal(a):
In article <ed***********@ pc-news.cogsci.ed. ac.uk>,
Richard Tobin <ri*****@cogsci .ed.ac.ukwrote:
>java.lang.Null PointerExceptio n: XPath query: *[@name='pd:posit iveInt']
failed.

I take it from your other message that you are querying the schema
document itself. In the schema you have

<xsd:simpleTy pe name="positiveI nt">

So you need to change your XPath to

*[@name='positive Int']

because you don't have "pd:" on it any more.

-- Richard
Thanks, that solved this particular problem.

Now I'm back to 'prefix must resolve to a namespace' stuff, but...
In heap of messages issued by third party library I noticed debugging
statement like:

xmnls: null = http://www.w3.org/2001/XMLSchema

and in schema it says
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema" (...)>

I know that thing uses 'lookupPrefix' method from org.w3c.dom.Nod e
class.
Shouldn't it return 'xsd' prefix?

Sep 6 '06 #7

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

Similar topics

6
5495
by: nico | last post by:
In my python scripts, I use a lot of accented characters as I work in french. In order to do this, I put the line # -*- coding: UTF-8 -*- at the beginning of the script file. Then, when I need to store accented characters in a string, I used to prefix the literal string with 'u', like this: mystring = u"prénom" But if I understand well, prefixing a unicode string literal with 'u'
5
1952
by: cppaddict | last post by:
It is typical to put the line: using namespace std; at the top of a file which makes use of std library objects. To take a simple example: #include <iostream> using namespace std;
1
6413
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32 Debug-------------------- Linking... icarus_camera.obj : error LNK2001: unresolved external symbol _dgels_ icarus_leastsquares.obj : error LNK2001: unresolved external symbol _dgels_ icarus_maths.obj : error LNK2001: unresolved external symbol _dgels_...
5
10012
by: SenthilSS | last post by:
My application produces XML Data files which have XML namespace qualified XML elements (nodes), but the namespace itself is not declared in the data file. My task is to read these data files in a C# app for viewing purposes. I am using "XmlDocument" and "DataSet" for displaying the XML data in the Data grid. Problem: If I add the Namespace declaration to the data file itself (by manually opening the file and adding a new Root element...
3
2429
by: beta | last post by:
Hello everyone, I need some help here. If anyone has encountered this, knidly give me your advice. I have a command button (Command0) and a listbox (List1). Upon clicking the command button, I want my listbox to be populated. Please look at the code below. The fields Day2 and Filename are both text fields. My problem is that Day2 field has rows with the text value "N/A" (without the quotes). MS Access is evaluating the "/" sign in
0
2988
by: maxim mat | last post by:
Hi I need to build client for web service. But when I'm using Visual Studio .NET to add Web Reference, I get error: "Custom tool error: Unable to import WebService/Schema. Unable to import binding 'controllerSoapBinding' from namespace 'http://Bla-Bla-Bla'. Unable to import operation 'getClient'. The datatype 'Array' is missing. " Some problem when I try to use wsdl.exe tool in .NET. I get: Schema validation warning: Type 'cww:Class' is...
7
1939
by: Jeff Lynn | last post by:
Help! I recently upgraded my VS V6 to VS 2005 and was unable to build projects that were perfectly ok under VS V6. Where VS 2005 fails was in the linker resolving external DLLs, which are Open Source DLLs like "log4Cxx" and "Xerces C++" DLL libraries. VS 2005 converted my projects without any problem. Even the proper lib includes and lib path were captured. But its linker just unable to resolve the C++ function references.
3
3062
by: raghunadhs | last post by:
Hi all, i have developed a ".dll" in vc++, regarding to find out CRC32. and in my V.B 6.0 application i am calling that .dll. If i run my v.b application it is working means.. i am able to find crc also. where as if i run the .exe of my v.b application, a runtime error is coming. the error is like this.... "Unhadled exception at 0x10001045(crc32example.dll) in latest.exe 0x0000005 Access violation reading locatioln 0x0017d000" Actually i...
2
16454
by: shalong | last post by:
Hi all, VS 2008 is complaining that HttpWebRequest class is not in System.Net namespace I have referenced System.Net and have coded "using System.Net" I think its a setup problem rather than a coding error The type or namespace name 'HttpWebRequest' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) C:\Documents and Settings\user\My Documents\Visual Studio...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
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
10143
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...
0
9939
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...
0
6729
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
5375
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...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
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.