[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: RE: DOCBOOK-APPS: designing an XSL stylesheet for "pidgin" docboo k
I would include the <xsl:apply-templates select="@*|node()"/> in all of your templates. If you just use <xsl:apply-templates/>, you will discard all text, comments, processing-instructions, and attributes in that element. Jeff Beal -----Original Message----- From: Robert P. J. Day [mailto:rpjday@mindspring.com] Sent: Tuesday, February 18, 2003 1:07 PM To: Bob Stayton Cc: docbook apps list Subject: Re: DOCBOOK-APPS: designing an XSL stylesheet for "pidgin" docbook On Tue, 18 Feb 2003, Bob Stayton wrote: > On Tue, Feb 18, 2003 at 11:41:32AM -0500, Robert P. J. Day wrote: > > > > i'm following the advice of one of the posters here and designing > > an XSL stylesheet that will allow me to write in what i'm calling > > "pidgin" docbook, with shortcuts for all of the elements i use, > > like <p> for <para>, <em> for <emphasis>, and so on. > > > > what i'm not clear on is how to write a template for an > > element that contains mixed content. this is what markus > > spath posted to help me out: > > > > > <xsl:template match="@* | node()"> > > > <xsl:copy><xsl:apply-templates select="@* | node()" /></xsl:copy> > > > </xsl:template> > > > > > > <xsl:template match="li"> > > > <listitem><para><xsl:apply-templates /></para></listitem> > > > </xsl:template> > > > > obviously, in the case of the "li" element, i want to apply templates > > to all of the content, including just copying the text over untouched. > > is that what that first template definition is specifying? that > > any non-element content is just copied? > > Yes, node() matches element, text, pi, and comments nodes. > All but attribute nodes, which is why you also need @*. actually, markus spath (who was the original respondent and showed me how to do this), suggested that my template for "li" should look like: <xsl:template match="li"> <listitem><para> <xsl:apply-templates select="@* | node()" /> </para></listitem> </xsl:template> so let me make sure i grok all this. the first template above (way above up there) is just for elements i don't redefine, and i'll toss that at the top of the templates in the .xsl file. for each pidgin docbook template, there are two possible templates: the simpler if that element has *only* nested elements, and the more complicated if it contains mixed content, the difference being only the inclusion of the 'select="@* | node()"' directive. is that about right? and if it is, is there any harm in making all templates capable of dealing with mixed content, even if they contain only elements? (just makes it easier to copy and paste with an editor.) i'll let the second stage of processing catch any errors, so i don't need to worry about them here. rday
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC