Re: [Saxon-JS 2] Handling non-XML error responses
Martynas Jusevičius <martynas-tyFqBaoSXPC1Z/[email protected]> Wed, 18 Nov 2020 10:01:04 +0100
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CAE35VmxKvhWx4su5cJO+C-s0J2i_yqS7eaJEVtWMuv0GnhGZBQ@mail.gmail.com> |
Hi Debbie, any news? :) On Tue, Nov 3, 2020 at 1:23 PM Debbie Lockett <[email protected]> wrote: > > Hi Martynas, > > I will need to look into this Saxon-JS issue and investigate. It may > take me longer than usual to respond at the moment, but please bear with > me, I will try to get back to you in the next few days. > > Debbie > > On 02/11/2020 20:59, Martynas Jusevičius wrote: > > Hi, > > > > how do I handle 4xx error responses in a <ixsl:schedule-action > > http-request> callback template when the response body is not HTML? > > > > The pattern I'm using: > > > > <xsl:template name="onResponseLoad"> > > <xsl:context-item as="map(*)" use="required"/> > > > > <xsl:variable name="response" select="." as="map(*)"/> > > <xsl:choose> > > <xsl:when test="?status = 200 and ?media-type = > > ('application/rdf+xml', 'application/sparql-results+xml')"> > > <xsl:for-each select="?body"> > > <!-- do something with the XML body --> > > </xsl:for-each> > > </xsl:when> > > <xsl:otherwise> > > <!-- handle error, show $response?message --> > > </xsl:otherwise> > > </xsl:choose> > > </xsl:template> > > > > When the error response contains an HTML body, the execution never > > gets to the <xsl:otherwise> as I get an error: > > > > code: "FODC0002" > > message: "Misplaced or malformed XML: This page contains the following > > errors:error on line 1 at column 2: StartTag: invalid element > > name↵Below is a rendering of the page up to the first error." > > name: "XError" > > stack: "Error↵ at new q > > (https://localhost:4443/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.rt.js:137:273)↵ > > at parseXmlFromString > > (https://localhost:4443/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.rt.js:684:475)↵ > > at XMLHttpRequest.w.onload > > (https://localhost:4443/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.rt.js:683:79)" > > > > The responses with content type "text/html" are served by Tomcat and > > look like this: > > > > <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad > > Request</title><style type="text/css">body > > {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b > > {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 > > {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a > > {color:black;} .line > > {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP > > Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Status > > Report</p><p><b>Message</b> Bad Request</p><p><b>Description</b> The > > server cannot or will not process the request due to something that is > > perceived to be a client error (e.g., malformed request syntax, > > invalid request message framing, or deceptive request routing).</p><hr > > class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html> > > > > I'm wondering at which point is Saxon-JS attempting to parse XML from > > the response body and why does it attempt that if the content type is > > not XML? > > > > > > Martynas > > > > > > _______________________________________________ > > saxon-help mailing list archived at http://saxon.markmail.org/ > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > -- > Debbie Lockett > Saxonica > > > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help