xsl-list
[Top] [All Lists]

RE: [xsl] Compound filter in for-each

2009-03-25 11:51:29
Wendell

Thank you so much for this broader advice - I very much appreciate you taking 
the trouble.

I have worked with XSLT before but very much on an intermittent and ad-hoc 
basis, to solve particular immediate problems. And as you suggest, that has 
involved guesswork, borrowing and adapting code where I can find it, searching 
on the Web and asking questions of this list. I have done some reading, notably 
the introductory chapters of Michael Kay's XSLT 1.0 Programmer's Reference book 
a few years ago, and more recently his XSLT 2.0 update. I've also looked at 
some basic tutorials on the Web. I have found the concepts difficult to grasp 
(again, as you suggest, I'm more familiar with procedural languages) though I 
had thought some of it was falling into place. Its clear I need to study some 
more, and in particular look at XPath in depth.

I am keen to become proficient (I find the approach fascinating) so thanks 
again for the advice and encouragement.

Best wishes

Alan

Alan Hale
Uwch Botanegydd ag Ymgynghorydd Is-blanhigion/Senior Botanist and Advisor on 
Lower Plants
Cyngor Cefn Gwlad Cymru/Countryside Council for Wales
Plas Gogerddan
Aberystwyth
Cymru/Wales
SY23 3EE
Tel. 01970 821101
(Dysgwr)

Wendell Piez <wapiez(_at_)mulberrytech(_dot_)com> 15:03 25 March 2009 >>>
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(_at_)mulberrytech(_dot_)com 
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list 
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ 
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>