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
(Deleted User) Subject: Xquery string-pad function
Author: (Deleted User)
Date: 26 Jan 2009 03:57 AM
Good morning all,

I'd like to concat two strings in an xml tag and fill out the first string with spaces up to ten positions. I think it can be done by means of a string-pad function, but how do I use it. I have added the namespace where this function is found, but it is not recognized. Here is my code:

for $Absences in collection("Synergist.dbo.Absences")/Absences
where ($Absences/Type = 205) and concat(string(year-from-dateTime($Absences/Approved)),("-"),string(month-from-dateTime($Absences/Approved)),("-"),string(day-from-dateTime($Absences/Approved)))=concat(year-from-dateTime(current-dateTime()),("-"),month-from-dateTime(current-dateTime()),("-"),day-from-dateTime(current-dateTime()))
return
<AVXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2003/05/xpath-functions">
<SONRQ>
<DTCLIENT>2006-09-21T10:51:11</DTCLIENT>
<USERID>DEMO</USERID>
<USERPASS>demo</USERPASS>
<ADMIN>NL_YR_GRD</ADMIN>
<APPID>ACCVW</APPID>
<APPVER>0701A</APPVER>
</SONRQ>
<EBUSMSGSRQ>
<EBUSTRNRQ>
<TRNUID>A1WI0N90OJ</TRNUID>
<BUSOBJ>OI5</BUSOBJ>
<ROWMODRQ>
{for $Creditor in collection("Synergist.dbo.cicmpy")/cicmpy[cmp_wwn=$Absences/CustomerID]
return
<RECID>{concat(string(normalize-space($Creditor/cmp_code)),fn:string-pad("",4))}</RECID>
}
<OI_STAT>4</OI_STAT>
<DISP_INV>.F.</DISP_INV>
</ROWMODRQ>
</EBUSTRNRQ>
</EBUSMSGSRQ>
</AVXML>

Postnext
Ivan PedruzziSubject: Xquery string-pad function
Author: Ivan Pedruzzi
Date: 26 Jan 2009 11:53 AM
See the following example

declare function local:string-pad($source as xs:string, $padCount as xs:integer, $padString as xs:string)
{
let $pad := $padCount - string-length($source)
return concat($source, string-join((for $i in 1 to $pad return $padString), ''))
};

string-join(
("'", local:string-pad("1" , 3, " "),"'&#10;",
"'", local:string-pad("12" , 3, " "),"'&#10;",
"'", local:string-pad("123", 3, " "),"'&#10;"), '')

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
(Deleted User) Subject: Xquery string-pad function
Author: (Deleted User)
Date: 26 Jan 2009 02:49 PM
Hi Ivan,

I see how this function can work, still a problem is where to place the code in my xquery. I would expect this part on the top of my file

declare function local:string-pad($source as xs:string, $padCount as xs:integer, $padString as xs:string)
{
let $pad := $padCount - string-length($source)
return concat($source, string-join((for $i in 1 to $pad return $padString), ''))
};

and then in the recid tag the function itself: local:string-pad("1" , 3, " ")

but now I get a blank file.

Can you give me another clue?

Thanks!


Cynthia

Postnext
Ivan PedruzziSubject: Xquery string-pad function
Author: Ivan Pedruzzi
Date: 26 Jan 2009 03:00 PM

Email your xquery and some sample XML data to

stylus-field-report @ progress.com

we will take a look.

Ivan Pedruzzi
Stylus Studio Team

Posttop
(Deleted User) Subject: Xquery string-pad function
Author: (Deleted User)
Date: 26 Jan 2009 04:48 PM
Hi Ivan,

Hope you haven't spent time yet on the mail I posted you, cause I now discovered why it was not working: my where clause worked yesterday, but no records are within scope today! Aaargh, looking for a mistake in the wrong section.

Thank you so much, it now works!

Cynthia

   
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.