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
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext 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.

 
Go to previous topicPrev TopicGo to next topicNext Topic
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.