|
Subject: apply-templates select question From: "Hunter, David" <dhunter@xxxxxxxxxxxx> Date: Tue, 15 Jun 1999 11:14:12 -0400 |
I have a [hopefully] simple question, regarding the apply-templates element.
Consider the following snippet of XML, and the XSL after it:
XML:
<TheRestOfTheDocument>
<Features>
<Count>2</Count>
<ID Description="c">1256</ID>
<ID Description="A">1892</ID>
</Features>
</TheRestOfTheDocument>
XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template>
<xsl:copy>
<xsl:apply-templates select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/TheRestOfTheDocument/Features">
<xsl:copy>
<xsl:apply-templates select="Count"/>
<xsl:apply-templates select="ID" order-by="+@Description"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
As you can see, what I want to do is sort the "ID" elements by their
"Description" attribute. However, I also need to include that "Count"
attribute, so I need a separate apply-templates just for it.
My question is, can I create an apply-templates that will copy everything
EXCEPT the "ID" attributes? So instead of
<xsl:apply-templates select="Count"/>
I want something similar to
<xsl:apply-templates select="not(ID)"/>
(which, obviously, doesn't work. At least, not with the IE5 XSL processor.)
The reason for this is that I'm sorting various sections of a very large
document, with a lot of similar scenarios, except that some of them might be
set up more like this:
<Blah>
<something1/>
<something2/>
<.../>
<somethingn/>
<ID Description="c">1</ID>
<ID Description="A">2</ID>
</Blah>
and I don't want to have to do a separate apply-templates for each
"something".
As I mentioned, I'm using the IE5 XSL processor, if it makes a difference.
Following are some of the misguided syntaxes I tried to use, none of which
worked:
select="not(ID)"
select="[not(ID)]"
select="[* && not(ID)]"
select="[* $and$ not(ID)]"
Thanks in advance for any light you can shed.
David Hunter
david.hunter@xxxxxxxxxxxxx
MediaServ Information Architects
http://www.MediaServ.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: String manipulation with script, Julian Reschke | Thread | Re: apply-templates select question, James Tauber |
| Re: Can solve the N-queens - but ca, Oren Ben-Kiki | Date | Re: apply-templates select question, James Tauber |
| Month |