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)
-> ->xquery escaping ambarsand...
-> ->xquery escaping ambarsand...
-> + 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
Bruce CantorSubject: xquery escaping ambarsand when downloading delimited file
Author: Bruce Cantor
Date: 23 Aug 2022 12:08 PM
Hi

Help appreciated regarding this funny little problem:

I have created this very small xquery script that downloads a stock file from a vendor:


declare variable $ItemURL := doc(resolve-uri("../Config/config.xml", fn:static-base-uri()))/config/PowerTech/WS/@ItemURL;
declare variable $request := doc(resolve-uri("../Config/config.xml", fn:static-base-uri()))/config/PowerTech/request;

let $httpResponse := ddtek:http-get($ItemURL,$request)


return $httpResponse/response/response-body/text()

The script downloads fine, but a lot of products are made by this manufactor 'Hewlett & Packard Enterprise' and after the download I get this instead: 'Hewlett & Packard Enterprise' which is not good when the file is delimited with the character semikolon.

I tried to play with the setting response-data-type in the request but this makes no difference.

How can I make the script make a raw download, not escaping the ambersand?

This is the content of my config file:

<PowerTech>
<WS ItemURL="https://powertech-electronics.shops4ecommerce.de/shop/preislistehummer04.txt"/>
<request>
<request-header>
<header name="Authorization" value="Basic xxxx"/>
<header name="Content-Type" value="text/plain"/>
<header name="response-data-type" value="text"/>
</request-header>
</request>
</PowerTech>

kind regards
Bruce

Postnext
Ivan PedruzziSubject: xquery escaping ambarsand when downloading delimited file
Author: Ivan Pedruzzi
Date: 23 Aug 2022 02:46 PM
XQuery 's serializer default output method is XML therefore characters are escaped to make it well formed.

If your query outputs text, you need to declare the following option in the query prolog

Ivan Pedruzzi
Stylus Studio Team


declare option ddtek:serialize "method=text";

let $httpResponse := ddtek:http-get($ItemURL,$request)
return $httpResponse/response/response-body/text()


Posttop
Bruce CantorSubject: xquery escaping ambarsand when downloading delimited file
Author: Bruce Cantor
Date: 24 Aug 2022 06:24 AM
Very nice! Works like a charm. Thank you.

   
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.