|
Subject: Cross-referencing From: Leigh Dodds <ldodds@xxxxxxxxxxx> Date: Mon, 18 Oct 1999 15:30:38 +0100 |
Hi,
First of all, thanks for the response to my previous post,
I managed to realise what I'd done wrong. Now I've got a bit
more of a thorny problem...
Consider the following xml file:
<taxa>
<character-list>
<character number="1">
<state number="1">no legs</state>
<state number="2">2 legs</state>
<state number="3">4 legs</state>
</character>
</character-list>
<item id="1">
<item-name>Chicken</item-name>
<attribute-list>
<attribute character="1"><value>2</value></attribute>
</attribute-list>
</item>
<item id="2">
<item-name>Worm</item-name>
<attribute-list>
<attribute character="1"><value>1</value></attribute>
</attribute-list>
</item>
</taxa>
I want to produce a stylesheet that will print out the descriptions
of each animal (item). An item has a list of attributes, which can
have a particular value (sometimes more than one, and in a range, but
ignore this for now). Each value corresponds to a state within
a character (so in the above example a chicken has two legs, and
a worm has none).
I'm attempting to write a statement to grab the text of a state after
matching the value in the attribute.
e.g.
<xsl:template match="value">
<xsl:value-of select="...return the text of the corresponding state..." />
</xsl:template>
I've gotten as far as pulling out the character number from the
attribute parent:
ancestor-or-self::attribute/@character
(which gives '1' in the above example).
I then want to grab the text from the right state in the right character.
I tried something like:
//character[@number='ancestor-or-self::attribute/@character']/state[@number=
"text()"]
...which if I understand things correctly, should select state
elements whose number attribute is equal to the text of the
current node (which is a value element), and whose
character parent has a number attribute whose value matches the
chararacter attribute of my (the current nodes) parent.
(Confusing huh?).
Any suggestions on this? I thought I was pretty close, but
XT just whirrs away for a while and comes back with nothing.
(parser is IBMs XML4J).
Thanks!
L.
==================================================================
"Never Do With More, What Can Be Achieved With Less"
---William of Occam
==================================================================
Leigh Dodds Eml: ldodds@xxxxxxxxxxx
ingenta ltd Tel: +44 1225 826619
BUCS Building, University of Bath Fax: +44 1225 826283
HomePage : http://www.bath.ac.uk/~ccslrd/
WebLog : http://my.userland.com/viewChannel$1079
==================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: starts-with any number, Kay Michael | Thread | Re: Cross-referencing, Francis Norton |
| Re: Help with matching, Eric van der Vlist | Date | Re: Help with matching, Francis Norton |
| Month |