[xsl] When *not* to use XLST...

Subject: [xsl] When *not* to use XLST...
From: Shawn Milochik <Shawn@xxxxxxxxxxxx>
Date: Thu, 23 Apr 2009 14:50:53 -0400
I'm writing an online application (as in a form you fill out). When
printed, it's about 30 pages long, so the site has to be modular. I'm
putting sections of it into XML files and having XSLT process the
controls (text boxes, etc.) into HTML forms.

XSLT is fantastic for allowing me to define XML and then create
dynamic text boxes, check boxes, and radio buttons. However, it gets
more complicated as need to add some advanced features. I'm wondering
if I should just create a (programming) class to handle my XML pages
and have my back-end code read the XML directly and create the dynamic
HTML instead.

Below are a few things I need to do. My question is whether these
things are easy or straightforward enough in XSLT, or whether I should
just be writing server-side code to do all this. As I said earlier,
I'm brand-new to XML (as of about two weeks ago), and have just pieced
a bunch of things together from Google searches to get it working so
far. I wouldn't really say I "know" XSLT -- only that I have "been
using" XSLT.

1. For some controls, I want to automatically create additional
controls. An example would be a table which, when generated, would
also need a set of text boxes (one per column in the table), which
would be used to edit data within a table row, or add a new row.

2. If I have many simple controls in a row, for example 15 checkboxes,
I'd like to have them two or three per line, rather than one per line.
Of course, it has to gracefully handle a number of items which doesn't
divide evenly by the desired number per line.

3. Some XML nodes of the same type may have some, but not all,
possible attributes. The HTML for one case can be different than
another.

It seems that XSLT is designed to turn XML data into a formatted
document, rather than use XML data to create dynamic forms, and maybe
I should just be writing code. I just wanted to check in with the list
to see whether the problem is more due to my lack of knowledge about
XSLT than limitations of XSLT. If that's the case, let me know, and
please recommend the best book for becoming a proficient user of XSLT.

A final note which may help clarify what I'm asking for: The two most
challenging problems I've had so far were how to get the value of an
attribute of a parent node in the XSLT section that processes the
child, and how to check to see whether any of the child nodes had a
specific value in a named attribute when processing the parent node.
Both are trivial to do with a class in a programming language by just
accessing a property or method. To be fair they're trivial in XSLT as
well, but the syntax to do takes a long time to discover by Google
searches.

Thanks,
Shawn

Current Thread