[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Auto numbering Tips
Hi, Generally it is a good idea when customizing to see how an element is already handled by the stylesheet, and then modify that behavior. Simply adding a template that matches on an element may not integrate it into the other templates in the stylesheet. In this case, a tip/title is not handled in normal mode (that is, a template with no mode attribute), but in mode="object.title.markup". That's because title is optional, and so a template with that match will not be triggered for tip without title, and there will be no generated "Tip" label. Instead, the template processing tip does: <xsl:apply-templates select="." mode="object.title.markup"/> This is applied to the current tip element, and that mode handles either the title child element or generates the "Tip:" text in the appropriate language. So your template could be instead: <xsl:template match="tip" mode="object.title.markup"> <xsl:text>Tip-</xsl:text> <xsl:variable name="tipnr"> <xsl:number count="tip" level="any"/> </xsl:variable> <xsl:number value="$tipnr+-1" format="01"/> </xsl:template> Not sure why you want to start counting from "00", though. Bob Stayton Sagehill Enterprises bobs@sagehill.net ----- Original Message ----- From: "Halm Reusser" <halm.reusser@switch.ch> To: <docbook-apps@lists.oasis-open.org> Sent: Thursday, July 23, 2009 1:56 AM Subject: [docbook-apps] Auto numbering Tips > Hello, > > in my document I use some tips and warnings, like > > <tip> <title> Tip- </title> > <para> > This the first example Tip. > </para> > </tip> > > > <tip> <title> Tip- </title> > <para> > This the second example Tip. > </para> > </tip> > > same for warnings... > > > My aim is to get the Tips and Warnings auto numbered. What means after > compilation, the title should be set like Tip-01, Tip-02 etc. > > For that, I wrote a small template: > > <xsl:template match="tip/title"> > <xsl:text>Tip-</xsl:text> > <xsl:variable name="tipnr"> > <xsl:number count="tip" level="any"/> > </xsl:variable> > <xsl:number value="$tipnr+-1" format="01"/> > </xsl:template> > > It counts up, but it do not sets the title, it sets the firstline of the > paragraph text. What am I doing wrong? > > Thanks in advance! > > The second step, that would be perfekt, if <tip> would be rewritten to > <tip xml:id="tip-01">. Do you know how to do it? > > -Halm > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]