This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: A simple basic question
- From: Oleg Tkachenko <olegt at multiconn dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 06 May 2002 15:15:20 +0200
- Subject: Re: [xsl] A simple basic question
- Organization: Multiconn International
- References: <20020506113852.GY30280@lina.aaanime.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Philip Mak wrote:
> I looked at various XSL guides, but I still can't figure out how to
> transform this:
>
> <document>
> <paragraph>Here is a <bold>bold</bold> word.</paragraph>
> <paragraph>Here is an <italic>italic</italic> word.</paragraph>
> </document>
>
> into this:
>
> <body>
> <p>Here is a <b>bold</b> word.</p>
> <p>Here is an <i>italic</i> word.</p>
> </document>
>
> The part I have trouble with is the <bold> and <italic>. The thing is
> that they could appear anywhere in the document; they're not part of a
> rigid structure. It seems that when I use <xsl:value-of
> select="paragraph">, the <bold> and <italic> tags inside just get
> stripped out.
>
> Any suggestions?
Don't use value-of if you want a value to be transformed also, use
<xsl:apply-templates/> instead.
That's a very simple transformation, you probably need to read some good
book about xslt.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="document">
<body><xsl:apply-templates/></body>
</xsl:template>
<xsl:template match="paragraph">
<p><xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="bold">
<b><xsl:apply-templates/></b>
</xsl:template>
<xsl:template match="italic">
<i><xsl:apply-templates/></i>
</xsl:template>
</xsl:stylesheet>
--
Oleg Tkachenko
Multiconn International, Israel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list