xquery error in Oxygen 10.3

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Taco Frenaij
Posts: 2
Joined: Fri Dec 18, 2009 3:30 pm

xquery error in Oxygen 10.3

Post by Taco Frenaij »

When running my xquery (see below) in Oxygen version 10.1 the results are as expected. When running the same xquery in Oxygen version 10.3 however, I get the following error:

"Required item type of value of variable $orderInput is element(*, order); supplied value has item type element({ordernamespace}order, xs:anyType)"

When I remove the vk:order in the xquery element declaration the error disappears. But of course I don’t want to remove this element type definition.

Has anyone any idea why this xquery fails in oxygen 10.3?


order.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<ord:order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ordernamespace order.xsd"
xmlns:ord="ordernamespace"
num="123">
<ord:item dept="WMN" number="557" quantity="1" />
</ord:order>


order.xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="ordernamespace" xmlns:tns="ordernamespace" targetNamespace="ordernamespace" elementFormDefault="qualified" version="1.0">
<xsd:element name="order" type="order"/>
<xsd:complexType name="order">
<xsd:sequence>
<xsd:element name="item" minOccurs="1">
<xsd:complexType>
<xsd:attribute name="number" type="xsd:integer"/>
<xsd:attribute name="dept" type="xsd:string"/>
<xsd:attribute name="quantity" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
</xsd:schema>


order.xquery:

import schema namespace vk = "ordernamespace" at "./order.xsd";

declare namespace xl = "ikBenEenNamespace";
declare namespace ord = "ordernamespace";

declare variable $orderInput as element(*,vk:order) := doc("file:///C:/taco/order.xml")/vk:order;

declare function xl:CreateItem($orderInput as element(*,vk:order))
as element(vk:item) {
$orderInput
};

xl:CreateItem($orderInput)
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Re: xquery error in Oxygen 10.3

Post by iulian_velea »

Hello,

I tested the samples in the 10.3 version of Oxygen and an error is indeed presented.
With our latest build, which is version 11.1, the XQuery can be executed correctly. However there are some changes that need to be done to the schema and to the XQuery.
The schema should declare the type of the "item" element as a top level type like this:

Code: Select all


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="ordernamespace" xmlns:tns="ordernamespace" targetNamespace="ordernamespace" elementFormDefault="qualified" version="1.0">
<xsd:element name="order" type="order"/>
<xsd:complexType name="order">
<xsd:sequence>
<xsd:element name="item" minOccurs="1" type="item"/>
</xsd:sequence>
<xsd:attribute name="num" type="xsd:integer"/>
</xsd:complexType>
<xsd:complexType name="item">
<xsd:attribute name="number" type="xsd:integer"/>
<xsd:attribute name="dept" type="xsd:string"/>
<xsd:attribute name="quantity" type="xsd:integer"/>
</xsd:complexType>
</xsd:schema>
And the xquery "xl:CreateItem" should be modified also like this:

Code: Select all


import schema namespace vk = "ordernamespace" at "./order.xsd";

declare namespace xl = "ikBenEenNamespace";
declare namespace ord = "ordernamespace";

declare variable $orderInput as element(*,vk:order) := doc("order.xml")/element(vk:order);

declare function xl:CreateItem($orderInput as element(*,vk:order))
as element(vk:item) {
$orderInput/element(vk:item)
};

xl:CreateItem($orderInput)
Note that it returns now the "item" child element of the $orderInput parameter.

The difference between the two versions of Oxygen is that a new Saxon build was included in 11.1 (Saxon 9.2.0.3).
You can download the latest Oxygen version from our download page:
http://www.oxygenxml.com/download.html
I hope that this will help you.

Best Regards,
Iulian.
Taco Frenaij
Posts: 2
Joined: Fri Dec 18, 2009 3:30 pm

Re: xquery error in Oxygen 10.3

Post by Taco Frenaij »

Thanks a lot for your response.

Since I don't have a license key for version 11, I decided to downgrade to version 10.1. With this version my xQuery runs succesfull without any changes in my xQuery and xsd.

It seems that the saxon parser in version 10.3 is the problem. Oxygen 10.3 is shipped with Saxon SA 9.1.0.7 and Oxygen 10.1 is shipped with Saxon SA 9.1.0.5

Kind regards,
Taco Frenaij.
iulian_velea
Posts: 63
Joined: Fri Dec 12, 2003 6:34 pm
Contact:

Re: xquery error in Oxygen 10.3

Post by iulian_velea »

Hello,

Please contact us at our support mailing address (support@oxygenxml.com) so we can check if you have a valid maintenance pack that could entitle you to an upgrade to version 11.1.
In the email message you should send us the license key SGN that can be found in the Help/About dialog.

Regards,
Iulian
Post Reply