Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xslt (identity?) transformation

From: roger <roger@--------.--->
To: 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 -



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent