[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: InString filter in XSL
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|