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

Re: Transforming XHTML to XHTML using XSLT

Subject: Re: Transforming XHTML to XHTML using XSLT
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Sun, 31 Mar 2002 12:16:57 +0200
transforming xhtml with xslt
Hello Anand,

I wouldn't make a difference between normal XML and XHTML. XHTML is XML too,
only with a special DTD. So you can easily use all documentations for XSLT.

Now your example: The important is always the XML (or the XHTML) which is
transformed. In the stylesheet there is only written should be done with the
nodes found in the XML. Normal processing is "in document order", with XSLT
you can change the general processing.

The only problem a beginner can have with your file is the namespace, you
set your XHTML-elements in: <html xmlns="http://www.w3.org/1999/xhtml">.
This means, every element which is a descendant of html (without a
namespace-prefix and setting a new namespace) and html itself are in this
XHTML namespace. This must be known in the XSLT too and you have to set the
same namespace.

The simplest stylesheet for extracting title and paragraphs:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">

    <xsl:output method="text"/>

    <xsl:template match="title">
        <xsl:text>title: </xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

    <xsl:template match="p">
        <xsl:text>paragraph "</xsl:text>
        <xsl:value-of select="@name"/>
        <xsl:text>": </xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template
</xsl:stylesheet>

Hope this helps,

Joerg

> I would like to use XSLT to transform one XHTML document to another XHTML
> document.  I have come across numerous articles that state that this is
> possible, but I have yet to see any working examples.
>
> Here is a simple XHTML document:
>
> --------------- begin XHTML document -----------------------------
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title> XHTML sample </title>
> </head>
>
> <body>
>
> <p name="who">Anand</p>
> <p name="job">Web Developer</p>
> <p name="area">California</p>
>
> </body>
> </html>
>
> --------------- end XHTML document -----------------------------
>
> My question is two fold: 1) What would a simple XSL style sheet to extract
> the title and various <p> tags look like? 2) Any body know of any good
books
> or website that have specific examples of XHTML being transformed with
XSLT?
>
> Thanks,
>
> Anand


 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.