Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Filter Nodes in XSL

Reply
Thread Tools

Filter Nodes in XSL

 
 
toffeem@hotmail.com
Guest
Posts: n/a
 
      12-19-2004
Hi all,

I have 2 xml files.

Books.xml - defined all the available books information
Exclude.xml -defined the books ids which need to be filter.

I would like to write a xsl file (filter.xsl) to show book information
except those defined in exclude.xml. Can anyone have any idea how to
write this xsl file? Any help is appreciated.

Thanks in advance.

Toffeem


For example.

All Available Books data

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="filter.xsl"?>
<Books>
<BookRecs>
<Book>
<name>ABC book</name>
<id>1234567890</id>
<price>10.00</price>
</Book>
<Book>
<name>CDE book</name>
<id>1111111111</id>
<price>11.00</price>
</Book>
<Book>
<name>FGH book</name>
<id>2222222222</id>
<price>12.00</price>
</Book>
<Book>
........
</Book>
</BookRecs>
</Books>


The books need to be filter
<FilterBook>
<id>1111111111</id>
<id>2222222222</id>
</FilterBook>

My expected result:
Case 1: Show all the books information except those defined in
"Exclude.xml".

<html>
<table>
<tr>Book data:</tr>
<tr>ABC book - 1234567890 - 10.00</tr>
</table>
</html>

Case 2: If no book information can be shown after filtering
<html>
No book is available.
</html>

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      12-19-2004
> Books.xml - defined all the available books information
> Exclude.xml -defined the books ids which need to be filter.
>
> I would like to write a xsl file (filter.xsl) to show book information
> except those defined in exclude.xml. Can anyone have any idea how to
> write this xsl file? Any help is appreciated.
>

Hi,

I think this will work:

<xsl:template match="BookRecs">
<xsl:apply-templates select="Book[not(id=document('Exclude.xml')//FilterBook/id)]"/>
</xsl:template>


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Gaudiam omnibus traderat W3C , nec vana fides
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
Looking A Nodes From Within Nodes Johnny Ooi XML 10 11-14-2004 06:55 PM
selecting nodes between other nodes Timo Nentwig XML 1 06-17-2004 04:54 AM
Reality check: Is it sensible to link XML nodes to other XML nodes in the same file? gavnosis XML 0 08-02-2003 08:22 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57