Solved

XML and HTML Forms

Posted on 2000-03-14
10
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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, …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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