xsl-list
[Top] [All Lists]

RE: [xsl] Removing elements based on contents

2006-06-24 07:41:10
In XSLT you don't remove the elements you want to lose, you copy the
elements you want to keep. So:

<xsl:template match="Root">
  <xsl:copy>
    <xsl:copy-of select="Story[.='End Here']/following-sibling::*"/>
  </xsl:copy>
</xsl:template>

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Chad Chelius [mailto:cchelius(_at_)agitraining(_dot_)com] 
Sent: 24 June 2006 13:04
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Removing elements based on contents

I have an XML file that looks something like this:

<Root>
      <Story>Content</Story>
      <Story>More Content</Story>
      <Story>End Here</Story>
      <Story>Good stuff that I want</Story>
</Root>

My question is: Is there a way using XSLT to remove all 
elements up to and including the one who's content contains 
<Story>End Here</ 
Story> and leave the rest intact? Basically everything from the top
of the XML file down to and including that tag is junk that I 
don't want to include in the file but the rest of it I want 
to keep. I don't think XSLT traverses I file in that way 
though. Does anyone have 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>