Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XML and HTML Forms

Posted on 2000-03-14
10
Medium Priority
?
274 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
Technology Partners: 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 900 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

704 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