[xsl] Re: Re: <xsl:choose> or variable syntax incorrect?

Subject: [xsl] Re: Re: <xsl:choose> or variable syntax incorrect?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 26 Sep 2003 21:51:10 +0200
Kathy,


"Kathy Burke" <Kathy_Burke@xxxxxxxxx> wrote in message
news:395DE57EA5BB7F4E952B7B89775350B5021E4209@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> First, I truly appreciate your responding. But please tell me how I did
not
> "explain the problem I've solving"? I honestly thought I did!
>
> <station name='StationOne'>
> <boards>
>    <board sn='123'/>
>    <board sn='124'/>
> </boards>
> </station>
>
> If there are no <board> elements in the <station> element, I would like to
> have a blue row with the value-of the <station> name attribute as text:
>
> -----------------------------------
> Station One  (in red text)
> -----------------------------------

The confusion starts here: you say you'd have the row in blue, but present a
row in red! ???

>
> Otherwise, I would like the same text (Station One) but in a blue row.

More confusing -- if something, then the row in blue, else the row (again)
in blue ... ???

>
> I still don't understand why this doesn't work:
>
> <xsl:template match="Station">

This template  will not get instantiated at all -it mathces "Station" while
in your source.xml you have "station" elements. XPath is case-sensitive,
which means that "station" and "Station" are different names.

>
> <xsl:variable name="boards"
select="//Station[name='@name']/Boards/Board"/>

This has a zero chance of selecting anything, because the predicate will be
true only if the some "Station" element (of which there are zero in your
xml.source has a "name" child which has value equal to the string '@name'.
But t there are no "name" elements at all in your source.xml. And probably
you did not mean to find "name" elements that have the same value (the
constant string '@name').

All this makes any further analysis almost impossible.

[skip]

> Although it doesn't work, why is it SO dreadful? If I could correctly
return
> the variant I need (are there boards for this station?) wouldn't the rest
be
> ok?

Probably yes, but how can you expect that somebody will be reading this code
so far? The first part of the code contains illogical and obviously
erroneous expressions and these prevent anyone from understanding what in
the first place you were trying to do... Therefore, why would anyone
continue reading further?


>
> I came up with this either out of books or from the MANY examples I've
read
> on the newsgroups.
>
> I have read Jeni's book (and M. Kay's as well). Unfortunately, that
doesn't
> mean I've absorbed it all :-?

These books are not to be absorbed -- they are to be understood. They have
examples and exercises, which if followed and worked out ensure that the
reader would have a correct understanding and practical experience with the
topics discussed.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread