Subject: Re: [xsl] When *not* to use XLST...|
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Thu, 23 Apr 2009 15:59:03 -0400
First, you wouldn't be the guy who wrote this garbage? :)
What version of XSL are you using? (answer should be 2.0 if using it on the server :) )
On Apr 23, 2009, at 2:50 PM, Shawn Milochik wrote:
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
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.
do both where it makes sense.
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
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.
what is the discriminator? Is it something that can be determined before deployment based on some page attribute or do you need to have info at runtime?
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.
xsl:template/@match up your needs
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
yes to the first part and no to second
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.
I learned XSL by diving into the docbook XSLs and modifying those. As for books, the only one I never found useful was O'Reilly's (which is strange). Mike Kay's is the bible
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,
You can either pass it as a param or
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.
one of the best things you can do is follow and/or ask good questions on this list. Include a small XML source, your XSL try and the desired output. Usually doing this will eventually solve the problem for you. But, if you are still uncertain, show what yo9u have done and ask about a better way.