Generating Drop Down HTML tags with XSL

Brandt Dainow bd at internet-etc.com
Thu Jan 20 17:15:42 GMT 2000


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 at internet-etc.com
Internet Etc Ltd
http://www.internet-etc.com

>-----Original Message-----
>From: owner-xml-dev at ic.ac.uk [mailto:owner-xml-dev at ic.ac.uk]On
>Behalf Of
>Kieran O'Shea
>Sent: Thursday, January 20, 2000 12:56 PM
>To: 'xml-dev-digest at ic.ac.uk'
>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 at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN
981-02-3594-1
Unsubscribe by posting to majordom at ic.ac.uk the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email at 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 at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Unsubscribe by posting to majordom at ic.ac.uk the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email at your-subscribed-address

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





More information about the Xml-dev mailing list