[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XHTML to XHTML transform


Subject: RE: [xsl] XHTML to XHTML transform
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Fri, 2 Apr 2004 20:48:47 +0200

> -----Original Message-----
> From: Jeffrey Moss [mailto:jeff@xxxxxxxxxxxx]
>
<snip />
> I have tried a number of different approaches already. I played
> around with the xmlns:xhtml namespace in my XSL file (not sure if I ever
did this
> correctly, I don't think I fully understand what namespaces do).
>

Hi,

What exactly is it that is not working?

If your supplied source and desired target format were plain XML the
solution would look like:

<xsl:template match="BODY">
  <xsl:copy>
    <xsl:apply-templates />
  </xsl:copy>
</xsl:template>

<xsl:template match="BOX">
  <DIV ID="box">
    <xsl:apply-templates />
  </DIV>
</xsl:template>

<xsl:template match="TITLE">
  <DIV ID="top">
    <DIV ID="topleft" />
    <DIV ID="topright" />
    <SPAN ID="title">
      <xsl:apply-templates />
    </SPAN>
  </DIV>
</xsl:template>

<xsl:template match="FOOTER">
  <DIV ID="bottom">
    <DIV ID="bottomleft" />
    <DIV ID="bottomright" />
    <SPAN ID="footer">
      <xsl:apply-templates />
    </SPAN>
  </DIV>
</xsl:template>

If you really want to you could combine the latter two templates, since they
output something very similar. The 'Hello World' text will be copied because
of the default template rule for text-nodes (same as the content of the
TITLE / FOOTER nodes)

Now, depending upon your source files (prefixed elements / namespaces), you
may need to make it something like:

<xsl:template match="html:BODY">
or
<xsl:template match="*[local-name()='BODY']">

> I also played with the xsl:output tag to see if I could get that to do
> something cool, but no.
>

In XSLT 1.0 the options are: xml / text / html

As you want to ouput XHTML, if you use xsl:output, you need to specify XML
as your output target.

Hope this helps!

Cheers,

Andreas


Current Thread
Keywords