Subject: Re: [xsl] inline troubles From: Luke Jones <ljones@xxxxxxxxxxxxxxxxxx> Date: Tue, 05 Sep 2006 16:42:26 -0500 |
Templates it is! :) I spent some a brief amount of time looking for a decent tutorial on using templates, and found nothing that seemed to break it down enough. Perhaps you know of a good source. I get confused as to what I do with the template I've created. I know I can call the templates, but how exactly I need them called in up in the air. If I take my xsl for example, I start off with //My current way of doing the xsl <xsl:template match="/"> ...layout master stuff ...page sequence stuff ...flow <fo:block> <xsl:apply-templates select = "flrdcs"/> </fo:block> .../flow .../page sequence .../root </xsl:template> <xsl:template match="flrdocs"/> ...no no for-each statements. </xsl:template> Your saying break down the underline, line through, and regular text in other templates. How is that going to work though? I'll keep looking for a good tutorial, or if you know of one please send me a link. I'd hate to bother you with things I can look up on my own..besides, I'll learn more that way :) Thanks, L On Tue, 2006-09-05 at 17:18 -0400, Wendell Piez wrote: > Dear Luke, > > Use templates. > > This is XSLT 101: > > <xsl:template match="line"> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="a"> > <fo:inline text-decoration="underline"> > <xsl:apply-templates/> > </fo:inline> > </xsl:template> > > <xsl:template match="d"> > <fo:inline text-decoration="line-through"> > <xsl:apply-templates/> > </fo:inline> > </xsl:template> > > I like to teach beginners never to use xsl:for-each at all unless > they have a good reason. Good reasons do not include "I didn't know > how to use a template", since to learn XSLT is to learn how to use them. :-) > > Cheers, > Wendell > > At 05:12 PM 9/5/2006, you wrote: > >I'm having some trouble trying to underline and line-through specific > >text from my xml. My xml is formatted like so: > > > >///XML/// > > > ><line number=3> > > This is some regular old text, <a> and now I want this > > underlined </a> and then maybe some more regular old text, > > <d>and this to be line-through</d> and finish up with some > > regular text. > ></line> > > > >Here is what I currently have in my xsl: > > > >///XSL/// > ><xsl: for-each select = "line"> > > <xsl:value-of select="./@number> > > <xsl:for-each select = "a"> > > <fo:inline text-decoration="underline"> > > <xsl:value-of select="."/> > > </fo:inline> > > </xsl:for-each> > > <xsl:for-each select = "d"> > > <fo:inline text-decoration="line-through"> > > <xsl:value-of select="."/> > > </fo:inline> > > </xsl:for-each> > ></xsl:for-each> > > > >The above xsl however prints the line with both the underline/strike > >through section and the non formatted version, giving me repeated lines. > >Any ideas on how to properly handle this? > > > >Thanks, > >L
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] inline troubles, Wendell Piez | Thread | RE: [xsl] inline troubles, Michael Kay |
Re: [xsl] inline troubles, Wendell Piez | Date | RE: [xsl] inline troubles, Michael Kay |
Month |