Magi

Contact info
Word
Research
   Publications
Studies
Free Software
Hobbies
Articles
Photography
About me
   Curriculum Vitae

©Marko Grönroos, 1998

USENET News sfnet.atk.linux

Säie: loook

Edellinen säie: SCO voivoivoi
Seuraava säie: RedHat9 & lokaalien asennus
[Muut säikeet] [Muut uutisryhmät]
From: Marko Gronroos <magi AT iki PISTE fi>
Newsgroups: sfnet.atk.linux
Subject: Re: loook
Date: 17 May 2003 01:11:54 +0300

Asmo Koskinen <asmo PISTE koskinen AT asmokoskinen PISTE net> writes:
> koska OpenOffice.org:n tiedostomuoto on xml (avoin sellainen), niin
> tiedostojen sisään voidaan tehdä hakuja, kun ensin lennossa puretaan
> zip-pakkaus. Eräs tällainen sovellus on Pythonin päälle tehty
> loook. Se sallii myös sanojen yhdistelmähaut.
>
> http://www.danielnaber.de/loook/

Jooh, noita on helppo tehdä itsekin, erityisesti XSLT:llä.

Alla taannoin tekemäni simppeli esimerkki, miten tulostetaan
dokumentin rakenne tekstipuuna. (Alussa on kamala
namespace-määrittelyröykkiö.)

<?xml version='1.0'?>
   <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:office="http://openoffice.org/2000/office"
   xmlns:style="http://openoffice.org/2000/style"
   xmlns:text="http://openoffice.org/2000/text"
   xmlns:table="http://openoffice.org/2000/table"
   xmlns:draw="http://openoffice.org/2000/drawing"
   xmlns:fo="http://www.w3.org/1999/XSL/Format"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:number="http://openoffice.org/2000/datastyl e "
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:chart="http://openoffice.org/2000/chart"
   xmlns:dr3d="http://openoffice.org/2000/dr3d"
   xmlns:math="http://www.w3.org/1998/Math/MathML"
   xmlns:form="http://openoffice.org/2000/form"
   xmlns:script="http://openoffice.org/2000/script"
       version='1.0'>

       <xsl:output method="text" encoding="ISO-8859-1"/>

       <!-- Print all headings, indented. -->
       <xsl:template match="text:h">
             <xsl:value-of select="substring(' ', 1, (@text:level - 1) * 2)"/>
             <xsl:text>* </xsl:text>
             <xsl:value-of select="text()"/>
             <xsl:text> </xsl:text>
       </xsl:template>

       <!-- Don't output any other text. -->
       <xsl:template match="text()">
       </xsl:template>
   </xsl:stylesheet>


Ohjelman voi ajaa OpenOffice-tekstidokumentin sisältä unzip:illä
löytyvälle content.xml:lle vaikkapa xsltproc-XSLT-prosessorilla:

            xsltproc esimerkki.xsl content.xml

Tuloksena tulostuu:

   * Ylimmän tason otsikko
       * 2. tason kappaleen otsikko
       * toinen otsikko
           * taas alempi otsikko
               * vielä alempi otsikko
       * Taas yksi kappale


Edellinen säie: SCO voivoivoi
Seuraava säie: RedHat9 & lokaalien asennus
[Muut säikeet] [Muut uutisryhmät]