|
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
|
|
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>
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
guest |