Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2005, 09:52 AM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forms with XML > XSLT > XHTML

This is my setup: XML > XSLT > XHTML (using transformNode method)

I want to create forms that pull data from a source XML doc, and displays the resulting data using an XSLT stylesheet. So far, I've created a form that does display the proper data with the <xsl:for-each...> method used, but the data doesn't change on the selections from the form menu.

I realize that I'm likely missing one or more steps, but I'm a complete newbie to XSLT forms, so any help would be greatly appreciated. Any good resources of info on using XSLT forms, especially without the use of scripting, would also be great.

This is what I have so far:

XML doc:

<?xml version="1.0" encoding="UTF-8"?>
<faqs>
    <faq>
        <category>all</category>
        <question>How do I do this?
        </question>
        <answer>I don't know.</answer>
    </faq>

    <faq>
        <category>option1</category>
        <question>How do I do that?
        </question>
        <answer>I'm not sure.</answer>
    </faq>

    <faq>
        <category>option2</category>
        <question>How do I do the other?
        </question>
        <answer>It depends.</answer>
    </faq>
</faqs>

XSLT doc:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:param name="pagepath">http://www.MYSITE.com</xsl:param>
<xsl:param name="selectcategory">all</xsl:param>
<xsl:param name="txtkeyword" />
    <xsl:template match="/">
        <form name="faqsearch" action="{$pagepath}" method="post">
                <table class="navyblueborder" width="100%">
                    <tr bgcolor="#333366">
                        <td colspan="2"><h6>Search</h6></td>
                    </tr>
                    <tr bgcolor="#9999cc">
                        <td width="50%"><strong>By Department</strong></td>
                        <td width="50%"><strong>By Keyword</strong></td>
                    </tr>
                    <tr>
                        <td>
                            <select name="bydept">
                                <option value="" selected="true">- Select a Category -</option>
                                <option value="all">General</option>
                                <option value="option1">Option1</option>
                                <option value="option2">Option2</option>
                            </select>
                            <input class="button" type="submit" name="submit" />
                        </td>
                        <td>
                            <input type="text" name="bykeyword" />
                            <input class="button" type="submit" name="submit" />
                        </td>
                    </tr>
                    <tr bgcolor="#9999cc">
                        <td colspan="2"><strong>Questions</strong></td>
                    </tr>
                    <xsl:for-each select="faqs/faq">
                        <xsl:sort select="question" data-type="text" order="ascending" />
                        <xsl:if test="category = $selectcategory">

                            <tr>
                                <xsl:if test="position() mod 2 != 1">
                                    <xsl:attribute name="style">background-color:#ccccff</xsl:attribute>
                                </xsl:if>
                                <td colspan="2"><a href="#"><xsl:value-of select="question" /></a></td>
                            </tr>
                        </xsl:if>
                    </xsl:for-each>
                </table>
            </form>
        </div>
    </xsl:template>
</xsl:stylesheet>
KWilliams





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I transform XSLT without the <?xml?> tag? nadavvin XSLT 4 June 10th, 2007 09:25 AM
xslt -> xhtml validation rahulsk1947 XSLT 3 May 17th, 2007 02:54 AM
XML > XSLT and ASP.NET 2.0 bonekrusher XSLT 7 September 22nd, 2006 06:26 PM
2 XML Docs > 1 XSLT Stylesheet kwilliams XSLT 3 September 12th, 2005 11:22 AM
Achitecture ? SQL -> XML -> ASP -> PDF or HTML Frm jstrong Classic ASP XML 0 July 9th, 2005 01:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.