This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]