Subject: Re: [xsl] Best Practices for inline elements From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 5 Jul 2002 19:23:03 +0100 |
Hello Brad, > Can any one give me some advice on how to handle inline elements. [snip] > So far everything I have tried has either given me the inline > elements formatted after the paragraph but never formatted "inline", > or just nothing at all. You don't say what you're trying to transform to, but the best way to handle mixed content is to use a data-driven or "push" method: apply templates to the content of the paragraph and have separate templates for each of the inline elements: <xsl:template match="para"> <p><xsl:apply-templates /></p> </xsl:template> <xsl:template match="bold"> <b><xsl:apply-templates /></b> </xsl:template> <xsl:template match="italics"> <i><xsl:apply-templates /></i> </xsl:template> <xsl:template match="image"> <img src="{@src}" /> </xsl:template> Doing it this way relies on the built-in template for text nodes: <xsl:template match="text()"> <xsl:value-of select="." /> </xsl:template> This guarantees that the text nodes between the various elements get output in place. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Best Practices for inline ele, Brad Miller | Thread | Re: [xsl] Best Practices for inline, David Carlisle |
[xsl] Best Practices for inline ele, Brad Miller | Date | Re: [xsl] fo:inline vs. fo:wrapper, Wendell Piez |
Month |