<!--

Copyright (c) 2002,2003 The Regenstrief Institute.  All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Written by Gunther Schadow.

$Id: brian-spextract-xml.xsl,v 1.1.1.1 2005/02/17 00:43:51 gschadow Exp $

-->
<xsl:transform version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:gut="http://aurora.regenstrief.org/XML/GenericUpTranslator"
   xmlns:saxon="http://saxon.sf.net/"
   extension-element-prefixes="saxon"
   exclude-result-prefixes="gut">

  <xsl:import href="spextract.xsl"/>

  <xsl:output method="xml" indent="no"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
    <root>
      <xsl:apply-templates select="node()"/>
    </root>
  </xsl:template>

  <!-- null transform -->       
  <xsl:template match="node()|@*">
    <xsl:apply-templates select="node()"/>
  </xsl:template>

  <xsl:template match="Text_Report">
    <xsl:variable name="text">
      <xsl:apply-templates mode="plaintext" select="node()"/>
    </xsl:variable>
    <xsl:variable name="string"> 
      <xsl:value-of select="string-join($text,'')"/>
    </xsl:variable>
    <xsl:variable name="new-info">    
      <xsl:apply-templates mode="gut:top" select="$string/text()"/>
    </xsl:variable>    
    <spextract>
      <text><xsl:copy-of select="$string"/></text>
      <found><xsl:copy-of select="$new-info"/></found>
    </spextract>
  </xsl:template>

  <!-- MODE plaintext - turn all the fancy XML into plain
       ASCII text. -->
  <xsl:template mode="plaintext" match="/|node()|@*">
    <xsl:apply-templates mode="plaintext" select="node()"/>
  </xsl:template>
  <xsl:template mode="plaintext" match="Text/text()">
    <xsl:copy/>
  </xsl:template>
  <xsl:template mode="plaintext" match="Text/br">
    <xsl:text>&#xA;</xsl:text>
  </xsl:template>

</xsl:transform>


