|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








