W3C home > Mailing lists > Public > www-xsl-fo@w3.org > September 2003

Re: Newbie question...

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Thu, 18 Sep 2003 07:13:31 -0400
Message-Id: <5.2.0.9.0.20030918071049.02099518@pop.storm.ca>
To: <www-xsl-fo@w3.org>

XSLT and XPath questions would be better posted to the following list:

   http://www.mulberrytech.com/xsl/xsl-list

There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:

   http://www.dpawson.co.uk

At 2003-09-17 14:24 -0400, KC Gray wrote:
>Hello I am trying to test a value in a node and make a decision to create 
>a checkbox or a radio button based on the value.

The code looks just fine to me, so I decided to run it (after trimming the 
irrelevant rows that follow the subject of your question).

>When I run my code all the results come back with a checkbox.

When I run your code, the results come back as a mixture of radio and 
checkboxes.  The audit is below.  Except for the trimming, I haven't 
changed your work.

I hope this helps.

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


T:\ftemp>type kc.xml
<?xml version='1.0' encoding="ISO-8859-1"?>
<!DOCTYPE QUOTE_SUMMARY [
<!ELEMENT QUOTE_SUMMARY (REQUEST, VERSION, RP?, ADDRESS, PASSENGERS, PRODUCTS)>
<!ELEMENT REQUEST (HD, DT, AC, RQ, TP)>
<!ELEMENT HD (SRC, SVR)>
<!ELEMENT SRC (#PCDATA)>
<!ELEMENT SVR (#PCDATA)>
<!ELEMENT DT (D, T, D2, T2)>
<!ELEMENT D (#PCDATA)>
<!ELEMENT T (#PCDATA)>
<!ELEMENT D2 (#PCDATA)>
<!ELEMENT T2 (#PCDATA)>
<!ELEMENT AC (AGC, AG, UN)>
<!ELEMENT AGC (#PCDATA)>
<!ELEMENT AG (#PCDATA)>
<!ELEMENT UN (#PCDATA)>
<!ELEMENT RQ (TRX, TY, REF, LAN)>
<!ELEMENT TRX (#PCDATA)>
<!ELEMENT TY (#PCDATA)>
<!ELEMENT REF (#PCDATA)>
<!ELEMENT LAN (#PCDATA)>
<!ELEMENT TP (DEP, RET, ORG, DES, DAYS)>
<!ELEMENT DEP (#PCDATA)>
<!ELEMENT RET (#PCDATA)>
<!ELEMENT DES (#PCDATA)>
<!ELEMENT ORG (#PCDATA)>
<!ELEMENT DAYS (#PCDATA)>
<!ELEMENT VERSION (VERS)>
<!ELEMENT VERS (#PCDATA)>
<!ELEMENT RP (ERT?,ERS?,ERN)>
<!ELEMENT ERT (#PCDATA)>
<!ELEMENT ERS (#PCDATA)>
<!ELEMENT ERN (#PCDATA)>
<!ELEMENT ADDRESS (FA)>
<!ELEMENT FA (U, A3)>
<!ELEMENT U (#PCDATA)>
<!ELEMENT A3 (#PCDATA)>
<!ELEMENT PASSENGERS (FI+)>
<!ELEMENT FI (FN?, U, S, F, B, TE, Q1?, Q2?)>
<!ELEMENT FN (#PCDATA)>
<!ELEMENT S (#PCDATA)>
<!ELEMENT F (#PCDATA)>
<!ELEMENT B (#PCDATA)>
<!ELEMENT TE (#PCDATA)>
<!ELEMENT Q1 (#PCDATA)>
<!ELEMENT Q2 (#PCDATA)>
<!ELEMENT PRODUCTS (FC+)>
<!ELEMENT FC ((FN?| U), C, NAME, V1?, V2?, COMM, PREM, TAX)>
<!ELEMENT C (#PCDATA)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT V1 (#PCDATA)>
<!ELEMENT V2 (#PCDATA)>
<!ELEMENT COMM (#PCDATA)>
<!ELEMENT PREM (#PCDATA)>
<!ELEMENT TAX (#PCDATA)>
]>
<QUOTE_SUMMARY>
<REQUEST><HD><SRC>NET</SRC><SVR>INTERNET</SVR></HD><DT><D>20030917</D><T>141906</T><D2>20030917</D2><T2>141900</T2></DT><AC><AGC>VOYTEST</AGC><AG>VYPUBLIC</AG><UN>VOYAGEUR</UN></AC><RQ><TRX>I00000000115916</TRX><TY>Q</TY><REF>RF2803961</REF><LAN>en</LAN></RQ><TP><DEP>20031010</DEP><RET>20031020</RET><ORG>ON</ORG><DES>LAX</DES><DAYS>11</DAYS></TP></REQUEST>
<VERSION>
<VERS>1.0</VERS>
</VERSION>
<ADDRESS><FA><U>*</U><A3>ON</A3></FA></ADDRESS>
<PASSENGERS><FI><U>01</U><S>LASKDJF</S><F>ASLKDFJ</F><B>20000612</B><TE>N</TE></FI><FI><U>02</U><S>LASKDJF</S><F>SKSDKJF</F><B>20020703</B><TE>N</TE></FI></PASSENGERS>
<PRODUCTS><FC><U>*</U><C>PT</C><NAME>Deluxe 
Package</NAME><V1>1500</V1><V2>99999999</V2><COMM>$84.25</COMM><PREM>$198.00</PREM><TAX>$15.84</TAX></FC><FC><U>*</U><C>NT</C><NAME>Non-Medical 
Package</NAME><V1>1500</V1><V2>99999999</V2><COMM>$68.93</COMM><PREM>$162.00</PREM><TAX>$12.96</TAX></FC><FC><U>*</U><C>IT</C><NAME>Standard 
Package</NAME><V1>1500</V1><V2>2000</V2><COMM>$79.99</COMM><PREM>$188.00</PREM><TAX>$15.04</TAX></FC><FC><U>*</U><C>CAR</C><NAME>Rental 
Car Physical 
Damage</NAME><V1>20031010</V1><V2>20031020</V2><COMM>$58.51</COMM><PREM>$137.50</PREM><TAX>$0.00</TAX></FC></PRODUCTS>
</QUOTE_SUMMARY>
T:\ftemp>type kc.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">

<!--$Id$-->
<!--comment-->

<xsl:output method="html"/>

<xsl:template match="/">
   <xsl:apply-templates select="/*/PRODUCTS"/>
</xsl:template>

  <xsl:template match="PRODUCTS">
   <table border="0" width="100%" cellpadding="0">
    <tr>
     <td colspan="7"><br/></td>
    </tr>
    <tr>
     <td colspan="7"><b>Product Details</b></td>
    </tr>
    <tr>
     <td class="text" width="7%" align="center" 
bgcolor="#E6F2FF"><b>Select</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Package Name</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Premium</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Tax</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Variable 1</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Variable 2</b></td>
     <td class="text" bgcolor="#E6F2FF"><b>Status</b></td>
    </tr>

    <xsl:for-each select="FC">
     <tr>
     <xsl:choose>
     <xsl:when test="C='CAR'">
      <td class="number" align="center"><input 
type="checkbox"><xsl:attribute name="name">policy_code</xsl:attribute>
       <xsl:attribute name="value"><xsl:value-of 
select="C"/></xsl:attribute></input>
      </td>
     </xsl:when>
     <xsl:otherwise>
      <td class="number" align="center"><input type="radio"><xsl:attribute 
name="name">policy_code</xsl:attribute>
       <xsl:attribute name="value"><xsl:value-of 
select="C"/></xsl:attribute></input>
      </td>
     </xsl:otherwise>
     </xsl:choose>

     </tr>
    </xsl:for-each>
   </table>
  </xsl:template>

</xsl:stylesheet>
T:\ftemp>saxon kc.xml kc.xsl
<table border="0" width="100%" cellpadding="0">
    <tr>
       <td colspan="7"><br></td>
    </tr>
    <tr>
       <td colspan="7"><b>Product Details</b></td>
    </tr>
    <tr>
       <td class="text" width="7%" align="center" 
bgcolor="#E6F2FF"><b>Select</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Package Name</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Premium</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Tax</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Variable 1</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Variable 2</b></td>
       <td class="text" bgcolor="#E6F2FF"><b>Status</b></td>
    </tr>
    <tr>
       <td class="number" align="center"><input type="radio" 
name="policy_code" value="PT"></td>
    </tr>
    <tr>
       <td class="number" align="center"><input type="radio" 
name="policy_code" value="NT"></td>
    </tr>
    <tr>
       <td class="number" align="center"><input type="radio" 
name="policy_code" value="IT"></td>
    </tr>
    <tr>
       <td class="number" align="center"><input type="checkbox" 
name="policy_code" value="CAR"></td>
    </tr>
</table>





--
Next public European delivery:  3-day XSLT/2-day XSL-FO 2003-09-22
Next public US delivery:        3-day XSLT/2-day XSL-FO 2003-10-13
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/f/bc
Received on Thursday, 18 September 2003 07:13:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:11 GMT