Subject: [xsl] Outputting form elements with msxsl:node-set function From: Maria Amuchastegui <mamuchastegui@xxxxxxxxxxx> Date: Wed, 17 Nov 2004 12:11:29 -0500 |
I am trying to output a disabled checkbox using XSLT. If the value of the checkbox is "true", then the checkbox should be checked. The stylesheet uses the msxsl:node-set function to store the form data as a node set. If I don't use the msxsl:node-set function, then the checkbox is output correctly. However, I have to use the msxsl:node-set function in order to create alternating row colours. Here is the XSLT: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/> <xsl:variable name="FRM" select="PresentationData/PageSpecific/Form"/> <xsl:variable name="vBillerDataRows"> <BillerDataRow> <BillerLabel>Titulaire du compte :</BillerLabel> <BillerValue> <xsl:value-of select="$FRM/Field[@Name='AccountHolder']/Value"/> </BillerValue> </BillerDataRow> <xsl:for-each select="$FRM/BillerParameters/Field[@IsComment = '0']"> <BillerDataRow> <BillerLabel> <xsl:value-of select="Prompt"/> </BillerLabel> <BillerValue> <xsl:choose> <!-- not checkbox, just display value --> <xsl:when test="@Type != '2'"> <xsl:value-of select="Value"/> </xsl:when> <!-- checkbox, display disabled checkbox in appropriate state --> <xsl:when test="@Type = '2'"> <input type="checkbox"> <xsl:attribute name="disabled"/> <xsl:if test="Value = 'true'"> <xsl:attribute name="Checked"/> </xsl:if> </input> </xsl:when> </xsl:choose> </BillerValue> </BillerDataRow> </xsl:for-each> </xsl:variable> <xsl:template match="/"> <html> <head> <style type="text/css"> .oddRow { background-color: #E9f5e9} .evenRow { background-color: #FFFFFF} .Cellule {font-family: Arial, Helvetica, sans-serif; font-size: 75%; font-weight: normal; color: #000000; padding-left: 2px; padding-top: 2px; padding-bottom: 2px} </style> </head> <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table> <tbody> <xsl:for-each select="msxsl:node-set($vBillerDataRows)/BillerDataRow"> <tr> <xsl:attribute name="class"><xsl:choose><xsl:when test="position() mod 2 = 0">evenRow</xsl:when><xsl:otherwise>oddRow</xsl:otherwise></xsl:choose></xsl :attribute> <td width="25%" class="Cellule"> <xsl:value-of select="BillerLabel"/> </td> <td width="75%" class="Cellule"> <xsl:value-of select="BillerValue"/> </td> </tr> </xsl:for-each> </tbody> </table> </body> </html> </xsl:template> </xsl:stylesheet> ------------------------------------- And here is the XML data: <?xml version="1.0" encoding="iso-8859-1"?> <PresentationData Name="BillerInfo"> <PageSpecific> <Form Name="BillerInfo"> <Field Name="AccountHolder" Type="text" Size="50" MaxLength="50" Mandatory="yes"> <Value>MME KNTUCT MPQBHSFBO</Value> <Prompt>Account holder</Prompt> <Message/> </Field> <BillerParameters Count="4"> <Field Name="AcctParam0" Type="3" Size="20" MaxLength="20" Mandatory="1" MaskID="1" MaskString="" UseMask="0" UseCalendar="0" IsComment="0" IsAlphanumeric="0"> <Value>100</Value> <Prompt>Total d{</Prompt> <Message/> <Description>Saisissez les montants impayis totaux indiquis sur votre dernihre facture. Exemple : 1000,99 ou 1000,99 lorsque le montant est nigatif.</Description> </Field> <Field Name="AcctParam1" Type="5" Size="50" MaxLength="50" Mandatory="0" MaskID="1" MaskString="" UseMask="0" UseCalendar="0" IsComment="0" IsAlphanumeric="0"> <Value>maria@xxxxxxxxx</Value> <Prompt>Adresse de courriel</Prompt> <Message/> <Description>Si vous souhaitez recevoir un avis par courriel indiquant que vous pouvez consulter votre facture en ligne pluttt que de recevoir une facture papier, saisissez votre courriel.</Description> </Field> <Field Name="AcctParam2" Type="6" Size="10" MaxLength="10" Mandatory="1" MaskID="2" MaskString="" UseMask="1" UseCalendar="1" IsComment="0" IsAlphanumeric="0"> <Value>01-11-2004</Value> <Prompt>Date Naissance</Prompt> <Message/> <Description>[Information du fournisseur pour le client. Format JJ-MM-AAAA]</Description> </Field> <Field Name="AcctParam3" Type="2" Size="10" MaxLength="10" Mandatory="0" MaskID="1" MaskString="" UseMask="0" UseCalendar="0" IsComment="0" IsAlphanumeric="0"> <Value>true</Value> <Prompt>J'aime les factures en ligne.</Prompt> <Message/> <Description>[Indiquer ici si vous aimez l'idie des factures en ligne.]</Description> </Field> </BillerParameters> </Form> </PageSpecific> </PresentationData>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Xml2PDF formatting engine, Tokushige Kobayashi | Thread | Re: [xsl] Outputting form elements , David Carlisle |
RE: [xsl] Using key and position(), Bhupendra Singh | Date | Re: [xsl] Outputting form elements , David Carlisle |
Month |