Subject: Re: [xsl] ancestor/subsequent descendant test From: "C. M. Sperberg-McQueen" <cmsmcq@xxxxxxxxxxxxxxxxx> Date: Sat, 28 Mar 2009 11:58:05 -0600 |
My input documents are allowed to contain nested sections. An optional
attribute marks out certain sections as significant. I want to detect a
situation in which a section which contains a descendant significant section
does not contain a subsequent INsignificant section (other than descendants
of any significant sections). It's complicated because the nested sections
are not (necessarily) immediate descendants of each other.
I think this may be one of those situations which benefit from looking at it in more than one way. If I've understood your requirement correctly, you want to detect a situation that has two components (or more). Actually, you name three components: (1) a section, containing (2) a significant section, and also (3) an insignificant section following the significant one.
The complexity of formulating the test can vary a lot depending on where you detect it from. If all you want is to see an error message during processing of the input, you can put the test wherever it's most convenient. And even if you don't have that freedom but MUST detect it from a particular location, it can be useful prep work to try three formulations: can you detect this situation from section (1)? from (2)? from (3)?
If I have understood you correctly, detecting the problem from location (3) amounts to finding an insignificant section which (a) has a preceding sibling which is a significant section, and (b) is not, itself, a descendant of a significant section. (Actually, I'm not sure whether being a descendant of a significant section makes the situation OK or not -- if not, adjust the test.) You can match and handle such sections with a template like this:
If the preceding significant section is not necessarily a sibling, but might be a child of 'include', the expression "preceding-sibling::section[@sig='Y']" will of course need to become more complicated.
You can detect sections which appear in role (2) of this configuration with a very similar pattern (use following-sibling, not preceding-sibling).
And the property of sections in role (1) is that they contain a descendant section in role (2) or role (3), so a template for them could be
Add 'terminate="yes"' to any of these messages if you want this to be a fatal error.
Your draft template makes things more complicated than they need to be, by matching a significant section and then climbing to its first ancestor section. It would be simpler just to test for following siblings which are insignificant sections, or (if this is necessary) which are 'include' elements with insignificant sections as children:
-- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xhtml2cals table stylesheet, Roman Huditsch | Thread | [xsl] Numbering new nodes using con, Michael Ludwig |
RE: [xsl] substring after/substring, Michael Kay | Date | [xsl] xhtml2cals table stylesheet, Roman Huditsch |
Month |