Handling ResourceNotFound or other exceptions non-fatally?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Handling ResourceNotFound or other exceptions non-fatally?

Jeff Jones
I'm trying to use the XPath doc() function to request a snippet of XHTML
from an external resource (via HTTP) and insert it into an XHTML page
I'm generating with OPS 3.0. I can't guarantee, though, that that HTTP
request will always succeed. When it fails, I don't want to give up on
the page; I just want to ignore the error and deliver the document
without the include. How can I do this with OPS?

I can write a separate pipeline to make the request if necessary, or use
XInclude if its error handling is more flexible; I'm not wedded to
doc(). My first thought was to test with doc-available(), but even if it
would work, I see in the Saxon docs that it wasn't implemented until
8.4. Do I have any other options?

</Jeff>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Handling ResourceNotFound or other exceptions non-fatally?

Erik Bruchez
Administrator
Jeff Jones wrote:
> I'm trying to use the XPath doc() function to request a snippet of XHTML
> from an external resource (via HTTP) and insert it into an XHTML page
> I'm generating with OPS 3.0. I can't guarantee, though, that that HTTP
> request will always succeed. When it fails, I don't want to give up on
> the page; I just want to ignore the error and deliver the document
> without the include. How can I do this with OPS?

Ideally, I think, with exception handling in XPL. Currently, there is
none, but there is a possibility that this will be implemented in the
future. As a temporary hack, you can use the oxf:exception-catcher
processor:

<p:processor name="oxf:exception-catcher">
     <p:input name="data" href="#the-output-of-the-stylesheet"/>
     <p:output name="data" id="ouput-or-exception-document"/>
</p:processor>

> I can write a separate pipeline to make the request if necessary, or use
> XInclude if its error handling is more flexible; I'm not wedded to
> doc(). My first thought was to test with doc-available(), but even if it
> would work, I see in the Saxon docs that it wasn't implemented until
> 8.4. Do I have any other options?

The XInclude processor does not yet implement xi:fallback, but it
should. When it does, you will be able to use that as an exception
mechanism to retrieve HTTP resources, although you won't have any detail
of exactly what went wrong.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Handling ResourceNotFound or other exceptions non-fatally?

Ryan Puddephatt
Erik,
    Is there any documentation on this exception catcher? How would it
be implemented into a pipeline?

Thanks
Ryan

Erik Bruchez wrote:

> Jeff Jones wrote:
>
>> I'm trying to use the XPath doc() function to request a snippet of
>> XHTML from an external resource (via HTTP) and insert it into an
>> XHTML page I'm generating with OPS 3.0. I can't guarantee, though,
>> that that HTTP request will always succeed. When it fails, I don't
>> want to give up on the page; I just want to ignore the error and
>> deliver the document without the include. How can I do this with OPS?
>
>
> Ideally, I think, with exception handling in XPL. Currently, there is
> none, but there is a possibility that this will be implemented in the
> future. As a temporary hack, you can use the oxf:exception-catcher
> processor:
>
> <p:processor name="oxf:exception-catcher">
>     <p:input name="data" href="#the-output-of-the-stylesheet"/>
>     <p:output name="data" id="ouput-or-exception-document"/>
> </p:processor>
>
>> I can write a separate pipeline to make the request if necessary, or
>> use XInclude if its error handling is more flexible; I'm not wedded
>> to doc(). My first thought was to test with doc-available(), but even
>> if it would work, I see in the Saxon docs that it wasn't implemented
>> until 8.4. Do I have any other options?
>
>
> The XInclude processor does not yet implement xi:fallback, but it
> should. When it does, you will be able to use that as an exception
> mechanism to retrieve HTTP resources, although you won't have any
> detail of exactly what went wrong.
>
> -Erik
>
>------------------------------------------------------------------------
>
>
>--
>You receive this message as a subscriber of the [hidden email] mailing list.
>To unsubscribe: mailto:[hidden email]
>For general help: mailto:[hidden email]?subject=help
>ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>  
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Handling ResourceNotFound or other exceptions non-fatally?

Erik Bruchez
Administrator
Ryan,

There is currently no documentation about this, because we feel
exception handling in XPL is the way to go.

You use this processor as shown below: just hook its "data" input to the
output that can cause an exception when reading it, and its "data"
output will either contain the document read, or an exception document
in the format returned by the exception generator (which you can look at
just by producing an exception).

-Erik

Ryan Puddephatt wrote:

> Erik,
>    Is there any documentation on this exception catcher? How would it be
> implemented into a pipeline?
>
> Thanks
> Ryan
>
> Erik Bruchez wrote:
>
>> Jeff Jones wrote:
>>
>>> I'm trying to use the XPath doc() function to request a snippet of
>>> XHTML from an external resource (via HTTP) and insert it into an
>>> XHTML page I'm generating with OPS 3.0. I can't guarantee, though,
>>> that that HTTP request will always succeed. When it fails, I don't
>>> want to give up on the page; I just want to ignore the error and
>>> deliver the document without the include. How can I do this with OPS?
>>
>>
>>
>> Ideally, I think, with exception handling in XPL. Currently, there is
>> none, but there is a possibility that this will be implemented in the
>> future. As a temporary hack, you can use the oxf:exception-catcher
>> processor:
>>
>> <p:processor name="oxf:exception-catcher">
>>     <p:input name="data" href="#the-output-of-the-stylesheet"/>
>>     <p:output name="data" id="ouput-or-exception-document"/>
>> </p:processor>
>>
>>> I can write a separate pipeline to make the request if necessary, or
>>> use XInclude if its error handling is more flexible; I'm not wedded
>>> to doc(). My first thought was to test with doc-available(), but even
>>> if it would work, I see in the Saxon docs that it wasn't implemented
>>> until 8.4. Do I have any other options?
>>
>>
>>
>> The XInclude processor does not yet implement xi:fallback, but it
>> should. When it does, you will be able to use that as an exception
>> mechanism to retrieve HTTP resources, although you won't have any
>> detail of exactly what went wrong.
>>
>> -Erik
>>
>> ------------------------------------------------------------------------
>>
>>
>> --
>> You receive this message as a subscriber of the
>> [hidden email] mailing list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>>  
>>
>
>
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws