this code is not showing any result for me please help......

Please help... this code is not showing any result........
bookstylesheet.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/collection">
<b> <xsl:text>* bookk details sortedin descending order of their pric*</xsl:text></b>

<xsl:for-each select="bookinfo/book">
<xsl:sort select="price" data-type="number" order="descending"/>
<hr>
<xsl:value-of select="@bookid"/> </br>
<xsl:value-of select="bookname"/> </br>
<font color="red"><xsl:apply-templates select="price"/></font><br/>
</hr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

book.xml

<?xml version="1.0" ?>
<?xml-stylesheet href="C:\Users\ajasawant\Downloads\AIT PRoject\xml practice\bookstylesheet.xsl" type="text/xsl" ?>
<bookinfo>
<book bookid="B001" category="practical">
<bookname>php and xml</bookname>
<authorname>neelima padmawar</authorname>
<price>120</price>
</book>
<book bookid="B002" category="practical">
<bookname>java</bookname>
<authorname>alok pawar</authorname>
<price>140</price>
</book>
</bookinfo>
Ajay SawantStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <b> <xsl:text>* bookk details sortedin descending order of their pric*</xsl:text></b>
        
        <xsl:for-each select="bookinfo/book">
            <xsl:sort select="price" data-type="number" order="descending"/>
            <hr/>
                <xsl:value-of select="@bookid"/> <br/>
                <xsl:value-of select="bookname"/> <br/>
                <font color="red"><xsl:apply-templates select="price"/></font><br/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
first you had the root wrong, your root element is not collection, so I changed the match attribute to a "/"
after that I tweaked the hr and br to be wellformed
1
Gertone (Geert Bormans)Information ArchitectCommented:
I recommend however that you avoid for-each for accessing child nodes the way you do
That is a pretty procedural way of programming XSLT that will be hard to maintain if things get more complex
Please learn right from the start to use the more functional mechanism of apply templates

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:template match="/">
        <b>
            <xsl:text>* bookk details sortedin descending order of their pric*</xsl:text>
        </b>
        
        <xsl:apply-templates select="bookinfo/book">
            <xsl:sort select="price" data-type="number" order="descending"/>
        </xsl:apply-templates>
        
    </xsl:template>
    
    <xsl:template match="book">
        <hr/>
        <xsl:value-of select="@bookid"/> <br/>
        <xsl:value-of select="bookname"/> <br/>
        <font color="red"><xsl:apply-templates select="price"/></font><br/>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
Gertone (Geert Bormans)Information ArchitectCommented:
answered to the full
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.