If you don't specify the namespace prefix, the default function namespace
will be used, and by default this is the namespace for the built-in functions.
Subject:User functions Author:Allan Graves Date:02 Feb 2005 05:40 PM
Thank you for your assistance. Adding local: prior to the function call
fixed that particular problem, however, I am now receiving an XP0006 (type)
error.
I changed the function expect string data, and the call is parsing string
data. I don't know what the problem is.
----- Changed XQuery --------
(: XQUERY to identify diamonds and display specifics in
an Affiliate XML RAW data feed file :)
declare function local:remove-zeros($data as string) as string {
let $retVal := $data (: translate($data,"0"," ") :)
return string($data)
};
<Root>
{
for $offer in /ROOT/Offer
where ($offer/MD_ID = '3')
order by substring($offer/Item_Number, 1,2)
return <Diamond>
{$offer/Item_Number}
<Shape> {substring($offer/Item_Number, 1,2)} </Shape>
<Size> {substring($offer/Item_Number, 9,2)}.{substring($offer/Item_Number, 11,2)} </Size>
<Color>{substring($offer/Item_Number, 19,1)}</Color>
<Clarity>{local:remove-zeros(substring($offer/Item_Number, 14,4))}</Clarity>
</Diamond>
}
Subject:User functions Author:(Deleted User) Date:03 Feb 2005 03:27 AM
Hi Allan,
the error is generated by the fact that you defined the signature for the
user-defined function using "string" as data type. By not using a namespace
prefix, you are telling that the definition for "string" should be taken
from the default element/type namespace, that by default is empty.
So you should change the definition to be
declare function local:remove-zeros($data as xs:string) as xs:string