fn:error and source URI and line number

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

fn:error and source URI and line number

max toro q
When I use fn:error it throws a DynamicError (on .NET) which has
ModuleUri and LineNumber properties that refer to the program location
where the error was raised. However, I'd like to know the URI and line
number of the document that contains the bad data that is the reason
why the error is raised. Is there a clean way to do it?

--
Max Toro

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: fn:error and source URI and line number

Michael Kay
The line number of a node in the source document is available using the saxon:line-number() extension function (like all extensions, that means it’s Saxon-PE or higher), provided that

(a) the source document was built with line numbering enabled

(b) it’s using one of the Saxon tree models (external models such as DOM and JDOM typically don’t retain line numbers).

The “URI of the document” is a more complex concept than you might imagine. The line number is relative to the “XML entity” in which it occurs, which might not be the whole document. Technically you therefore want the “system ID” property, but in most practical cases you will get the same result from base-uri() or document-uri().

Michael Kay
Saxonica


> On 26 Jun 2015, at 22:17, Max Toro <[hidden email]> wrote:
>
> When I use fn:error it throws a DynamicError (on .NET) which has
> ModuleUri and LineNumber properties that refer to the program location
> where the error was raised. However, I'd like to know the URI and line
> number of the document that contains the bad data that is the reason
> why the error is raised. Is there a clean way to do it?
>
> --
> Max Toro
>
> ------------------------------------------------------------------------------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: fn:error and source URI and line number

max toro q
Michael,
I know how to get the URI/line number, my question is, is there a
clean way to pass that info to the host application in the form of a
terminating error. Or for that matter, any other data.
--
Max Toro


On Fri, Jun 26, 2015 at 7:36 PM, Michael Kay <[hidden email]> wrote:

> The line number of a node in the source document is available using the saxon:line-number() extension function (like all extensions, that means it’s Saxon-PE or higher), provided that
>
> (a) the source document was built with line numbering enabled
>
> (b) it’s using one of the Saxon tree models (external models such as DOM and JDOM typically don’t retain line numbers).
>
> The “URI of the document” is a more complex concept than you might imagine. The line number is relative to the “XML entity” in which it occurs, which might not be the whole document. Technically you therefore want the “system ID” property, but in most practical cases you will get the same result from base-uri() or document-uri().
>
> Michael Kay
> Saxonica
>
>
>> On 26 Jun 2015, at 22:17, Max Toro <[hidden email]> wrote:
>>
>> When I use fn:error it throws a DynamicError (on .NET) which has
>> ModuleUri and LineNumber properties that refer to the program location
>> where the error was raised. However, I'd like to know the URI and line
>> number of the document that contains the bad data that is the reason
>> why the error is raised. Is there a clean way to do it?
>>
>> --
>> Max Toro
>>
>> ------------------------------------------------------------------------------
>> Monitor 25 network devices or servers for free with OpManager!
>> OpManager is web-based network management software that monitors
>> network devices and physical & virtual servers, alerts via email & sms
>> for fault. Monitor 25 devices for free with no restriction. Download now
>> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: fn:error and source URI and line number

Michael Kay

> On 27 Jun 2015, at 02:57, Max Toro <[hidden email]> wrote:
>
> Michael,
> I know how to get the URI/line number, my question is, is there a
> clean way to pass that info to the host application in the form of a
> terminating error. Or for that matter, any other data.

You have to decide what information to pass to fn:error() and how to structure it. There’s a lot of flexibility there. If you write an ErrorListener then you can extract the information from the exception that comes through (e.g. XPathException.getErrorObject()), and format it accordingly.

Michael Kay
Saxonica




------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help