Outputting form elements using XSLT

I am trying to output a disabled checkbox using XSLT. If the value of the checkbox is "true", then the checkbox should be checked. I have tried two different methods, but the XML parser is not outputting the checkbox, or any form elements for that matter. I am using MSXML4. Is there another way to do it?

These are the two approaches that I have tried:

      <xsl:element name="input">
            <xsl:attribute name="type">checkbox</xsl:attribute>
            <xsl:attribute name="checked">true</xsl:attribute>
            <xsl:attribute name="disabled">true</xsl:attribute>
      </xsl:element>
      
      <input type="checkbox">
            <xsl:attribute name="disabled"/>
            <xsl:if test="Value = 'true'">
                  <xsl:attribute name="Checked"/>
            </xsl:if>
      </input>




mariitaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dualsoulCommented:
hm.....
ok, here is the my sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<root>
      <Value>true</Value>
</root>

, and XSLT to output checkbox:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>      
      <xsl:template match="/">
            <input type="checkbox" disabled="disabled">          
                    <xsl:if test="/root/Value = 'true'">
                           <xsl:attribute name="checked">checked</xsl:attribute>
                    </xsl:if>
             </input>
      </xsl:template>
</xsl:stylesheet>


, it seems it works fine :)

if you still can't get idea how to make your xslt work, post your xml and xslt please.
0
mariitaAuthor Commented:
It also works fine for me when I isolate it, but in the context of this particular XSLT stylesheet the parser seems to ignore the directive to output HTML form elements. Under what circumstances will the parser *not* output HTML? Is there a way to force the output?

M


0
dualsoulCommented:
it would be better if you post your xml and xslt, it's hard to understand what is not working without seeing the sources.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mariitaAuthor Commented:
Here is the XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?altova_samplexml C:\Documents and Settings\mamuchastegui\Desktop\Debug\ConfirmBillerInfoDES.xml?>
<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&#160;:</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 impayés totaux indiqués sur votre dernière facture. Exemple : 1000,99 ou 1000,99 lorsque le montant est négatif.</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@maria.com</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 plutôt 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'idée des factures en ligne.]</Description>
</Field>
</BillerParameters>
</Form>
</PageSpecific>
</PresentationData>





0
dualsoulCommented:
uh...the problem is due to using microsoft's extensions. This is not pure XSLT, you build your output in variable, and then using node-set() function to get resulting tree, somewhere here you loose the structure...hm....

i need to explore it a bit before i can answer. By the way why don't use pure XSLT solution?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mariitaAuthor Commented:
You're right. I do need to use the node-set function, but I don't need to build the HTML in the node-set itself. I can do that later.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.