|
|
|
date: Thu, 7 Feb 2008 11:49:39 +0100,
group: microsoft.public.xsl
back
search all elements?
Dear Sir,
I have below filter function using XSLT .
---------------------------------------------------------------------------------------
<xsl:apply-templates mode="search"
select="agendas/agenda[contains(translate(intro,$UC,$lc), $Keyword) or
contains(translate(title,$UC,$lc), $Keyword)]">
</xsl:apply-templates>
----------------------------------------------------------------------------------------
XML is an agenda list which contains many fields. an example is given beloe.
---------------------------------------------------------------------------------------
<agendas>
<agenda id=1>
<title>title of it</title>
<intro>some intro text here </intro>
<location>america</location>
<members>someone, me </members>
<remarks>some remarkds </remarks>
<schedule>content of the event </schedule>
</agenda>
</agendas>
----------------------------------------------------------------------------------------------
In above example, I use apply-templates, contains to filter data, and I use
keyword "or" to search multiple fields now, but this isn't a good solution.
because I need to search into many element. in above example, I only search
"intro" and "title".
How can I search all elements? I try "node()", but it does not work out?
Regards,
Guoqi Zheng
date: Thu, 7 Feb 2008 11:49:39 +0100
author: guoqi zheng
Re: search all elements?
Well, if your keyword is a one word, you can just check agenda element
string value:
<xsl:apply-templates mode="search"
select="agendas/agenda[contains(translate(.,$UC,$lc), $Keyword)]">
</xsl:apply-templates>
Alternatively you can do this trick:
<xsl:for-each select="agendas/agenda">
<xsl:variable name="process-it">
<xsl:for-each select="*">
<xsl:if test="translate(.,$UC,$lc), $Keyword">1</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$process-it != ''">
<xsl:apply-templates select="." mode="search"/>
</xsl:if>
</xsl:for-each>
--
Oleg
guoqi zheng wrote:
> Dear Sir,
>
> I have below filter function using XSLT .
> ---------------------------------------------------------------------------------------
> <xsl:apply-templates mode="search"
> select="agendas/agenda[contains(translate(intro,$UC,$lc), $Keyword) or
> contains(translate(title,$UC,$lc), $Keyword)]">
> </xsl:apply-templates>
> ----------------------------------------------------------------------------------------
> XML is an agenda list which contains many fields. an example is given beloe.
>
> ---------------------------------------------------------------------------------------
> <agendas>
> <agenda id=1>
> <title>title of it</title>
> <intro>some intro text here </intro>
> <location>america</location>
> <members>someone, me </members>
> <remarks>some remarkds </remarks>
> <schedule>content of the event </schedule>
> </agenda>
> </agendas>
> ----------------------------------------------------------------------------------------------
>
> In above example, I use apply-templates, contains to filter data, and I use
> keyword "or" to search multiple fields now, but this isn't a good solution.
> because I need to search into many element. in above example, I only search
> "intro" and "title".
>
> How can I search all elements? I try "node()", but it does not work out?
>
> Regards,
>
> Guoqi Zheng
>
>
date: Thu, 07 Feb 2008 13:27:41 +0200
author: Oleg Tkachenko
Re: search all elements?
I use the ".", it works now. Thanks.
"Oleg Tkachenko" wrote in message
news:uu7h2xXaIHA.1208@TK2MSFTNGP05.phx.gbl...
> Well, if your keyword is a one word, you can just check agenda element
> string value:
> <xsl:apply-templates mode="search"
> select="agendas/agenda[contains(translate(.,$UC,$lc), $Keyword)]">
> </xsl:apply-templates>
>
> Alternatively you can do this trick:
> <xsl:for-each select="agendas/agenda">
> <xsl:variable name="process-it">
> <xsl:for-each select="*">
> <xsl:if test="translate(.,$UC,$lc), $Keyword">1</xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:if test="$process-it != ''">
> <xsl:apply-templates select="." mode="search"/>
> </xsl:if>
> </xsl:for-each>
>
> --
> Oleg
>
> guoqi zheng wrote:
>> Dear Sir,
>>
>> I have below filter function using XSLT .
>> ---------------------------------------------------------------------------------------
>> <xsl:apply-templates mode="search"
>> select="agendas/agenda[contains(translate(intro,$UC,$lc), $Keyword) or
>> contains(translate(title,$UC,$lc), $Keyword)]">
>> </xsl:apply-templates>
>> ----------------------------------------------------------------------------------------
>> XML is an agenda list which contains many fields. an example is given
>> beloe.
>>
>> ---------------------------------------------------------------------------------------
>> <agendas>
>> <agenda id=1>
>> <title>title of it</title>
>> <intro>some intro text here </intro>
>> <location>america</location>
>> <members>someone, me </members>
>> <remarks>some remarkds </remarks>
>> <schedule>content of the event </schedule>
>> </agenda>
>> </agendas>
>> ----------------------------------------------------------------------------------------------
>>
>> In above example, I use apply-templates, contains to filter data, and I
>> use keyword "or" to search multiple fields now, but this isn't a good
>> solution. because I need to search into many element. in above example, I
>> only search "intro" and "title".
>>
>> How can I search all elements? I try "node()", but it does not work out?
>>
>> Regards,
>>
>> Guoqi Zheng
date: Thu, 7 Feb 2008 13:17:55 +0100
author: guoqi zheng
|
|