Subject: RE: [xsl] Filtering out books with short description From: cknell@xxxxxxxxxx Date: Tue, 19 Jul 2005 15:18:09 -0400 |
<?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" indent="yes" encoding="UTF-8" /> <xsl:strip-space elements="*" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="bookshelf"> <bookshelf> <xsl:apply-templates select="book[string-length(description) > 5]" /> </bookshelf> </xsl:template> <xsl:template match="book"> <xsl:copy-of select="." /> </xsl:template> </xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Karl Koch <TheRanger@xxxxxxx> Sent: Tue, 19 Jul 2005 20:38:19 +0200 (MEST) To: "Mulberry list" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Filtering out books with short description Hello experts, all my postings here relate to a number of problems regarding one set of content I have to solve. I have a list of books (simplified to make our lifes easier:). This content needs to be transformed for various purposes. <bookshelf> <book> <title>First book</title> <description>text text text</description> </book> <book> <title>Second book</title> <description>text text</description> </book> <book> <title>Third book</title> <description>text</description> </book> </bookshelf> I would like to filter out all books with short descriptions. How can I do that? I curretnly see two different ideas of how this could be done (text lengh and number of text tokens) and wonder if you can help me with one or perhaps even both of them? 1) Copy only books with a description text of at least 5 letters in the resulting XML file. That would remove the third book. The result would only contain the first and teh second book. How can I do that? 2) Copy only books with at least 3 text tokens in the description element. After doing that only the first book would arrive in the resulting XML file. Is there a way to do that with XSLT? I am using XALAN. Kind Regards and many thanks in advance, Karl -- GMX DSL = Maximale Leistung zum minimalen Preis! 2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Merging XML structure by , cknell | Thread | RE: [xsl] Filtering out books with , Karl Koch |
Re: [xsl] Merging XML structure by , Wendell Piez | Date | [xsl] Saxon8 beginner questions, Manfred Staudinger |
Month |