|
next
|
 Subject: User functions Author: Allan Graves Date: 02 Feb 2005 04:33 PM
|
Using this XQuery:
(: XQUERY to identify diamonds and display specifics in
an Affiliate XML RAW data feed file :)
declare function local:remove-zeros($data as element) as string {
let $retVal := translate($data,'0',' ')
return string($retVal)
};
<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>{remove-zeros(substring($offer/Item_Number, 14,4))}</Clarity>
</Diamond>
}
</Root>
I continue to get the following error:
Function 'remove-zeros' in namespace 'http://www.w3.org/2004/10/xpath-functions' is undefined
What am I missing?
|
next
|
 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>
}
</Root>
|
|
|
|