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

Re: Option in form problem

Subject: Re: Option in form problem
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 08 May 2000 11:57:01 -0400
xsl element option
At 00/05/08 11:12 -0400, Elder, Larry wrote:
I'm trying to create a blank line in a drop down list. The list is inside a
form, obviously.

What I'm using, and works BTW, is...

<xsl:element name="OPTION">
  <xsl:attribute name="SELECTED"/>
  </xsl:element>

The output I get is

<Option selected="" />

Correct, because you haven't supplied a value for the attribute.


You can use a literal result element:

<OPTION selected="selected"/>

... or instructions:

<xsl:element name="OPTION">
  <xsl:attribute name="selected">selected</xsl:selected>
</xsl:element>

What I want is the more robust...

<Option selected />

Actually, "robust" isn't the word to use here ... SGML markup minimization allows the name of the attribute to be omitted when the available tokens are unique. If you looked at the SGML Document Type Definition for HTML you would find:


<!ELEMENT OPTION - O (#PCDATA)*>
<!ATTLIST OPTION
        selected (selected) #IMPLIED
        value  CDATA  #IMPLIED -- defaults to element content --
        >

The SGML way of specifying this without using minimization is:

<OPTION selected="selected"></OPTION>

This need is recognized by XSLT processors recognizing the HTML output method, thus those processors will suppress the attribute name.

I hope my example below helps (the use of the HTML document element may screw up some mail readers, such as my Eudora 4).

.............. Ken

T:\ftemp>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:template match="/">                         <!--root rule-->
 <html><body>
   <test1>
     <OPTION selected="selected"/>
   </test1>
    <test2>
     <xsl:element name="OPTION">
       <xsl:attribute name="selected">selected</xsl:attribute>
     </xsl:element>
   </test2>
 </body></html>
</xsl:template>

</xsl:stylesheet>


T:\ftemp>xt test.xsl test.xsl
<html>
<body>
<test1><OPTION selected></OPTION></test1><test2><OPTION selected></OPTION></test
2>
</body>
</html>


T:\ftemp>

--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-04-7
Next instructor-led training:               2000-05-11/12,2000-05-15,
-                                    2000-06-12,2000-06-13,2001-01-27


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

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
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.