[jdom-interest] XPath from Element

Todd O'Bryan toddobryan at mac.com
Thu Jul 17 06:05:43 PDT 2003


Some of my elements have SQL queries embedded in them. If there's an  
error along the way, I need to know where it happened, and since the  
SQL is remarkably similar, printing the Exception message it gives  
hasn't been too helpful. Being able to pinpoint which element I was  
working on when it happened would be very useful. There's also the  
problem that many of the elements will have the same name, so a full  
path description is pretty much necessary.

Todd

On Wednesday, July 16, 2003, at 11:58  PM, Jason Hunter wrote:

> There's no direct method.  It'd be easy to write by walking up the  
> tree and counting your place along the way.  Of course, the only path  
> you can get from a tool is fragile and based on things like index  
> which aren't the kind of general XPath a person can write which more  
> describes the element's characteristics than it's current locatoin.
>
> Why do you need this?
>
> -jh-
>
> Todd O'Bryan wrote:
>
>> I'm using XML to write a mini-programming language (very mini), but I  
>> need to be able to catch syntax errors and tell the user where they  
>> occur.
>> Is there a way to get an XPath representation of an Element from the  
>> element?
>> For example,
>> <x>
>>     <y>
>>         <z>...</z>
>>         <z>...</z>
>>         <z>Error here</z>
>>     </y>
>> </x>
>> When I discover the error processing the element shown, is there any  
>> way to get
>> /x/y/z[2] from somewhere?
>> Thanks,
>> Todd
>> _______________________________________________
>> To control your jdom-interest membership:
>> http://lists.denveronline.net/mailman/options/jdom-interest/ 
>> youraddr at yourhost.com
>




More information about the jdom-interest mailing list