[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Finding all occurences of a node

Subject: Re: Finding all occurences of a node
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 31 Jan 2001 13:21:52 GMT
Re:  Finding all occurences of a node

  To get everything below <sub1> I am using:

  <xsl:template match="child::sub1/child::*">
     <xsl:copy-of select="."/>
  </xsl:template>


that match is the same as sub1/* ie it matches any child of sub1.
It might be clearer (or might not) to just use match="sub2" in any
event, that would have the same effect on your input.



  But how can I replace all occurences of <myowntag>? Something like
  <xsl:template match="myowntag">
      ....
  </xsl:template match>
  doesn't work.

Yes it does (if you delete the spurious match in the close tag).
 At least that template would work if you ever applied any
templates to the myowntag element. But you don't. Your first template
doesn't use applu-templates it uses copy-of so no templates are applied
after that, the whole subtree below sub2 is copied.

What you want to do is
a) copy the identity transform stylesheet from the XSLT spec.
b) add a template for the root node, that makes it jump to sub2
  <xsl:template match="/">
   <xsl:apply-templates select="sub1/sub2"/>
  </xsl:template
c) add a template for myowntag
  <xsl:template match="myowntag">
      ....
  </xsl:template>

David

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.