|
next
|
 Subject: Trying to embed INPUT tags in XML->HTML text transformation Author: Andrew Ballard Date: 28 Mar 2006 08:47 AM
|
I am writing a web-based tool where users can create questions for other people to answer. One of the question types is a simple fill in the blank. I have an XML structure similar to this:
<question>
<text>The colors of the rainbow are X, X, X, X, X, X, and X.</text>
<answer user-text="red"/>
<answer user-text="orange"/>
<answer user-text="yellow"/>
<answer user-text="green"/>
<answer user-text="blue"/>
<answer user-text="indigo"/>
<answer user-text="violet"/>
</question>
The character X in the text above is actually a character at the end of the Unicode table that should not appear in the text of the question, and is used as a placeholder where I want an <INPUT> tag generated in the HTML output:
The colors of the rainbow are <input .../>, <input .../>, <input .../>, <input .../>, <input .../>, <input .../>, and <input .../>.
I tried creating a recursive template to transform this, but when I used <input> tags in the template, they were always stripped out of the resulting HTML. So, I tried encoding the tags as <input ... >, which seemed to work. It's a bit clunky, but the input tags were in the HTML and the fields appeared in the browser. However, if the user includes a double quote character in their answer, the answer doesn't appear because the resulting tranformation looks like this:
<input type="text" name="Q1" value=""red""/>
Is there a way I can get this to work in XSLT?
|
|
|
|