This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Best Practices for inline elements


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]