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 (50 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"
			xmlns:rslt="http://www.mythicsoft.com/FileLocator_16Aug2005"
           version="1.0">

  <xsl:output method="text"/>

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

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

    <xsl:if test="@rslt:linetype='found'">
      <xsl:text>Preceding:</xsl:text>
      <xsl:value-of select="preceding-sibling::*[5]/rslt:text"/>
      <xsl:text>&#13;&#10;</xsl:text>
      <xsl:text>Text:</xsl:text>
      <xsl:value-of select="rslt:text"/>
      <xsl:text>&#13;&#10;</xsl:text>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

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

by (1.6k points)

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

Ah yes, good point.

...