This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: dynamically select an element
- From: yan bai <bytj at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 5 Feb 2002 11:13:50 -0800 (PST)
- Subject: RE: [xsl] dynamically select an element
- Reply-to: xsl-list at lists dot mulberrytech dot com
Andrew,
That's a great solution to my problem.
Thank you again.
Yan
--- Andrew Welch <andrew@thebristoldirectory.com>
wrote:
>
> Yan,
>
> You need to pass as a parameter the required field
> from the form to the XSL
> stylesheet.
>
> You can do this using Javascript on the client or
> ASP on the server (in a
> general windows environment...)
>
> To do this clientside, using msxml4:
>
>
> ==html==
> <form name="searchForm" action="searchXML()">
> <input type="text" id="searchVal"/>
> <input type="submit"/>
> </form>
>
> ==javascript==
> function searchXML()
> {
> xml = new
> ActiveXObject("Msxml2.DOMDocument.4.0");
> xml.async=false;
> xml.load("yourXML.xml");
>
> xsl = new
> ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
> xsl.async=false;
> xsl.load("yourXSL.xsl");
>
> xslTemp = new
> ActiveXObject("Msxml2.XSLTemplate.4.0");
> xslTemp.stylesheet = xsl;
>
> xslProc = xslTemp.createProcessor();
> xslProc.input = xml;
>
>
xslProc.addParameter("param1",document.searchForm.searchVal.value);
> //pull value from form
>
> document.write(xslProc.transform);
> }
> </SCRIPT>
>
> ===xsl==
> <?xml version='1.0'?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:param name="param1"/>
>
> <xsl:template match="/">
> <xsl:apply-templates
> select="*[local-name()=$param1]"/>
> </xsl:apply-templates>
>
> ........and so on
>
>
> I hope this is a start
>
> cheers
>
>
> andrew
>
>
> ===
>
>
>
>
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On
> Behalf Of yan bai
> Sent: Tuesday, February 05, 2002 2:40 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] dynamically select an element
>
>
> Hi, Gurus,
>
> I'd like to have a form in a html page, which allows
> a
> user to select the wanted elements to view data from
> an XML file. How can I do that? I know someone
> ask
> the same question in this list or somewhere else.
> But
> I just can find it. Hope you can help.
>
> Thanks so much.
>
> Yan
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE Valentine eCards with Yahoo! Greetings!
> http://greetings.yahoo.com
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
>
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list