Subject: Re: Preserve ancestors/discard children From: "Nikolai Grigoriev" <grig@xxxxxxx> Date: Sun, 19 Dec 1999 23:46:49 +0300 |
John Robert Gardner <jrgardn@xxxxxxxxx> wrote: >For the following XML, I'm trying to "shave off" all the <ul>'s, each of >of which has only a "class="L"" attribute to distinguish its <li>'s. In >other I only want to have everything from <li class="T"> UPWARD, >with _none_ of the sub-ul's therein. This can be done by adding just one line to your stylesheet: <xsl:template select="li[@class='T']//*" precedence="1"/> It suppresses all element descendants of any <li class="T"> element. The precedence value of 1 guarantees that this rule cannot be overridden by rules with default precedence. The rule just does nothing, thus making every trace of the matching element disappear from the output. Text children of the <li class="T"> itself are not matched, and processed in a regular way. There are some caveats in this approach, e.g. you should care about not to override this rule by incautious use of <xsl:for-each>. But in regular situations, when most of the tree navigation is done by calls to <xsl:apply-templates>, this should work. Regards, Nikolai XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Preserve ancestors/discard chil, John Robert Gardner | Thread | Do you know how to refer to a node?, Jonathan Asbell |
Re: Templates aplied to namespaces, Mark D. Anderson | Date | Re: Templates aplied to namespaces, John Robert Gardner |
Month |