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 (1123)
+ Stylus Studio Technical Forum (13809)
+ Website Feedback (243)
+ XSLT Help and Discussion (7447)
- XQuery Help and Discussion (1861)
-> + Error Please Help (3)
-> - Error Please Help (1)
-> + XPath descendant question (2)
-> + java/lang/OutOfMemoryError Run... (2)
-> + Xquery key value lookup (8)
-> + Improve xQuery Performance (3)
-> + MS SQL Server - Disable order ... (10)
-> + proper use of fn:distinct-valu... (2)
-> + Ignore DTD (7)
-> - Thanks Ivan (1)
-> + Trying to get 2nd value of nod... (5)
-> + Outer joins (4)
-> + Figured Out Issues From Last P... (2)
-> + Best Way To Generate Complex X... (3)
-> + count in xquery (4)
-> + left/right presentation (3)
-> + new to stylus - connecting to ... (2)
-> + XQuery problem with namespaces (4)
-> + .conv and xquery problem (3)
-> + Can pass text into CONV file (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (361)
+ 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
Alberto MassariSubject: User functions
Author: Alberto Massari
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
Alberto MassariSubject: User functions
Author: Alberto Massari
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-2011 All Rights Reserved.