|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: select descendant problem
This is the day for the identity transform!
At 2008-10-10 18:00 +0000, Mati Hadi wrote: select=*[not(descendant::wrapper[wrapper=bmenueb])]/>I have an xml file like this: ... I want to select all the children of the wrapper, except the children wrappers. I mean I want to select i.e from the first wrapper just title, section,section/title, section/table and section/section,but not the child wrapper, and from the child wrapper, I want to select all its children except the child wrapper, and so on. I tried to write : <xsl: for-each select=bwrapper[@class=bmenub]> <xsl:apply-templates </xsl:for-each> But this dos not work.
Now, note that the result *isn't* well-formed XML but it is a well-formed external parsed general entity. You have more than one top element in the result ... so to make this a document you'll have to wrap it in something. You can do that by adding: <xsl:template match="/">
<something>
<xsl:apply-templates/>
</something>
</xsl:template>I hope this helps. (and that I've understood your requirement!) . . . . . . . . . . . Ken t:\ftemp>type mati.xml
<wrapper class="menu">
<title>menu1</title>
<section>
<title>Indoor climate</title>
<table> some table here</table>
<section>
<title> under menus</title>
<paragraph>some text here</paragraph>
</section>
<wrapper class="menu">
<title>menu1.1</title>
<section>
<title>Temperatur</title>
<paragraph>some text here</paragraph>
</section>
<wrapper class="menu">
<title>menu1.1.1</title>
<section>
<title>Heat</title>
<paragraph>some text here</paragraph>
</section>
<wrapper class="menu">
<title>menu1.1.1.1</title>
<section>
<title>Heat2</title>
<paragraph>some text here</paragraph>
</section>
</wrapper>
</wrapper>
</wrapper>
</section>
</wrapper>t:\ftemp>call xslt mati.xml mati.xsl mati.out t:\ftemp>type mati.out
<?xml version="1.0" encoding="utf-8"?>
<title>menu1</title>
<section>
<title>Indoor climate</title>
<table> some table here</table>
<section>
<title> under menus</title>
<paragraph>some text here</paragraph>
</section> <title>menu1.1</title>
<section>
<title>Temperatur</title>
<paragraph>some text here</paragraph>
</section> <title>menu1.1.1</title>
<section>
<title>Heat</title>
<paragraph>some text here</paragraph>
</section> <title>menu1.1.1.1</title>
<section>
<title>Heat2</title>
<paragraph>some text here</paragraph>
</section></section> t:\ftemp>type mati.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template><xsl:template match="wrapper"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> t:\ftemp>rem Done! -- Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








