Radiobuttons in XML / XSL

Questions about XML that are not covered by the other forums should go here.
Mario777
Posts: 4

Radiobuttons in XML / XSL

Fri Apr 04, 2014 2:37 pm

First: Sorry, my english is not the best, but I try to write as good as possible.

My Path in .XML file:

Code: Select all

<ClinicalDocument>
<recordTarget>
<patientRole>
<rezeptgebuehrenbefreiung>ja</rezeptgebuehrenbefreiung>


If in .XML file in

Code: Select all

<rezeptgebuehrenbefreiung>


is a "yes", then the result should be:

yes (radiobutton=checked) (radiobutton) no

If in .XML in

Code: Select all

<rezeptgebuehrenbefreiung>


is a "no", then the result should be:

yes (radiobutton) (radiobutton=checked) no

In my .XSL file it looks like this as far:

Code: Select all

...
<xsl:variable name="rezeptgebbefr">
<xsl:choose>

<xsl:when test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:rezeptgebuehrenbefreiung">

<xsl:value-of select="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:rezeptgebuehrenbefreiung"/>

</xsl:when>

<xsl:otherwise>unspecified</xsl:otherwise>

</xsl:choose>

</xsl:variable>
...


I don't know how I get the radiobuttons to the correct place. I tried different solutions of Google, but they also don't work.

Maybe somebody can help me! Thank you very much!

Greetings, Mario
Jamil
Posts: 77

Re: Radiobuttons in XML / XSL

Sat Apr 05, 2014 6:40 am

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<n1:ClinicalDocument xmlns:n1="localhost">
    <n1:recordTarget>
        <n1:patientRole>
            <n1:rezeptgebuehrenbefreiung>yes</n1:rezeptgebuehrenbefreiung>
        </n1:patientRole>
    </n1:recordTarget>
</n1:ClinicalDocument>


Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:n1="localhost" exclude-result-prefixes="xs" version="1.0">
   
    <xsl:output method="html"/>
   
    <xsl:template match="/">
        <html>
            <head><title>test</title></head>
            <body>
                <form action="">
                    <xsl:if test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:rezeptgebuehrenbefreiung='yes'">
                        <xsl:text disable-output-escaping="yes">&lt;input type="radio" name="answer" value="yes" checked>Yes</xsl:text>
                        <xsl:text disable-output-escaping="yes">&lt;input type="radio" name="answer" value="no">No</xsl:text>
                    </xsl:if>
                    <xsl:if test="/n1:ClinicalDocument/n1:recordTarget/n1:patientRole/n1:rezeptgebuehrenbefreiung='no'">
                        <xsl:text disable-output-escaping="yes">&lt;input type="radio" name="answer" value="yes">Yes</xsl:text>
                        <xsl:text disable-output-escaping="yes">&lt;input type="radio" name="answer" value="no" checked>No</xsl:text>
                    </xsl:if>
                </form>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 0 guests