ok, fair enough.
i was just hoping that somebody could give me some ideas
about how to sturcture my categories.xml file for the kind of
search i am trying to do.
another poster provided some useful code for the XSL file (below).
but now, if somebody could show me how to pass the value from
the user's search string on the client to the XSL file and, how to
structure the XML file for the kind of "proximity searching" that
i was discussing wiht Peter. Should each node contain a string
of key words?
If this is an application design issue and not an XML problem, fair
enough. otherwise, advice appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<!--change <xsl:variable name="data" select="'met sport baseball'"/>
in
<xsl:param name="data"/>-->
<xsl:variable name="data" select="'met sport baseball'"/>
<xsl:variable name="upperCase"
select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="lowerCase"
select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="test"
select="translate($data,$upperCase,$lowerCase)"/>
<xsl:template match="/">
<xsl:apply-templates select="*/*">
<xsl:with-param name="search" select="$test"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">
<xsl:param name="search"/>
<xsl:variable name="result">
<xsl:call-template name="searching">
<xsl:with-param name="Sdeb" select="$search"/>
<xsl:with-param name="Send" />
<xsl:with-param name="val" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="string($result)=''">
trouvé <xsl:value-of select="."/>
</xsl:if>
</xsl:template>
<xsl:template match="*[@title]">
<xsl:param name="search"/>
<xsl:variable name="result">
<xsl:call-template name="searching">
<xsl:with-param name="Sdeb" select="$search"/>
<xsl:with-param name="Send" />
<xsl:with-param name="val" select="@title"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="string($result)=''">
trouvé <xsl:value-of select="@title"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*">
<xsl:with-param name="search" select="string($result)"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="searching">
<xsl:param name="Sdeb"/>
<xsl:param name="Send"/>
<xsl:param name="val"/>
<xsl:variable name="trans">
<xsl:choose>
<xsl:when test="contains($Sdeb,' ')">
<xsl:value-of select="substring-before($Sdeb,' ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Sdeb"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="word" select="string($trans)"/>
<xsl:choose>
<xsl:when
test="contains(translate($val,$upperCase,$lowerCas e),$word)">
<xsl:choose>
<xsl:when test="$Sdeb=$word">
<xsl:value-of select="$Send"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="searching">
<xsl:with-param name="Sdeb"
select="substring-after($Sdeb,' ')"/>
<xsl:with-param name="Send" select="$Send"/>
<xsl:with-param name="val" select="$val"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$Sdeb=$word">
<xsl:value-of select="concat($Send,' ',$word)"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="searching">
<xsl:with-param name="Sdeb"
select="substring-after($Sdeb,' ')"/>
<xsl:with-param name="Send" select="concat($Send,'
',$word)"/>
<xsl:with-param name="val" select="$val"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Joe Kesselman wrote:
pbd22 wrote:
What i do need to understand is how to rank such a search. How would
the logic
work for scoring number (2) as 93% and (3) as 90%, say?
That's an application design issue, not an XML issue per se.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry