[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] XSL-loop
Subject: Re: [xsl] XSL-loop From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 23 Mar 2001 11:44:56 +0000 |
Hi Mark, > In my DTD i've created a P-tag. It can contain many different > elements - also other P's. A P-element has an attribute called > Title. It contains the title of a block of text (p for paragraph!). > I would like to display the titles of the different P-elements with > a different headersize for each title depending on its position in > the XML-tree (how many P-ancestors does it have). You can find out how many P ancestor elements you have with the XPath: count(ancestor::P) This gets all the P elements that are ancestors of this one and counts them. You can create an element name dynamically using an attribute-value-template as the value of the name attribute on xsl:element. For example if $level holds the number that you want, you can create HTML headings of different levels with: <xsl:element name="h{$level}"> ... </xsl:element> Putting this together, you can use: <xsl:template match="P"> <xsl:element name="h{count(ancestor::P) + 1}"> <xsl:value-of select="@Title" /> </xsl:element> ... </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL-loop, Larry Garfield | Thread | [xsl] internal DTD-subset and CDATA, Tobias Reif |
Re: [xsl] Is there a direct phrase , Jeni Tennison | Date | Re: [xsl] How to display XML data p, Jeni Tennison |
Month |