Welcome to the Mythicsoft Q&A site for:

- Agent Ransack
- FileLocator Lite
- FileLocator Pro

Please feel free to ask any questions on these products or even answer other community member questions.

Useful Links:

- Contact Us
- Help Manuals
- Mythicsoft Home
0 votes

I'm searching logfiles where it would be helpful to export the found line and e.g. the 5th line before the found line (think of searching for ERROR and what caused the error).
It looks like this should be possible with a custom XSL but I can't find a suitable example to start with.
Please help!

by (30 points)

1 Answer

0 votes

If you can be sure that there are 5 preceding lines then something like this should work:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:apply-templates select="//rslt:line"/>

  <xsl:template match="rslt:line">

    <xsl:if test="@rslt:linetype='found'">
      <xsl:value-of select="preceding-sibling::*[5]/rslt:text"/>
      <xsl:value-of select="rslt:text"/>


Don't forget to change the Surrounding Lines so that Line before is at least 5.

by (715 points)

Works like a charm!
As a note: the "Save information ... Sourrounding lines" checkbox must be checked, too, of course.

Ah yes, good point.