Re: Need help combing two elements
At 09:00 AM 3/27/2009, you wrote:
I worded it incorrectly, but yes I don't want to change the data itself, simply how it is displayed.
Don't worry, I'm just quibbling. (And maybe helping to reinforce correct impressions.)
The data is very predictable. It will always be as I've shown above, so I have no worries about that. I'm not sure what you mean by "edge cases". I'm very new to XSL, as demonstrated by my use of incorrect terminology.
In the parallel thread with Alan, we are talking about templates without using them much.
The reason templates are relevant is that they are the way XSLT manages complexity.
Managing complexity is important and relevant because XSLT is designed to deal with transformation problems where there are constraints over the input (commonly enforced with a schema to which the input must be valid), but those constraints are fairly loose, and may not govern the exact number or arrangement of elements, only their names, the names (and sometimes values) of their attributes, and their content models -- what elements they may (or may not) contain and in what general orders and combinations.
Think of processing an XHTML document as input, where you might have divs containing paragraphs, lists, tables, and paragraphs and list items may contain inline markup and anchors and what not, all in a big mishmash, and recursively when tables or divs or lists contain tables or divs or lists or whatever else, and you get the idea.
Or generalize from there to a more properly "descriptive" document tag set such as Docbook, TEI, NLM Journal, or DITA (it shouldn't be too hard to find examples of any of these on line), and you'll get an even better idea.
XSLT is perfectly capable of handling more regular inputs, such as database or structured data dumps, because this is generally an easier set of problems. (Making wooden boxes is not hard when you have power tools designed for making furniture.)
To get back to your question, "edge cases" is a way of describing possible inputs, which you are required to handle, but which are not perfectly normal or regular.
Of course, whether you have edge cases, of what sort they are (elements in a different order, elements with or without particular children or attributes, elements missing or duplicated, etc. etc.), and whether they are really "edge cases" or in fact perfectly normal, differs from one problem to another.
The first problem that needs to be considered when designing a transformation is what kind of boundaries can be drawn around the range of inputs. While these boundaries are probably obvious to you, since you are looking at the whole problem, it's a live question to any of us, since we see only the tiny piece of it you've shown.
I hope I don't sound like I'm lecturing. I'm actually just trying to draw lines around the fascinating problem of drawing lines around problems.
> But in general, the casting of values such as "Mar 23, 2006" to > "2006-05-03" is going to be more work than the combining of values > from two (or several) elements into one.
It will be much easier in XSLT 2.0 if you have the option of using that.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format