[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How can I filter stoppwords

Subject: Re: How can I filter stoppwords
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: Mon, 28 Aug 2000 16:33:26 +0200
azertyuiopqsdfghjklmwxcvbn
If you really want to do it with XSLT ;=) ...

--------------XML-----------
<?xml version='1.0' encoding='ISO-8859-1'?>
<xmlfile>
<book>
   <title>The Ants</title>
   <id>1234</id>
</book>
<book>
   <title>Lifestyle</title>
   <id>1235</id>
</book>
<book>
   <title>Being a Dog Is a Full-Time Job</title>
   <id>1236</id>
</book>
</xmlfile>
--------------/XML-----------

through

--------------XSL-----------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sw="mailto:vdv@xxxxxxxxxxxx";>

<sw:stop>
  <word>the</word>
  <word>a</word>
  <word>is</word>
</sw:stop>

<xsl:template match="/">
  <result>
    <xsl:apply-templates select="/xmlfile/book/title"/>
  </result>
</xsl:template>

<xsl:template match="title">
  <before><xsl:value-of select="."/></before>
  <after><xsl:call-template name="strip-stop">

    <xsl:with-param name="string"
select="concat(translate(normalize-space(),
'AZERTYUIOPQSDFGHJKLMWXCVBN', 'azertyuiopqsdfghjklmwxcvbn'), ' ')"/>
    </xsl:call-template></after>
</xsl:template>

<xsl:template name="strip-stop">
  <xsl:param name="string"/>
  <xsl:variable name="before" select="substring-before($string, ' ')"/>
  <xsl:variable name="after" select="substring-after($string, ' ')"/>
  <xsl:if
test="count(document('')/xsl:stylesheet/sw:stop[word=$before])=0">
    <xsl:value-of select="concat($before, ' ')"/>
  </xsl:if>
  <xsl:if test="$after!=''">
    <xsl:call-template name="strip-stop">
    <xsl:with-param name="string" select="$after"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>
--------------/XSL-----------

gives

--------------XML-----------
<?xml version="1.0" encoding="utf-8"?>
<result xmlns:sw="mailto:vdv@xxxxxxxxxxxx";>
<before>The Ants</before><after>ants </after>
<before>Lifestyle</before><after>lifestyle </after>
<before>Being a Dog Is a Full-Time Job</before><after>being dog
full-time job </after>
</result>
--------------/XML-----------

Despite the fact that XPath has no 'to lower' function and that you need
to use translate instead, the trick here is the way to access the nodes
of the stylesheet itself though document("")...

Hope this helps.

Eric

"Sellmer-Brüls, Barbara" wrote:
> 
> Hi,
> 
> I need to filter stopp words from book titles.
> 
> Example:
> <xmlfile>
> <book>
>    <title>The Ants</title>
>    <id>1234</id>
> </book>
> <book>
>    <title>Lifestyle</title>
>    <id>1235</id>
> </book>
> </xmlfile>
> 
> I tried to do it with <xsl:value-of select="substring-after(title,'The')"/>
> I was successfull as regards to "The Ants", but in all cases where there
> exists no stopp word, the substring function returns an empty string.
> 
> Does anybody know another way to filter stopp words?
> How do you XSL-create a sort criterion?
> How can I tell the what-so-ever-function that there is not only one stopp
> word, but a list of such words to be stripped from the beginning (!!!) of
> titles.
> 
> Thanks a lot.
> Barbara
> ---
> Barbara Sellmer-Bruels
> Klopotek & Partner GmbH - Berlin
> E-Commerce
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.