As has been commented it depends if you are assuming things
about your input that you didn't state, but in general this
doesn't fully answer your request (and neither did the
version I posted, they both made (slightly different assumptions)
For example the above doesn't test that the nearest (choice
or define) ancestor is a choice, which is, I think what you asked.
It is indeed.
It would be true on
define
choice
define
ref
Which would be wrong for my use-case.
perhaps the most direct way of saying
nearest (choice or define) ancestor is a choice
would be
ancestor::*[self::define or self::choice][1][self::choice]
^^^^^^^
Shouldn't that be self::define?
More assumptions.
choice may(or may not) be in position 1, i.e. parent of the current node,
no, wait one,
DC isn't wrong enough times (except in his typing).
The or condition latches onto the first (ancestor) choice,
then 'requires' there be a choice nearer the document root.
Neat David, neat :-)
Math logic always makes me smile!
Since I now know that choice is never an ancestor of define,
as David Rosenborg pointed out, the simpler
<xsl:when test="ancestor::rng:choice"> is sufficient.
And now, adding DC logic, i.e. knowing that
a) I will always have a define as an ancestor,
b) Some form of Karnaugh probably reduces [self::choice][1][self::define]
to ancestor::choice.
Thanks David.
regards DaveP
--
DISCLAIMER:
NOTICE: The information contained in this email and any attachments is
confidential and may be privileged. If you are not the intended
recipient you should not use, disclose, distribute or copy any of the
content of it or of any attachment; you are requested to notify the
sender immediately of your receipt of the email and then to delete it
and any attachments from your system.
RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants. However, it
cannot accept any responsibility for any such which are transmitted.
We therefore recommend you scan all attachments.
Please note that the statements and views expressed in this email and
any attachments are those of the author and do not necessarily represent
those of RNIB.
RNIB Registered Charity Number: 226227
Website: http://www.rnib.org.uk