Solved

XML and HTML Forms

Posted on 2000-03-14
10
235 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now