XSLT链接到XSLT

时间:2014-12-19 01:19:11

标签: javascript html xml xslt


我是新的xml和xslt所以对我来说很容易。我有一个名为allBooks.xml的文件,它有三个文件allBooksTitle.xsl,allBooksDetails.xsl,allBooksCategories.xsl的信息。

我已经看到并且看到可以使用javascript显示隐藏功能的可能性,但我不知道javascript。

当查看allBooksTitle.xsl时,我想要一个链接,当你点击书的标题,带你到那本书的allBooksDetails.xsl。

当查看allBooksCategories.xsl时,我想要一个链接,当你点击该类书籍的标题时,你会看到该书的allBooksDetails.xsl。

ALLBOOKSTITLE.XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <html>
        <body>
            <h2><xsl:apply-templates select="root/record"/><br/></h2>
        </body>
        </html>
    </xsl:template>
    <xsl:template match="record">
        <div>
            <xsl:apply-templates select="Title"/>
        </div>
    </xsl:template>

</xsl:stylesheet>

ALLBOOKCATEGORIES.XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <html>
        <body>
            <xsl:apply-templates select="root/record"/>
        </body>
        </html>
    </xsl:template>
    <xsl:template match="record">
        <div>
            <p><h4><xsl:apply-templates select="Title"/></h4>
            <xsl:apply-templates select="Category"/><br/>
            <xsl:apply-templates select="ISBN"/><br/>
            <xsl:apply-templates select="Description"/><br/>
            <xsl:apply-templates select="Price"/><br/>
            <xsl:apply-templates select="au_firstname"/><br/>
            <xsl:apply-templates select="au_lastname"/><br/>
            <xsl:apply-templates select="Coverpic"/><br/>
            <br/>
            <br/>
            </p>
        </div>
    </xsl:template>

</xsl:stylesheet>

ALLBOOKSDETAILS.XSL

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <html>
        <body>
            <xsl:apply-templates select="root/record[not(Category=preceding::record/Category)]" mode="Category">
                <xsl:sort select="Category"/>
            </xsl:apply-templates>

            <xsl:for-each select="root/record">
        <xsl:sort select="Category"/>

        <xsl:if test="not(Category=preceding::record/Category)">
            <h1 id="{generate-id()}"><xsl:value-of select="Category"/></h1>
        </xsl:if>
            <xsl:value-of select="Title"/><br /> 
         </xsl:for-each>
        </body>
        </html>
    </xsl:template>
<xsl:template match="record" mode="Category">
 <a href="#{generate-id()}"><xsl:value-of select="Category"/></a>
</xsl:template>
</xsl:stylesheet>

ALLBOOKS.XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="allBooks.xsl"?>
<root>
<record>
<ISBN>0-07-882122-3</ISBN>
<Title>Oracle: A Beginner's Guide</Title>
<Category>database</Category>
<Description>
A beginner's guide to the complex and powerful Oracle database management system. Teaches you how to set up, query and manage your database, including principles of database design, how to manage data, generate reports and tune the system for optimal performance.
</Description>
<Price>30.00</Price>
<au_firstname>Michael</au_firstname>
<au_lastname>Abbey</au_lastname>
<Coverpic>images/Oracle.JPG</Coverpic>
</record>
<record>
<ISBN>0-201-43787-7</ISBN>
<Title>
Creating Killer Interactive Web Sites : The Art of Integrating Interactivity and Design
</Title>
<Category>web</Category>
<Description>
Creating Killer Interactive Sites is the one-of-a-kind look into the secrets of one of the world's most preeminent Web design firms. Its highly visual, inspiring approach brings a new standard to integrating design and interactivity to create successful sites. The book's companion Web site includes all the code and examples from the book, valuable tools and utilities, plus updated new, information, and tips.
</Description>
<Price>39.99</Price>
<au_firstname>Deke</au_firstname>
<au_lastname>McClelland</au_lastname>
<Coverpic>images/KillerInteractiveSites.gif</Coverpic>
</record>
<record>
<ISBN>0-201-44787-8</ISBN>
<Title>The Practical SQL Handbook</Title>
<Category>database</Category>
<Description>
The best-selling guide to learning SQL, the standard language for accessing information in relational databases. Teaches SQL as it's really used, with step-by-step lessons in the basic vocabulary and functions of the language and the processes and issues involved in developing robust applications.
</Description>
<Price>40.12</Price>
<au_firstname>Judith</au_firstname>
<au_lastname>Bowman</au_lastname>
<Coverpic>images/PracticalSQL.JPG</Coverpic>
</record>
<record>
<ISBN>0-672-30956-4</ISBN>
<Title>SQL Server 6.5 Second Edition</Title>
<Category>database</Category>
<Description>
Comprehensive guide to Microsoft SQL Server 6.5, including the latest enhancements such as Distributed Transaction Coordinator (DTC), replication to ODBC clients, SQL Enterprise Manager and SQL Web Assistant, SQL language enhancements.
</Description>
<Price>60.00</Price>
<au_firstname>David</au_firstname>
<au_lastname>Solomon</au_lastname>
<Coverpic>images/SQLUnleashed.JPG</Coverpic>
</record>
<record>
<ISBN>0-7645-4032-7</ISBN>
<Title>Photoshop 4 for Windows 95 Bible</Title>
<Category>graphics</Category>
<Description>
Comprehensive reference for Photoshop users includes step-by-step guides to everything from working wonders with layers to customizing graphics for the World Wide Web.
</Description>
<Price>50.23</Price>
<au_firstname>Deke</au_firstname>
<au_lastname>McClelland</au_lastname>
<Coverpic>images/PS4Bible.JPG</Coverpic>
</record>
<record>
<ISBN>1-26592-234-2</ISBN>
<Title>Web Page Design : A Different Multimedia</Title>
<Category>web</Category>
<Description>
Revealing the crucial differences between an ordinary Web page and an effective site, bestselling Internet author Mary E. S. Morris and co-author Randy J. Hinrichs go beyond the basics of web creation to show readers how to tackle the crucial problems of information overload at your Web site, getting lost in cyberspace, bandwidth constraints required to hold a user's attention, and more.
</Description>
<Price>19.96</Price>
<au_firstname>David</au_firstname>
<au_lastname>Flanagan</au_lastname>
<Coverpic>images/WebPageDesign.gif</Coverpic>
</record>
<record>
<ISBN>1-549514-32-1</ISBN>
<Title>Information Architecture for the World Wide Web</Title>
<Category>web</Category>
<Description>
With a swift and convincing stroke, the authors of Information Architecture for the World Wide Web tear down many entrenched ideas about Web design. Flashy animations are cool, they agree, as long as they don't irritate the viewer. Nifty clickable icons are nice, but are their meanings universal? Is the search engine providing results that are useful and relevant? This book acts as a mirror and with careful questioning causes the reader to think through all the elements and decisions required for well-crafted Web design.
</Description>
<Price>19.34</Price>
<au_firstname>Louis</au_firstname>
<au_lastname>Rosenfeld</au_lastname>
<Coverpic>images/InformationArchitecture.gif</Coverpic>
</record>
<record>
<ISBN>1-56204-223-1</ISBN>
<Title>
The Non-Designer's Web Book : An Easy Guide to Creating, Designing, and Posting Your Own Web Site
</Title>
<Category>web</Category>
<Description>
The Non-Designer's Web Book is a pretty, full-color guide for aspiring Web designers. The authors first explain how to browse and search the Web and then discuss how to plan and post a Web site. Then they get you into the real work of designing Web sites, whether for business or personal purposes. The authors teach you basic design principles--covering such areas as alignment, proximity, repetition, and contrast--and then discuss design issues that are specific to the Web: You learn about creating pages with careful attention to color, graphics, typography, tables, and more. Finally, you learn how to test, fix, upload, update, and register your site. The book isn't an HTML primer, but you do get a few tips on tweaking your pages by editing HTML code.
</Description>
<Price>23.96</Price>
<au_firstname>Robin</au_firstname>
<au_lastname>Williams</au_lastname>
<Coverpic>images/NonDesignerWebBook.gif</Coverpic>
</record>
<record>
<ISBN>1-56542-264-4</ISBN>
<Title>
Elements of Web Design : The Designer's Guide to a New Medium
</Title>
<Category>graphics</Category>
<Description>
Elements of Web Design helps designers learn how the experts plan and design their Web sites. It"s ideal for readers who haven"t yet learned what the Web is all about, but who'd like to start applying their design and management skills to Web-site production. The book provides a history of the Web, examples of well-designed sites, and information on coding HTML and preparing Web graphics.
</Description>
<Price>31.96</Price>
<au_firstname>Michael</au_firstname>
<au_lastname>Groh</au_lastname>
<Coverpic>images/ElementsOfWebDesign.gif</Coverpic>
</record>
<record>
<ISBN>1-56592-234-4</ISBN>
<Title>JavaScript: The Definitive Guide</Title>
<Category>programming</Category>
<Description>
A thorough description of the JavaScript programming language, complete with sophisticated programming examples, as well as a definitive, in-depth reference section covering each JavaScript function, object method, property and event handler.
</Description>
<Price>33.23</Price>
<au_firstname>David</au_firstname>
<au_lastname>Flanagan</au_lastname>
<Coverpic>images/JavaScript.JPG</Coverpic>
</record>
<record>
<ISBN>1-56604-286-0</ISBN>
<Title>
The Visual Guide to Microsoft Access for Windows 95
</Title>
<Category>database</Category>
<Description>
A graphical approach to using Microsoft Access 95 to build, customize and manage databases.
</Description>
<Price>35.36</Price>
<au_firstname>Michael</au_firstname>
<au_lastname>Groh</au_lastname>
<Coverpic>images/MSAccess.JPG</Coverpic>
</record>
<record>
<ISBN>1-56884-230-9</ISBN>
<Title>Visual Basic 4 for Windows for Dummies</Title>
<Category>programming</Category>
<Description>
The fun and easy way to learn the fundamentals of Windows programming with Visual Basic. For novice programmers and seasoned professionals who want an easy-to-use reference, this book shows you how to use Visual Basic to begin programming and designing attractive interfaces in no time, without any intimidating jargon.
</Description>
<Price>20.99</Price>
<au_firstname>Deke</au_firstname>
<au_lastname>McClelland</au_lastname>
<Coverpic>images/VBDummies.JPG</Coverpic>
</record>
<record>
<ISBN>1-57521-014-2</ISBN>
<Title>Teach Yourself Web Publishing With HTML in 14 Days</Title>
<Category>HTML</Category>
<Description>
Step-by-step guide to learning HTML and Web publishing--everything from the fundamentals of creating a simple home page to the intricacies of designing and creating elaborate Web sites with advanced HTML and CGI scripts.
</Description>
<Price>40.34</Price>
<au_firstname>Laura</au_firstname>
<au_lastname>Lemay</au_lastname>
<Coverpic>images/WebPubHTML.JPG</Coverpic>
</record>
<record>
<ISBN>1-845577-86-7</ISBN>
<Title>
Designing With JavaScript : Creating Dynamic Web Pages
</Title>
<Category>JavaScript</Category>
<Description>
Designing with JavaScript is an excellent learn-by-example tutorial that helps you create dynamic content for your Web site. Each chapter tackles a single topic with a relaxed and conversational tone. The thoroughly explained examples in each chapter are blocked off in green for quick reference and included on the accompanying CD-ROM.
</Description>
<Price>23.96</Price>
<au_firstname>Nick</au_firstname>
<au_lastname>Heinle</au_lastname>
<Coverpic>images/DesigningWithJavaScript.gif</Coverpic>
</record>
<record>
<ISBN>1-861001-26-6</ISBN>
<Title>Active Server Pages 2.0 Professional Guide</Title>
<Category>web</Category>
<Description>
Professional Guide to Microsoft's server-based technology desinged to create dynamically generated HTML pages for the World Wide Web or corporate internets.Explains how Active Server pages fit into the grand scheme of things and how you can use it to build great web sites and intranet applications
</Description>
<Price>60.00</Price>
<au_firstname>Alex</au_firstname>
<au_lastname>Federov</au_lastname>
<Coverpic>images/ProASP.JPG</Coverpic>
</record>
<record>
<ISBN>1-882537-15-8</ISBN>
<Title>
Creating the Virtual Store : Taking Your Web Site from Browsing to Buying
</Title>
<Category>web</Category>
<Description>
Learn how to turn "lookers" into "buyers" by creating a virtual store that will show off your company's goods and services. The author, a co-founder of CyberCash, shows businesses how to convert their existing Web sites into commercial venues that can handle sales and payments directly over the Internet.
</Description>
<Price>19.96</Price>
<au_firstname>Laura</au_firstname>
<au_lastname>Lemay</au_lastname>
<Coverpic>images/CreatingVirtualStore.gif</Coverpic>
</record>
<record>
<ISBN>1-883577-85-3</ISBN>
<Title>Database Publishing on the Web and Intranets</Title>
<Category>web</Category>
<Description>
Shows you, step-by-step, how to master database publishing on the Web and Intranets so that you can easily create and maintain a database-driven Web site that can change on the fly. Includes use of the latest Web technologies and languages like ODBC, Java, JavaScript and Visual Basic, and a review of off-the-shelf Web database development tools.
</Description>
<Price>40.00</Price>
<au_firstname>Curt</au_firstname>
<au_lastname>Lang</au_lastname>
<Coverpic>images/ProASP.JPG</Coverpic>
</record>
</root>

0 个答案:

没有答案