RE: [xsl] Filtering out books with short description

Subject: RE: [xsl] Filtering out books with short description
From: "Karl Koch" <TheRanger@xxxxxxx>
Date: Wed, 20 Jul 2005 15:33:10 +0200 (MEST)
Hello,

and thank you for the script. Is seems to work. I have one question
regarding this script. In the line:

<xsl:apply-templates select="book[string-length(description) &gt;
> 5]" /> 

Is it ensured that (description) only considers "description" being a direct
child of "book". What would happen if there would (sometimes) be another
"description" tag deeper inside the structure. Would this script than also
pick on that one? If yes, how could this be avoided. I checked in my output
(please remember, my orginal datastructure is much more complicated) and it
seems only to consider /book/description but I can't really explain why that
should be...

The second question is: What does "&gt" mean?

Karl



> <?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) &gt;
> 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
> 

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse fo?=r Mail, Message, More +++

Current Thread