XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Allan GravesSubject: 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?

Postnext
(Deleted User) Subject: User functions
Author: (Deleted User)
Date: 02 Feb 2005 05:10 PM
Hi Allan,
you should fully qualify the remove-zero function invocation, like this

<Clarity>{local:remove-zeros(substring($offer/Item_Number, 14,4))}</Clarity>

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.

Hope this helps,
Alberto

Postnext
Allan GravesSubject: 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>

Postnext
(Deleted User) 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

Hope this helps,
Alberto

Posttop
Allan GravesSubject: User functions
Author: Allan Graves
Date: 03 Feb 2005 09:37 AM
Thank you. Using xs:string did the trick.

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.