|
next
|
Subject: XQuery problem with namespaces Author: Roel van der Hoeven Date: 28 Feb 2012 03:43 AM
|
Hi,
I've got a problem to get namespaces working in a mapping I created.
I'll be getting a message which sometimes will contain the namespace ns0, and sometimes without any namespace. I tried to get this very simple QXuery to work with the namespace first, but I keep getting in the error part of the if construction.
We usually do not use namespaces and therefor I'm quite unfamiliar with them and their use. I imagine it could have something to do with the fact that we receive the input as a stream which is set to xs:untyped. If I set that to xs:anyType or xs:string I'll get the error:
Static type error. Types 'element(ns0:responseTypeCode, xs:anyType)*' and 'xs:string' are invalid argument types for binary operator '='.
Code:
declare namespace emt="http://pcs.portinfolink.nl/consignment_types";
declare namespace mct="http://pcs.portinfolink.nl/consignment_type";
declare namespace aty="http://pcs.portinfolink.nl/em_message_component_types";
declare namespace ns0="http://pcs.portinfolink.nl/schema";
declare variable $input as document-node(element(*, xs:untyped)) external;
declare option ddtek:xml-streaming 'no';
declare option ddtek:serialize 'indent=yes,omit-xml-declaration=no';
declare variable $messagePreviousReference as xs:string external;
<TechnicalAcknowledgement ns0="http://bla.com/xsd">
{
if ($input/ns0:technicalResponse/ns0:responseTypeCode = "AK")
then
(
<emt:MessageInterchange
mct:codedAction="8"
mct:interchangeControlReference="{$messagePreviousReference}"/>,
<aty:ResponseMessageWithoutFunctionalGroups>
<aty:MessageResponse
mct:codedAction="8"
mct:messageReferenceNumber="{$messagePreviousReference}"/>
</aty:ResponseMessageWithoutFunctionalGroups>
)
else
if ($input/ns0:technicalResponse/ns0:responseTypeCode = "NA")
then
(
<emt:MessageInterchange
mct:codedAction="4"
mct:interchangeControlReference="{$messagePreviousReference}"/>,
<aty:ResponseMessageWithoutFunctionalGroups>
<aty:MessageResponse
mct:codedAction="4"
mct:messageReferenceNumber="{$messagePreviousReference}"/>
</aty:ResponseMessageWithoutFunctionalGroups>
)
else
error(xs:QName("Error"), concat(" Expected values for responseTypeCode are NA or AK. Current value is: ", $input/ns0:technicalResponse/ns0:responseTypeCode))
}
</TechnicalAcknowledgement>
XML_CONTRL_IN_TA12_var.xml XML input
|
|
|