RE: [xsl] Compound filter in for-each

Subject: RE: [xsl] Compound filter in for-each
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Mar 2009 11:03:50 -0400
Alan,

You are certainly welcome to the help.

Considering your posts, I also think you would be well served by a good introductory treatment or tutorial. Not only are you still guessing when it comes to the XPath, but also it appears that your code is not yet taking advantage of the XSLT processing model, which is characterized by a general preference for template matching over explicit conditionals using xsl:choose or xsl:if. This isn't surprising if you're new to the language. Template matching requires a rather different kind of thinking from the imperative statements typical of procedural languages, although it is just as predictable and logical once you get the hang of it.

Related to this, it appears that a good part of the reason why you aren't using a template matching approach is that you are faced with a kind of problem (essentially, flattening a very regular structure) that doesn't need it and wouldn't necessarily even take advantage of it. In a sense, the problem you are solving hasn't actually demanded that you "take the plunge". While XSLT is perfectly able to do what you're doing with it, it doesn't have to do it in a particularly XSLT-like way. Other kinds of problems, on the other hand....

Competency in XSLT really requires at least two things: proficiency (if not absolute mastery) of XPath syntax, and a certain comfort level with the related concept of context (which you've now taken in) and the applying and matching of templates that is at the heart of its processing model. This is the case even (or especially) when working with problems that are outside the core problem domain of straightforward conversions of semi-structured input. (As noted, your input looks very structured.)

I bet if you take a few hours to study the language on its own (on the net or with a good book), if only as an academic exercise and out of curiosity, you'll be much better able to move forward and learn more quickly.

Questions you might ask yourself are:

What are templates and how to they work?
What sorts of transformation problems take advantage of templates?
What does the basic grammar of XPath look like?

Put this together with what you've recently learned about processing context, and you'll be well on your way.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread