I have a requirement to do a bunch of enrollment forms in the context of
jsp. The same questions appear on many forms, but sometimes with different labels, or different options. So the same question could be marked up with one xsl in form A but another xsl in form B. So I plan to implement each question as an xml file:
question_001.xml
question_017.xml
colors.xml
The xsl will turn the question into an input, or a checkbox or a textarea and so on.
My jsp will look something like this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
<head>
<title>XYZ enrollment</title>
</head>
<body>
<div id="part1" class="question">
<c:import url="question_001.xml" var="question_001"/>
<c:import url="question_001.xsl" var="question_001.xsl"/>
<x:transform xml="${question_001}" xslt="${question_001.xsl}"/>
</div>
<div id="part2" class="boilerplate">
<c:import url="http://localhost:8080/boilerplate_001.xml" var="boilerplate_001"/>
<c:import url="http://localhost:8080/boilerplate_001.xsl" var="boilerplate_001.xsl"/>
<x:transform xml="${boilerplate_001}" xslt="${boilerplate_001.xsl}"/>
</div>
<div id="part3" class="question">
<c:import url="question_002.xml" var="question_002"/>
<c:import url="question_002.xsl" var="question_002.xsl"/>
<x:transform xml="${question_002}" xslt="${question_002.xsl}"/>
<c:import url="question_003.xml" var="question_003"/>
<c:import url="question_003.xsl" var="question_003.xsl"/>
<x:transform xml="${question_003}" xslt="${question_003.xsl}"/>
</div>
</body>
</html>
Response data will be captured in xml columns, so I have the option of exposing existing data through the view as xml, or Strings or lists or whatever.
What I don't know how to do is combine existing response data into the markup in some cases. For input fields that's easy, I can have the transform spit out the markup necessary to retrieve the field value from the view. What I don't understand is how to populate things like checkboxes. For example how can my transform know whether to insert the checked="checked" attribute if, for a <question> whose options are RED BLUE GREEN and whose presentation should be checkbox format, the existing data says the user selected GREEN?