Fwd: [xsl] Hints on http POST

Hello oXygenistes, Over on XSL-List, Martin Honnen kindly pointed me to EXPath as a possible answer to my question regarding how to call http POST from inside XSLT (see below): he suggests the EXPath http client module. However, I find this isn't available in Saxon by default. Any ideas of how I can get this to work in oXygen? (or alternative strategies?) http://expath.org/modules/http-client/ http://expath.org/files Cheers, Wendell ---------- Forwarded message ---------- From: Martin Honnen martin.honnen@gmx.de <xsl-list-service@lists.mulberrytech.com> Date: Fri, Feb 2, 2018 at 1:06 PM Subject: Re: [xsl] Hints on http POST To: xsl-list@lists.mulberrytech.com On 02.02.2018 18:29, Wendell Piez wapiez@wendellpiez.com wrote:
I have a need to procure a little bit of XML from a web service running locally. To get it (once) from curl is easy:
curl -X POST -d "My string goes in here" localhost:8888/do/me
But I need to call it many many times, which I would naturally like to do from inside my transformation.
Does anyone have any neat hints of how to do this under unextended (or openly extended) XSLT 3.0?
I am not sure how exactly that HTTP POST that curl produces looks like but http://expath.org/modules/http-client/ allows HTTP POST requests. --~---------------------------------------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/174322 or by email: xsl-list-unsub@lists.mulberrytech.com --~-- -- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^

Hi Wendell, I do not have much experience with EXpath, at some point I tried to make it work in order to help somebody and I detailed the installation steps here: https://www.oxygenxml.com/forum/post34427.html Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 2/2/2018 8:33 PM, Wendell Piez wrote:
Hello oXygenistes,
Over on XSL-List, Martin Honnen kindly pointed me to EXPath as a possible answer to my question regarding how to call http POST from inside XSLT (see below): he suggests the EXPath http client module.
However, I find this isn't available in Saxon by default.
Any ideas of how I can get this to work in oXygen? (or alternative strategies?)
http://expath.org/modules/http-client/ http://expath.org/files
Cheers, Wendell
---------- Forwarded message ---------- From: Martin Honnen martin.honnen@gmx.de <xsl-list-service@lists.mulberrytech.com> Date: Fri, Feb 2, 2018 at 1:06 PM Subject: Re: [xsl] Hints on http POST To: xsl-list@lists.mulberrytech.com
On 02.02.2018 18:29, Wendell Piez wapiez@wendellpiez.com wrote:
I have a need to procure a little bit of XML from a web service running locally. To get it (once) from curl is easy:
curl -X POST -d "My string goes in here" localhost:8888/do/me
But I need to call it many many times, which I would naturally like to do from inside my transformation.
Does anyone have any neat hints of how to do this under unextended (or openly extended) XSLT 3.0?
I am not sure how exactly that HTTP POST that curl produces looks like but http://expath.org/modules/http-client/ allows HTTP POST requests.
--~---------------------------------------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/174322 or by email: xsl-list-unsub@lists.mulberrytech.com --~--

Awesome, thanks Radu. Cheers, Wendell On Tue, Feb 6, 2018 at 2:41 AM, Oxygen XML Editor Support (Radu Coravu) <support@oxygenxml.com> wrote:
Hi Wendell,
I do not have much experience with EXpath, at some point I tried to make it work in order to help somebody and I detailed the installation steps here:
https://www.oxygenxml.com/forum/post34427.html
Regards, Radu
Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com
On 2/2/2018 8:33 PM, Wendell Piez wrote:
Hello oXygenistes,
Over on XSL-List, Martin Honnen kindly pointed me to EXPath as a possible answer to my question regarding how to call http POST from inside XSLT (see below): he suggests the EXPath http client module.
However, I find this isn't available in Saxon by default.
Any ideas of how I can get this to work in oXygen? (or alternative strategies?)
http://expath.org/modules/http-client/ http://expath.org/files
Cheers, Wendell
---------- Forwarded message ---------- From: Martin Honnen martin.honnen@gmx.de <xsl-list-service@lists.mulberrytech.com> Date: Fri, Feb 2, 2018 at 1:06 PM Subject: Re: [xsl] Hints on http POST To: xsl-list@lists.mulberrytech.com
On 02.02.2018 18:29, Wendell Piez wapiez@wendellpiez.com wrote:
I have a need to procure a little bit of XML from a web service running locally. To get it (once) from curl is easy:
curl -X POST -d "My string goes in here" localhost:8888/do/me
But I need to call it many many times, which I would naturally like to do from inside my transformation.
Does anyone have any neat hints of how to do this under unextended (or openly extended) XSLT 3.0?
I am not sure how exactly that HTTP POST that curl produces looks like but http://expath.org/modules/http-client/ allows HTTP POST requests.
--~---------------------------------------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/174322 or by email: xsl-list-unsub@lists.mulberrytech.com --~--
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user
-- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^

On Fri, Feb 02, 2018 at 01:33:15PM -0500, Wendell Piez wrote:
Hello oXygenistes,
Over on XSL-List, Martin Honnen kindly pointed me to EXPath as a possible answer to my question regarding how to call http POST from inside XSLT (see below): he suggests the EXPath http client module.
On 02.02.2018 18:29, Wendell Piez wapiez@wendellpiez.com wrote:
I have a need to procure a little bit of XML from a web service running locally. To get it (once) from curl is easy:
curl -X POST -d "My string goes in here" localhost:8888/do/me
But I need to call it many many times, which I would naturally like to do from inside my transformation.
Does anyone have any neat hints of how to do this under unextended (or openly extended) XSLT 3.0?
However, I find this isn't available in Saxon by default.
Any ideas of how I can get this to work in oXygen? (or alternative strategies?)
Does it really need to be called in the transformation or just triggered at the same time? If the latter, then any ant script can call an external command, including a shell script or other tool. In which case, pick your favourite scripting language. If it needs tighter integration with oXygen, but you don't want to use Java (fair enough), then any language that can run on the same JVM will work; Jython, Clojure, etc. The protestations against my use of a site-wide JDK with oXygen in a previous thread notwithstanding, that sort of thing does make it a lot easier to do things like launch Jython in the same JVM as oXygen and run, for instance, something like this: Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_162 Type "help", "copyright", "credits" or "license" for more information.
import requests url = "https://www.oxygenxml.com" r = requests.get(url) /Library/Java/Jython/jython2.7.0_jdk1.8.0/Lib/site-packages/requests/packages/urllib3/util/ssl_.py:84: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarn.... warnings.warn( r.url u'https://www.oxygenxml.com/' r.headers {'date': 'Sat, 10 Feb 2018 18:36:41 GMT', 'server': 'Apache/2.4.18 (Ubuntu)', 'content-length': '13402', 'vary': 'Accept-Encoding', 'content-encoding': 'gzip', 'strict-transport-security': 'max-age=31536000;', 'keep-alive': 'timeout=10, max=500', 'connection': 'Keep-Alive', 'content-type': 'text/html; charset=UTF-8'} dir(r) ['__attrs__', '__bool__', '__class__', '__delattr__', '__dict__', '__doc__', '__ensure_finalizer__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__str__', '__subclasshook__', '__weakref__', '_content', '_content_consumed', 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'elapsed', 'encoding', 'headers', 'history', 'is_permanent_redirect', 'is_redirect', 'iter_content', 'iter_lines', 'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason', 'request', 'status_code', 'text', 'url'] r.status_code 200 r.content.splitlines()[0].replace('><', '>><<').split('><')[18] '<title>XML Editor</title>' print(r.content.splitlines()[0].replace('><', '>><<').split('><')[18]) <title>XML Editor</title>
Ignore the security warning, it's due to Java and the JVM being what they are. Other languages might not mention issues like that, but they're still present. Oh, yes, it is possible to install Jython into oXygen with a built-in JRE, but it's a lot more annoying and it increases the application's install size by however big Jython and all the modules you need to add really is (at least 100MB or more). I did it once or twice to prove it could be done and then left it alone. The same is likely to be true of any of the other JVM friendly languages. Still, given how useful requests is for all web stuff, especially playing with APIs and how easy it makes POSTs, plus Jython with pip can install requests straight from PyPI ... the answer to your entire problem is basically above with just a few slight variations and which are well documented all over the Net (i.e. requests.post(url, params=assorted_stuff), where assorted_stuff is a dict containing whatever you need in there). You could probably even make it play with oXygen's GUI interface, but that's *far* more effort than this example needs. Regards, Ben
participants (3)
-
Ben McGinnes
-
Oxygen XML Editor Support (Radu Coravu)
-
Wendell Piez