Solved

XML and HTML Forms

Posted on 2000-03-14
10
248 Views
Last Modified: 2012-08-14
   I have a XML document that I am combining with and XSL document to produce an HTML document.  This is creating a form that with the information from the XML document filling out the form, i.e. <Name>Paul</Name> ends up creating a textbox with Paul written in the textbox.
    This part of the document is fine, the problem that I am having is with the Checkboxes section.  I want to have one of the pieces of information displayed as checkboxes or option buttons.  So basically I have <CarBenefits>Auto Program</CarBenefits> and on the page I have two option buttons one that says Auto Program and one that says 29 Cents Per Mile.  I want the Option Button that has the same Value as the what is in the CarBenefits tag to be selected.  
    Here is what I have
<input type="radio" value="Auto Program" name="CarBenefits">Auto Program

<input type="radio" name="CarBenefits" value="Twenty Nine Cents Per Mile">29 Cents Per Mile
0
Comment
Question by:cavacasp
  • 5
  • 4
10 Comments
 
LVL 2

Expert Comment

by:meming
ID: 2620416
Try:

<xsl:template match="CarBenefit">
    <xsl:choose>
      <xsl:when test="contains(.,'Auto Program')">
<input type="radio" value="Auto Program" name="CarBenefits" checked>Auto Program
<input type="radio" value="Twenty Nine Cents Per Mile" name="CarBenefits">29 Cents Per Mile
      </xsl:when>
      <xsl:otherwise>      
<input type="radio" value="Auto Program" name="CarBenefits">Auto Program
<input type="radio" value="Twenty Nine Cents Per Mile" name="CarBenefits" checked>29 Cents Per Mile
    </xsl:otherwise>
    </xsl:choose>
</xsl:template>
0
 

Author Comment

by:cavacasp
ID: 2620953
I am getting the following error

Keyword xsl:template may not be used here.


Because the template keyword can not be used in the middle of the XSL document inside of another XSL document.  I have a document that uses xsl:template to parse the whole document, so I con't use the template tag inside of the other one.  So what can I do to accomplish this.
0
 
LVL 2

Expert Comment

by:meming
ID: 2620996
<xsl:template match="whatever">
<!-- ....  -->
   <xsl:apply-templates select="CarBenefit"/>
<!-- ....  -->
</xsl:template>
<!-- previous code goes here -->


This should work. You need to apply the new template inside your existing one.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:cavacasp
ID: 2621037
Now I'm getting the error

Unknown method. -->contains(.<--, 'FullTime')

on this

<xsl:template match="EmploymentStatus">
      <xsl:choose>
            <xsl:when test="contains(., 'FullTime')">
                  <TD Width="31%"><INPUT Type="radio" name="EmploymentStatus" Value="FullTime" Checked="" /><FONT face="times new roman" size="1">Full-Time</FONT></TD>
                  <TD Width="23%"><INPUT Type="radio" name="EmploymentStatus" Value="PartTime" /><FONT face="times new roman" size="1">Part-Time</FONT></TD>
                  <TD Width="21%"><INPUT Type="radio" name="EmploymentStatus" Value="CompanyTemporary" /><FONT face="times new roman" size="1">Company Temporary</FONT></TD>
                  <TD Width="25%"><INPUT Type="radio" name="EmploymentStatus" Value="AgencyTemporray" /><FONT face="times new roman" size="1">Agency Temporary</FONT></TD>
            </xsl:when>
            <xsl:when test="contains(., 'PartTime')">
                  <TD Width="31%"><INPUT Type="radio" name="EmploymentStatus" Value="FullTime" /><FONT face="times new roman" size="1">Full-Time</FONT></TD>
                  <TD Width="23%"><INPUT Type="radio" name="EmploymentStatus" Value="PartTime" Checked="" /><FONT face="times new roman" size="1">Part-Time</FONT></TD>
                  <TD Width="21%"><INPUT Type="radio" name="EmploymentStatus" Value="CompanyTemporary" /><FONT face="times new roman" size="1">Company Temporary</FONT></TD>
                  <TD Width="25%"><INPUT Type="radio" name="EmploymentStatus" Value="AgencyTemporray" /><FONT face="times new roman" size="1">Agency Temporary</FONT></TD>
            </xsl:when>
            <xsl:when test="contains(., 'CompanyTemporary')">
                  <TD Width="31%"><INPUT Type="radio" name="EmploymentStatus" Value="FullTime" /><FONT face="times new roman" size="1">Full-Time</FONT></TD>
                  <TD Width="23%"><INPUT Type="radio" name="EmploymentStatus" Value="PartTime" /><FONT face="times new roman" size="1">Part-Time</FONT></TD>
                  <TD Width="21%"><INPUT Type="radio" name="EmploymentStatus" Value="CompanyTemporary" Checked="" /><FONT face="times new roman" size="1">Company Temporary</FONT></TD>
                  <TD Width="25%"><INPUT Type="radio" name="EmploymentStatus" Value="AgencyTemporray" /><FONT face="times new roman" size="1">Agency Temporary</FONT></TD>
            </xsl:when>
            <xsl:otherwise>
                  <TD Width="31%"><INPUT Type="radio" name="EmploymentStatus" Value="FullTime" /><FONT face="times new roman" size="1">Full-Time</FONT></TD>
                  <TD Width="23%"><INPUT Type="radio" name="EmploymentStatus" Value="PartTime" /><FONT face="times new roman" size="1">Part-Time</FONT></TD>
                  <TD Width="21%"><INPUT Type="radio" name="EmploymentStatus" Value="CompanyTemporary" /><FONT face="times new roman" size="1">Company Temporary</FONT></TD>
                  <TD Width="25%"><INPUT Type="radio" name="EmploymentStatus" Value="AgencyTemporray" Checked="" /><FONT face="times new roman" size="1">Agency Temporary</FONT></TD>
            </xsl:otherwise>
      </xsl:choose>
</xsl:template>



this section of code is after </xsl:template> and the </xsl:stylesheet> tag.  I can include the whole Stylesheet if you need me to, but it is very long about 300 lines.
0
 
LVL 2

Expert Comment

by:meming
ID: 2621058
If you are using IE5, it doesn't support the W3C recommended XSLT. You would need to do some Javascript to get it to work then.
0
 

Author Comment

by:cavacasp
ID: 2621078
Yes I am using IE5 so what do I have to do Anybody?
0
 

Author Comment

by:cavacasp
ID: 2621152
Adjusted points from 200 to 300
0
 

Author Comment

by:cavacasp
ID: 2621153
Somebody please help.  Any idea on how to go about doing this.
0
 
LVL 2

Accepted Solution

by:
meming earned 300 total points
ID: 2621619
http://msdn.microsoft.com/xml/reference/xsl/Examples.asp

<xsl:template match="CarBenefit[.='Auto Program']">
<input type="radio" value="Auto Program" name="CarBenefits" checked>Auto Program
<input type="radio" value="Twenty Nine Cents Per Mile" name="CarBenefits">29 Cents Per Mile
</xsl:template>

<xsl:template match="CarBenefit[.='Twenty Nine Cents Per Mile']">
<input type="radio" value="Auto Program" name="CarBenefits">Auto Program
<input type="radio" value="Twenty Nine Cents Per Mile" name="CarBenefits" checked>29 Cents Per Mile
</xsl:template>

Try this...
0
 
LVL 2

Expert Comment

by:Jagar
ID: 2623699
   OK I am not getting the radio buttons, but am getting the rest of the form displayed.  
    In the main part where I have a for-each statement I have this

<tr>
<td width="100%"><FONT face="times new roman" size="1">Why is employee being replaced:</FONT>
<xsl:apply-templates select="ReasonForReplacement"/>
</td>
</tr>

Then outside of that main template part I have this
<xsl:template match="ReasonForReplacement[.='Termination']">
<input type="radio" name="ReasonForReplacement" value="Termination" Checked="" /><FONT face="times new roman" size="1">Termination </FONT>
<input type="checkbox" name="ReasonForReplacement" value="Transfer" /><FONT face="times new roman" size="1">Transfer</FONT>
</xsl:template>
<xsl:template match="ReasonForReplacement[.='Transfer']">
<input type="radio" name="ReasonForReplacement" value="Termination" /><FONT face="times new roman" size="1">Termination</FONT>
<input type="checkbox" name="ReasonForReplacement" value="Transfer" Checked="" /><FONT face="times new roman" size="1">Transfer</FONT>
</xsl:template>


But in the form where the ReasonForReplacement button should be there is nothing.

What am I doing wrong?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question