Filter Nodes in XSL

Discussion in 'XML' started by toffeem@hotmail.com, Dec 19, 2004.

  1. Guest

    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>
     
    , Dec 19, 2004
    #1
    1. Advertising

  2. Joris Gillis Guest

    > 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-view.cgi?userid=38041)
    Gaudiam omnibus traderat W3C , nec vana fides
     
    Joris Gillis, Dec 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asd
    Replies:
    3
    Views:
    458
    Arnaud Berger
    May 23, 2005
  2. gavnosis
    Replies:
    0
    Views:
    544
    gavnosis
    Aug 2, 2003
  3. Timo Nentwig

    selecting nodes between other nodes

    Timo Nentwig, Jun 16, 2004, in forum: XML
    Replies:
    1
    Views:
    435
    Patrick TJ McPhee
    Jun 17, 2004
  4. Johnny Ooi

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    672
    Johnny Ooi
    Nov 14, 2004
  5. Replies:
    1
    Views:
    3,688
    A. Bolmarcich
    May 27, 2005
Loading...

Share This Page