Filter Nodes in XSL

T

toffeem

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>
 
J

Joris Gillis

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top