Problem with Select & Sort please help!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem with Select & Sort please help!

  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Problem with Select & Sort please help!

    Hi everyone,

    Hope someone can help me out as im new to this language and am abit confused.

    Basically im creating an online store with sections Music and subsections CD, Vinyl & MP3. I have the products displaying but they display on all three pages how do i sort them so they only appear on the correct page. so far the code I have used to sort them is:

    <td>


    <xsl:for-each select="document('products.xml')/SECTIONS/CATEGORY/SECTION/SUBSECTION[INFO='CD']">
    <xsl:sort select="SUB"/>
    <P>
    <xsl:value-of select="INFO"/><br/>
    <xsl:value-of select="SUB"/><br/>
    <xsl:value-of select="SUB2"/><br/>
    <xsl:value-of select="SUB3"/><br/>
    </P>


    </xsl:for-each>

    </td>

    Thank you

  2. #2
    Join Date
    May 2009
    Posts
    60
    at first make a xml filedata
    eg musik.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="musik.xsl"?>
    <musik>
    	<item typ="Vinyl"><!--here data of musik -->
    		<year>1981</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="Vinyl"><!--here data of musik -->
    		<year>1982</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="Vinyl"><!--here data of musik -->
    		<year>1983</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="mp3"><!--here data of musik -->
    		<year>2001</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="mp3"><!--here data of musik -->
    		<year>2002</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="CD"><!--here data of musik -->
    		<year>1991</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="CD"><!--here data of musik -->
    		<year>1992</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="CD"><!--here data of musik -->
    		<year>1995</year>
    		<kind>movisound</kind>
    	</item>
    	<item typ="mp3"><!--here data of musik -->
    		<year>2007</year>
    		<kind>movisound</kind>
    	</item>
    </musik>

    in same dir make a xsl file

    call musik.xsl

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes"/>
        <xsl:template match="/">
            <html>
                <xsl:apply-templates select="musik"></xsl:apply-templates>
            </html>
            
        </xsl:template>
        <xsl:template match="musik">
            <h1>mp3</h1>
            <xsl:apply-templates select="item[@typ='mp3']">
                <!-- here can sort -->
            </xsl:apply-templates>
            <h1>Vinyl</h1>
            <xsl:apply-templates select="item[@typ='Vinyl']">
                <!-- here can sort -->
            </xsl:apply-templates>
            <h1>CD</h1>
            <xsl:apply-templates select="item[@typ='CD']">
            <xsl:sort data-type="number" select="year" order="descending"></xsl:sort>
                <!-- here can sort -->
            </xsl:apply-templates>
            
        </xsl:template>
        
        <xsl:template match="item">
            <!-- here more out from the musik.xml -->
            <p>
                <xsl:value-of select="year"/>
            </p>
            
        </xsl:template>
    </xsl:stylesheet>
    in the browser click musik.xml

    result




    HTML Code:
    <html>
       <h1>mp3</h1>
       <p>2001</p>
       <p>2002</p>
       <p>2007</p>
       <h1>Vinyl</h1>
       <p>1981</p>
       <p>1982</p>
       <p>1983</p>
       <h1>CD</h1>
       <p>1995</p>
       <p>1992</p>
       <p>1991</p>
    </html>
    Helmut Hagemann

Similar Threads

  1. Sort Problem in C ( For Data > 3 GB )
    By praveenholal in forum C++
    Replies: 3
    Last Post: 03-29-2007, 09:21 AM
  2. Problem with cursor and UNION in select
    By steph2004 in forum Database
    Replies: 1
    Last Post: 02-11-2006, 06:06 PM
  3. Replies: 1
    Last Post: 09-09-2002, 09:06 AM
  4. Ado Data Control: Sort Problem
    By Sorin in forum VB Classic
    Replies: 1
    Last Post: 07-12-2002, 04:41 AM
  5. Stored Procedure (Want looping in Cursor)
    By malikmehmood in forum Database
    Replies: 0
    Last Post: 11-20-2000, 06:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center