Subject: [xsl] applying templates to ancestor nodes without reprocessing context node From: Jarom McDonald <jmcdon@xxxxxxxxxxxx> Date: Wed, 10 Apr 2002 13:13:48 -0400 |
I've been searching for a week or so and haven't found an answer to this question, so I thought I'd try posting it. If it's already been discussed in the past, please direct me to the proper archive. I'm trying to write a stylesheet for some documents encoded with the TEI dtd, and am running into a problem. Here is the xml: <l n="1">There are two Ripenings <app> <rdg wit="A456 H47"> -</rdg> <rdg wit="ATr60a"></rdg> </app></l> <l n="2"> <app> <rdg wit="A456">one -</rdg> <rdg wit="H47">One -</rdg> <rdg wit="ATr60a">one</rdg> </app> of <app> <rdg wit="A456">sight -</rdg> <rdg wit="H47">Sight - whose Forces</rdg> <rdg wit="ATr60a">sight</rdg> </app></l> I want the stylesheet to process each <rdg> element and produce HTML <div> elements that have corresponding "wit" attributes, but whose content contains first the content of the xml <l> element (which should appear in all the HTML <div>s), followed by the specific content of the current <rdg> element. Here's where I've begun: <xsl:template match="app" mode="parallel-segmentation"> <xsl:for-each select="rdg"> <div id="line"> <xsl:attribute name="wit"><xsl:value-of select="@wit"/></xsl:attribute> <xsl:apply-templates/> </div> </xsl:for-each> </xsl:template> This obviously works for getting just the content of the <rdg> elements. So here's my question. Before applying the templates to the children of the <rdg> element (many will have children, though my example doesn't), I want to process the ancestor <l> element and all of its children (again, many will have them, though my example doesn't) EXCEPT <app> (and hence decendant <rdg>) elements. Basically, I want the resultant HTML to look like this: <div id="line" wit="A456 H47">There are two Ripenings -</div> <div id="line" wit="ATr60a">There are two Ripenings</div> <div id="line" wit="A456">one -</div> <div id="line" wit="H47">One -</div> <div id="line" wit="ATr60a">one</div> <div id="line" wit="A456">of sight -</div> <div id="line" wit="H47">of Sight - whose Forces</div <div id="line" wit="ATr60a">of sight</div> I've tried putting this line into my <app> template: <xsl:apply-templates select="node()[ancestor::l]" mode="noApps"/> and then having a new template that looks like this: <xsl:template name="l" mode="noApps"> <xsl:apply-templates select="node()[not(self::app)]"/> </xsl:template> But that, in actuality, re-processes the child <app> elements without processing any of the other children. Hope my question makes sense. Sorry the post is so long. -- Jarom McDonald Project Manager Dickinson Electronic Archives http://jefferson.village.virginia.edu/dickinson jmcdon@xxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] date, Michael Kay | Thread | Re: [xsl] applying templates to anc, Wendell Piez |
Re: [xsl] xsl:variable ?, Greg Faron | Date | RE: [xsl] date, Michael Kay |
Month |