xsl-list
[Top] [All Lists]

RE: equivalent for 'while'

2005-02-16 10:37:07
Well I have an XML document which has several <DEFCONCEPT> elements. 
Each of these elements contain certain <CHILD> sub-elements 
of the form 
below:

<DEFCONCEPT id="123" name="abc">
    <CHILD ref="567">abcChild</CHILD>
</DEFCONCEPT>

<DEFCONCEPT id="567" name="abcChild">
    <CHILD ref="890">abcGrandChild</CHILD>
</DEFCONCEPT>

<DEFCONCEPT id="890" name="abcGrandChild"/>

How could I then place conditions when processing this XML 
doc such that 
it continues searching for a <CHILD> element until it finds  
'abcGrandChild' ?

I thought perhaps a single statement could loop until the condition 
becomes 'true' which is obviously not in lines with declarative
programming. How else is it then possible?

Don't think in terms of the the program processing the first element, then
the second, and so on, in a time-ordered manner. Rather, describe the set of
elements that you want to be processed: that is, preceding-siblings of the
DEFCONCEPT named "abcGrandChild":

<xsl:for-each
select="DEFCONCEPT[name="abcGrandChild"]/preceding-sibling::DEFCONCEPT"

Michael Kay
http://www.saxonica.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>
--~--