Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2013, 11:50 PM
Registered User
 
Join Date: Aug 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Map a drop-down list value to a checkbox in an XSLT

Hi

I rarely have to create an XSLT from scratch in my current position at my company but I have run into a case where I am unable to find an example to replicate.

In my XML I have a value that is derived from a drop-down list. Its a simple list that asks if you have a military spouse and the values in the drop down list are simply Yes or No for the user to select. The "Yes" value is associated with a code of "Military_Spouse" and the "No" value is associated with a simple code of "No".

If the user says Yes to having a Military Spouse I want the code to be mapped via an XSLT to a checkbox in another system that has a matching code/value. The issue I have encountered is mapping a drop down list to a checkbox.

The XML would look similar to this:

Code:
<Military_Spouse_CustomField_Code>Military_Spouse</Military_Spouse_CustomField_Code>
But I am unsure of what I should use in the XSLT. Should I do an xsl:if because I only want the checkbox in the corresponding system to be checked if the value being passed is Military_Spouse. Or do I use an xsl:when statement.

I hope this is enough information and I don't sound too stupid

Last edited by SRTrice; August 29th, 2013 at 12:11 AM..
 
Old August 29th, 2013, 12:10 AM
Registered User
 
Join Date: Aug 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am thinking I would use something similar to this:

Code:
<xsl:when test="local-name()='Military_Spouse_CustomField_Code'">
    <xsl:if test="contains(.,'Military_Spouse')">
        <Military_Spouse>Military_Spouse</Military_Spouse>
   </xsl:if>
</xsl:when>
Is that the most efficient way with xml version 1.0?

Thanks for any responses/help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help required to plot seat map using xml and xslt Smiley XSLT 1 August 4th, 2013 08:43 AM
XSLT 2.0 array/map geek.shrek XSLT 5 November 2nd, 2007 10:20 AM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
checkbox and the drop down menu in update form phudong3da Dreamweaver (all versions) 3 May 4th, 2005 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.