This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Best Practices for inline elements
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Brad Miller" <Brad dot Miller at tririga dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 5 Jul 2002 19:23:03 +0100
- Subject: Re: [xsl] Best Practices for inline elements
- Organization: Jeni Tennison Consulting Ltd
- References: <C0813D854A46F249A72DC407680227A9A2DEDC@mail1.tririga.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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