Subject: Re: Testing/searching for several elements using xsl From: Rick Geimer <rick.geimer@xxxxxxx> Date: Wed, 14 Apr 1999 11:39:24 -0700 |
This might not be exactly what you are looking for, but it seems to do the job, at least for IE5. Given the following XML document: <?xml version="1.0"?> <?xml-stylesheet href="cddoc.xsl" type="text/xsl"?> <cd_doc> <entries> <entry no="1" path="/cdrom/stugg/long path/moretext/python_stuff.tar.gz"/> <entry no="5" path="/cdrom/stugg/long path/moretext/python_stuff.tar.gz"/> <entry no="21" path="/cdrom/stugg/long path/moretext/python_stuff.tar.gz"/> </entries> </cd_doc> The following XSL stylesheet will find entries with "no" attributes matching 1, 21, or 1432 and display the line "Here's an entry". <xsl:template xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:qxsl="quote:http://www.w3.org/TR/WD-xsl"> <html><head><title>CD Stuff</title></head> <body> <xsl:apply-templates select="/*"/> </body> </html> <xsl:define-template-set> <xsl:template match="cd_doc"> <h1>Result of search</h1> <xsl:apply-templates/> </xsl:template> <xsl:template match="entries"> <xsl:apply-templates select="entry[@no = 1 or @no = 21 or @no = 1432]" /> </xsl:template> <xsl:template match="entry"> <h2>Here's an entry</h2> <xsl:apply-templates/> </xsl:template> </xsl:define-template-set> </xsl:template> Hope this helps. Rick Geimer National Semiconductor rick.geimer@xxxxxxx ------------------------------------------------------------------------------ Thomas Weholt wrote: > Hello, > > Note! This mail is related to the "Searching huge xml-documents" question I > posted earlier, but it`s intereseting by itself too. > > I want to locate several "entries"-elements in a xml-document using a > entry-elements "no"-attribute. > > Sample xml-doc : > > <cd_doc> > ... info about the cd ... > <entries> > <entry no="1" path="/cdrom/stugg/long path/more > text/python_stuff.tar.gz" ... more info .../> > ... lots of more entries > </entries> > </cd_doc> > > I tried with a stylesheet like this : > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> > > <xsl:template match="cd_doc"> > <HTML> > <BODY> > <h2>Result of search</h2> > <xsl:apply-templates select="entry"/> > </BODY> > </HTML> > </xsl:template> > > <xsl:template match="entry"> > <xsl:choose> > <xsl:when test='.[@no="1"|@no="21"|@no="1432"]'> > <xsl:apply-templates select=""/> > </xsl:when> > </xsl:choose> > </xsl:template> > > </xsl:stylesheet> > > But it didn`t work. I want to process entries with attribute numbers equal > to 1, 21 and 1432. Used Xt to generate HTML with these documents. > > ---------------------------------------------- > Thomas Weholt > eMail : weholt@xxxxxxxxxxxxxx > HTTP://www.linuxfreak.com/~weholt > Phone : +47 - 92 09 59 68 > ---------------------------------------------- > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Testing/searching for several e, Paul Prescod | Thread | RE: Testing/searching for several e, Kay Michael |
Re: apache,perl,xml,xsl, Betty L. Harvey | Date | RE: Problem in referencing DHTML 'd, Didier PH Martin |
Month |