Altova Mailing List Archives


from xpath to surrounding context?

From: "Evan Owens" <Evan.Owens@-------.--->
To: <xml-dev@-----.---.--->
Date: 11/7/2007 1:41:00 PM
Given an xpath 
expression that points into a document, can anyone suggest a clever way 
to extract an arbitrary chunk of the document immediately before and 
after that point?  Say, 40 characters before and after?
 
Here's the use case: 
we have an 
error report that is generated as part of an XSLT batch transformation 
process.  The error message include the xpath that describes 
the element that caused the problem; e.g.,   
/ART[1]/BM[1]/BIBL[1]/BIB[5]/NOTE[1]/P[1].  The users of the report 
have requested that we add a bit of context to help them assess the 
errors without having to open every single file...a preview snippet as it 
were. 
 
It doesn't have to 
be a pure XML solution nor does it have to be extremely efficient in processor 
time.  These are not large documents and it would be okay to reread the 
files as part of the error report generation.   
 
Thanks in advance 
for any suggestions as to ways to tackle this problem.
 
Evan Owens

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.