![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - RE: [xsl] data translation => descendants appear side by side in HTML-table [Thread Next] Re: [xsl] xpath - how to return all nodes but the node matching a value in an arbitrary tree?To: Date: 5/4/2002 6:50:00 PM At 2002-05-04 10:27 -0700, Scott Zagar wrote: In order to "delete" a node, I'm trying to write an xpath that, when given an id, will return the entire tree with the exception of the matching node for the id. This must be done using the processing model of XSLT and cannot be done with a single XPath expression. I hope the solution below helps. I left every other parameter you used untouched. ............. Ken t:\ftemp>type scott.xml <category id="5">music <category id="6">blues <artist id="7">bb king</artist> <artist id="8">lightnin hopkins</artist> </category> <category id="6">jazz <category id="11">bebop <artist id="12">charlie parker</artist> </category> <artist id="9">miles davis</artist> <artist id="10">john coltrane</artist> </category> </category> t:\ftemp>type scott.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" cdata-section-elements="category artist" /> <xsl:param name="delete_id"/> <xsl:template match="/|*|text()|processing-instruction()|comment()" name="copy-me"> <xsl:copy><!--copy all elements if this were the only rule--> <xsl:copy-of select="@*"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="artist"> <xsl:if test="@id != $delete_id"> <xsl:call-template name="copy-me"/> </xsl:if> </xsl:template> </xsl:stylesheet> t:\ftemp>saxon scott.xml scott.xsl delete_id="7" <category id="5"><![CDATA[music ]]><category id="6"><![CDATA[blues ]]><artist id="8"><![CDATA[lightnin hopkins]]></artist><![CDATA[ ]]></category><![CDATA[ ]]><category id="6"><![CDATA[jazz ]]><category id="11"><![CDATA[bebop ]]><artist id="12"><![CDATA[charlie parker]]></artist><![CDATA[ ]]></category><![CDATA[ ]]><artist id="9"><![CDATA[miles davis]]></artist><![CDATA[ ]]><artist id="10"><![CDATA[john coltrane]]></artist><![CDATA[ ]]></category><![CDATA[ ]]></category> t:\ftemp> -- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002 - : 3-days XML Information Modeling: July 31-August 2, 2002 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-05-06,07,09,10,13,15,20, - 06-04,07,10,11,13,14,17,20,07-31,08-05,27,30 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
