Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: xslt (identity?) transformation [Thread Next] Re: xslt (identity?) transformationTo: NULL Date: 2/27/2008 1:51:00 AM Never mind guys - I found a way to do it :-) Thanks again to both of you for invaluable help! :-) Best regards, Roger On 26 Feb, 21:55, roger <ro...@langedal.com> wrote: > Thank you Martin! > > Putting it all together: > > ------ snippet --------- > <xsl:template match="@* | node()"> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="author"/> > > <xsl:template match="author[@name = 'whatever_name_of_author]"> > <xsl:copy> > <xsl:apply-templates select="@*"/> <-- I want the attributes > <xsl:apply-templates > select="book[NOT(contains(@title,'do_not_include_this_title))]"/> > </xsl:copy> > </xsl:template> > ----- snippet ------ > > As I wanted to exclude the title I was searching for I've added the > not clause. > > But one last thing - forgive me the stupid example with the books xml, > but my real world example is a bit more complex. > But for the sake of simplifying and sticking to the example: > What if I the books where nested and I wanted the "<xsl:apply- > templates > select="book[NOT(contains(@title,'do_not_include_this_title))]"/>" > to apply to all nested elements - no matter how deep they were > appearing under an author i still want to check the "title" attribute, > and if I find a book I do not like, discard it? > > So - how do I shred away the <book title="title_212"/> from the XML > below when I do not know where in the structure it is , only that it > is below an author by a given name? > > <author lastname="lastname_2" givenname="given_2"> > <book title="title_21"/> > <book title="title_22"/> > <book title="title_211"/> > <book title="title_212"/> > <book title="title_23"/> > </author> > > And again - thank you for taking the time to show me how this is done > - I've already learned a lot, and will keep digging :-) > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:template match="@* | node()"> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="author[@lastname != 'lastname_2']"/> > > </xsl:stylesheet> > > On 26 Feb, 14:24, Martin Honnen <mahotr...@yahoo.de> wrote: > > > > > roger wrote: > > > if it possible to select all childelements of an "author" element - > > > EXCLUDING a few - based on the "title" attribute of the "book" element > > > in this example? > > > Well you could write a template for author elements that processes only > > some book child elements e.g. > > <xsl:template match="author"> > > <xsl:copy> > > <xsl:apply-templates select="@*"/> > > <xsl:apply-templates select="book[contains(@title,'foo')]"/> > > </xsl:copy> > > </xsl:template> > > > -- > > > Martin Honnen --- MVP XML > > http://JavaScript.FAQTs.com/- Skjul sitert tekst - > > - Vis sitert tekst - | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
