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
Jack TanSubject: Treatment of reserved characters in text
Author: Jack Tan
Date: 01 Sep 2005 04:24 AM
I am new to XQUERY and I am trying to process large XML file containing text. Part of the text contains reserved characters such as "&". I want to remove "&" from the text. For example xml fragment has:

<label>"[(n==32) &amp;&amp; (Pmax - Pmin)&lt;20]"</label>

How "&&" can be replaced by " " using XQUERY?
Along the same line, I tried to replace selected characters using

let $answer := fn:replace($string, "[-+ <>|*]", " "]

and it almost worked, with exception of "-". To complete this I have to aply in a separate line

let $answer1 := fn:replace($answer, "-", " "]

Why fn:replace did not worked the first time?

This is probably a trivial question, and the answer must be available somewhere in www.w3.org but I could not find it.

Thx for help.

Jack

Postnext
(Deleted User) Subject: Treatment of reserved characters in text
Author: (Deleted User)
Date: 01 Sep 2005 06:58 AM
Hi Jack,
what version of Stylus are you using? I tried on version 6 Release 3,
build 377m the following XQuery:

let $string:="-aaa-",
$answer := fn:replace($string, "[-+ <>|*]", " ")
return $answer

and I got the expected " aaa " answer.

Alberto

Postnext
Jack TanSubject: Treatment of reserved characters in text
Author: Jack Tan
Date: 01 Sep 2005 12:25 PM
Alberto,

You are right, it indeed works with "-" (it must be a late night candle that blured my vision). Thanks.

Any suggestions about removal of "&" from the text?

Best regards,

Jack

Postnext
(Deleted User) Subject: Treatment of reserved characters in text
Author: (Deleted User)
Date: 01 Sep 2005 12:59 PM
Hi Jack,
you can use the fn:replace as in the previous example; you just need to keep in mind that "&" must be always represented as "&amp;", and write

$result:=fn:replace($string,"-+<> []&amp;"," ")

Hope this helps,
Alberto

Postnext
Jack TanSubject: Treatment of reserved characters in text
Author: Jack Tan
Date: 01 Sep 2005 01:48 PM
I tried this

let $rslt := fn:replace($txt, "[+()=<>|&amp*:-]"," ")

but, it comes back with an error: "Unrecognized character '"' (0x22)". Part of the expression is also highlighted red (Studio 6, rel. 3, build 377m).

So perhaps the question is: how can I enter the query so the evaluator will accept "&" as a part of string between "" rather than reserved character? Any control flags to properly configure the environment/engine?

Jack

Posttop
Tony LavinioSubject: Treatment of reserved characters in text
Author: Tony Lavinio
Date: 01 Sep 2005 05:55 PM
You used &amp but forgot the ; at the end.

   
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.