xsl-list
[Top] [All Lists]

RE: Selecting only those nodes whos attibutes contain a given substring

2005-04-12 08:12:18
Does this reflect your situation?

Data:
<?xml version="1.0" encoding="UTF-8" ?>
<doc>
  <some-node class="menublock-selected-true" />
  <some-node class="menublock-selected-false" />
  <some-node>
    <another-node class="menublock-selected-false" />
    <another-node />
  </some-node>
  <some-node />
</doc>

Stylesheet:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:template match="*[contains(@class,'menublock-selected-')]">
    <output><xsl:value-of select="child::*/@class" /></output>
  </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Peter Hickman <peter(_at_)semantico(_dot_)com>
Sent:     Tue, 12 Apr 2005 15:26:11 +0100
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] Selecting only those nodes whos attibutes contain a given 
substring

I am having to write some XSLT that needs to decide if it needs to 
recurse into the contents of the current mode. Basically I am at a node 
and I only want to recurse into it if at least one of the child nodes 
has an attribute called "class" who's value contains the sub string 
"menublock-selected-". Otherwise I am going to skip this node.

The XML is part of an open source project so there is little chance of 
patching it up.

Any ideas?


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • RE: Selecting only those nodes whos attibutes contain a given substring, cknell <=