Re: InString filter in XSL

Subject: Re: InString filter in XSL
From: Eugeny Kuzakov <kev@xxxxxxxxx>
Date: Thu, 24 Jun 1999 15:50:26 +0700 (OSS)
On Thu, 24 Jun 1999, Christian Wittern wrote:

> <el att="aa, bb, cc">I want to select this</el>
> <el att="bb, cc">Or I want to select this</el>
> <el att="aa, cc">Or maybe I want to select this</el>
> 
> I want to select nodes based on the value of att: Either those containing
> 'aa', or 'bb', or 'cc', regardless of the other surrounding values, i.e. if
> I check for 'aa', I'd like to get the first and last, in the case of 'bb'
> the first and second, etc.
Example of xml document:

<?xml version="1.0"?>
<document>
    <el att="aa">Object with attribute aa</el>
    <el att="bb">Object with attribute bb</el>
    <el att="cc">Object with attribute bb</el>
    <el att="dd">Object with attribute bb</el>
</document>

Example of stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";
                  default-space="strip"
                  indent-result="yes"
    result-ns="">

<xsl:template match="document">
    <document>
	<xsl:apply-templates select="el[from-attributes(att) = 'aa']"/>
	<xsl:apply-templates select="el[from-attributes(att) = 'bb']"/>
	<xsl:apply-templates select="el[from-attributes(att) = 'bb']"/>
	<xsl:apply-templates select="el[from-attributes(att) = 'aa']"/>
    </document>
</xsl:template>


<xsl:template match="el">
    <selected_object>
	<xsl:value-of select="."/>
<!--	<with_attribute>
	    <xsl:value-of select="@att"/>
	</with_attribute>
-->
    </selected_object>
</xsl:template>

</xsl:stylesheet>

Example of output:

<document>
<selected_object>Object with attribute aa</selected_object>
<selected_object>Object with attribute bb</selected_object>
<selected_object>Object with attribute bb</selected_object>
<selected_object>Object with attribute aa</selected_object>
</document>

--
	Best wishes, Eugeny Kuzakov
		Laboratory 321 ( Omsk, Russia )
		kev@xxxxxxxxx
		ICQ#: 5885106

p.s. Tested with xt.


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


Current Thread