[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Generating Drop Down HTML tags with XSL

  • From: "Brandt Dainow" <bd@i...>
  • To: "'Kieran O'Shea'" <ksh@d...>, <xml-dev-digest@i...>
  • Date: Thu, 20 Jan 2000 15:11:01 -0000

xsl drop down
Yes to first question, as follows:-

You load the XML file and the XSL file into 2 MSXML objects and use a single
line of javascript to merge them and produce output.  The XML output can be
wrapped in other stuff, such as HTML and JavaScript.  The web page looks
like this:-
*******************************************
<HTML> <HEAD> <SCRIPT>
// commence function
function doIt(){
// create 2 XML objects (1 to hold XML, 1 to hold XSL)
srcDoc = new ActiveXObject("Microsoft.xmldom");
stySht = new ActiveXObject("Microsoft.xmldom");
// load xml data from xml file
srcDoc.load("myFile.xml");
// load XSL data from xsl file
stySht.load("myXslFile.xsl")
// use XSL to transform XML into HTML and place output on page
document.all.item("outputHere").innerHTML=srcDoc.transformNode(stySht.docume
ntElement);
}
</SCRIPT> </HEAD>
<!-- activate function when page loads -->
< BODY onLoad=doIt()>
<!-- create ID marker for output -->
<DIV ID="outputHere"></DIV>
</BODY> </HTML>

Here's some sample XSL we use in one of our courses:-
 <xsl:stylesheet xmlns:xsl="uri:xsl">
 <xsl:template match="/">
 <HTML>
 <BODY>
  <H1>Phone and Fax List</H1>
 <TABLE BORDER="1" CELLPADDING="2">
 <TR>
  <TH>Name</TH>
  <TH>Phone</TH>
  <TH>Extension</TH>
  <TH>Fax</TH>
  <TH>Extension</TH>
  </TR>
 <xsl:for-each select="EMPLOYEELIST/RECORD" order-by="NAME/SECOND">
 <TR>
  <xsl:apply-templates />
  </TR>
  </xsl:for-each>
  </TABLE>
  </BODY>
  ...
 <xsl:for-each select="VOICE">
 <TD>
  <xsl:value-of select="@MAIN" />
  </TD>
 <xsl:choose>
 <xsl:when match=".[@EXTENSION]">
 <TD>
  <xsl:value-of select="@EXTENSION" />
  </TD>
  </xsl:when>
 <xsl:otherwise>
  <TD>NONE</TD>
  </xsl:otherwise>
  </xsl:choose>
  </xsl:for-each>

Now, while we're wrapping the XML with table HTML, it could just as easily
be wrapped with <SELECT> and <OPTION> tags...

In fact, wrapping XML with other stuff is (to me) exactly what XSL is for.

DOM access is not so simple.  As I understand it, it's the XQL components
which add DOM methods.  I'm sure somebody can elucidate this one, but my
understanding is that XQL is merging back into XSL to add DOM capbailities,
so we don't all have to walk the tree to access a given element.

Brandt Dainow
bd@i...
Internet Etc Ltd
http://www.internet-etc.com

>-----Original Message-----
>From: owner-xml-dev@i... [mailto:owner-xml-dev@i...]On
>Behalf Of
>Kieran O'Shea
>Sent: Thursday, January 20, 2000 12:56 PM
>To: 'xml-dev-digest@i...'
>Subject: Generating Drop Down HTML tags with XSL
>
>
>Hi,
>
>	Is there anyway of creating  a dropdown html menu using
>XSL (Option,
>Value). The Menu information will be stored
>in the XML document calling this XSL stylesheet ?
>
>	Can Javascript in XSL access the html code it contains ?
>
>
>	Can JavaScript in XSL access the DOM object for the XML document
>that calls it ?
>
>
>
>
>					Kieran O'Shea
>
>xml-dev: A list for W3C XML Developers. To post,
mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN
981-02-3594-1
Unsubscribe by posting to majordom@i... the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email@your-subscribed-address

Please note: New list subscriptions now closed in preparation for transfer
to OASIS.



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Unsubscribe by posting to majordom@i... the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email@your-subscribed-address

Please note: New list subscriptions now closed in preparation for transfer to OASIS.



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.