xsl-list
[Top] [All Lists]

Re: [xsl] Fwd: Parsing Excel - Selecting Ranges

2008-10-21 08:33:39
Luciano Greiner wrote:

  Hi

I need to select Row elements between Rows containing first
Cell/Data child filled with '#' and a clear first Cell/Data.

  You can use the << and >> operators:

    georgfl(_at_)bxl-wrk-090> cat luciano.xsl
    <xsl:stylesheet
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
          version="2.0">

       <xsl:output indent="yes"/>

       <xsl:template match="/sheet">
          <xsl:variable name="first" as="element(Row)" select="
              Row[Cell/Data eq '#']"/>
          <xsl:variable name="last" as="element(Row)" select="
              Row[Cell/Data eq '']"/>
          <xsl:sequence select="
              Row[. >> $first][. &lt;&lt; $last]/Cell/Data"/>
       </xsl:template>

    </xsl:stylesheet>

    georgfl(_at_)bxl-wrk-090> cat luciano.xml
    <sheet>
       <Row>
          <Cell><Data>#</Data></Cell>
       </Row>
       <Row>
          <Cell><Data>1</Data></Cell>
       </Row>
       <Row>
          <Cell><Data>2</Data></Cell>
       </Row>
       <Row>
          <Cell><Data/></Cell>
       </Row>
    </sheet>

    georgfl(_at_)bxl-wrk-090> saxon -s:luciano.xml -xsl:luciano.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <Data>1</Data>
    <Data>2</Data>

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/

























      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>