Page 1 of 1

Radiobuttons in XML / XSL

Posted: Fri Apr 04, 2014 2:37 pm
by Mario777
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

Re: Radiobuttons in XML / XSL

Posted: Sat Apr 05, 2014 6:40 am
by Jamil

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"><input type="radio" name="answer" value="yes" checked>Yes</xsl:text>
<xsl:text disable-output-escaping="yes"><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"><input type="radio" name="answer" value="yes">Yes</xsl:text>
<xsl:text disable-output-escaping="yes"><input type="radio" name="answer" value="no" checked>No</xsl:text>
</xsl:if>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>