[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Best Practices for inline elements

Subject: Re: Best Practices for inline elements
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 5 Jul 2002 19:23:03 +0100
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.