IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

XQuery Execution Error: Failed to load all required documents! Options · View
og_dl
Posted: Thursday, October 31, 2013 1:49:43 PM
Rank: Newbie

Joined: 10/31/2013
Posts: 2
Hello,

I am using Altova XMLSpy Professional Edition 2012 rel. 2 sp1.

I am trying to use the XQuery functionality, but always get the following error when executing a simple XQuery file:
XQuery Execution Error: Failed to load all required documents!

Here's the content of the file:
xquery version "1.0";
<items> {
for $d in doc("c:\test\output_1204.xml")
return <item> $d//Item/ItemNo </item> }
</items>

XMLSpy finds the XQuery to be valid. I tried several variations for the parameter in doc(), e.g. I put the file into the same folder as the xquery file and of course adjusted the query to doc("output_1204.xml"), I also tried with single quotation marks. Nothing worked.

What am I missing?

Regards
vlad
Posted: Friday, November 1, 2013 9:54:21 AM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
Just tried your sample with XMLSpy 2014 - everything works like expected. Maybe you should consider to update?

In any case your sample has an error - you need { } brackets around the $d//... statement

xquery version "1.0";
<items> {
for $d in doc("c:\test\output_1204.xml")
return <item> { $d//Item/ItemNo } </item> }
</items>
og_dl
Posted: Friday, November 1, 2013 12:10:28 PM
Rank: Newbie

Joined: 10/31/2013
Posts: 2
Thanx Vlad.
Unfortunately, updating is not an option at the moment.

Can anyone tell me what this error means? Does it mean that my xml file can't be loaded? Or does it mean that some files needed for executing the query (e.g. some engine files) can't be loaded?

Regards
Jamil
Posted: Monday, November 25, 2013 6:05:43 PM
Rank: Newbie

Joined: 10/2/2007
Posts: 7
Location: USA
I understand that the original poster left out the curly braces resulting in incorrect results from the query.

However, there is a second issue with this XQuery. I am surprised that it is working at all.

fn:doc requires a URI as a parameter. The poster did not use a valid URI. How is this working at all? Here it is documented in the XQuery specification.

A valid URI, in this example, would be:

file:/C:/test/output_1204.xml
vlad
Posted: Tuesday, November 26, 2013 10:24:50 AM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
As far as I know a valid URI example would be actually file:///c:/test/output_1204.xml

But as an exception to this rule, when running under Windows, Altova engines allow pure Windows file paths too, otherwise the engine will become impossible to use for almost all Windows users who only "think" in Windows paths and have no idea how to write URIs, which follow Unix conventions

In those cases where Altova tools generate URIs for end users, for example when you assign a schema to XML file, they do it in correct URI way.
Jamil
Posted: Tuesday, November 26, 2013 2:54:40 PM
Rank: Newbie

Joined: 10/2/2007
Posts: 7
Location: USA
Okay. The bad thing about this exception is that the resulting XQuery does not follow specification. It'll work fine under Altova tools, but it will most likely fail under everything else that follows specification. Unless the user knows this, he or she will be clueless on why the XQuery is not working under other tools.

Also, under Windows 7, URIs are supported. I can enter the following in the Windows Explorer address bar or in Start|Run:

file:/C:/Temp/file.txt

The file.txt file will open in the associated application.

vlad
Posted: Tuesday, November 26, 2013 3:08:44 PM
Rank: Advanced Member

Joined: 12/13/2005
Posts: 2,856
Location: Mauritius
I can understand Altova's position: if you need to choose between whether 95% of your users are clueless and cannot use your engine and other 5% of who only might become clueless under specific conditions, then the answer is pretty straightforward.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.