[Home] [By Thread] [By Date] [Recent Entries]

Subject: RE: Maintainability Problem
From: Jarno.Elovirta@xxxxxxxxx
Date: Mon, 3 Mar 2003 17:02:00 +0200
Hi,

> I have created two XSLs, one which is with a DOCTYPE for HTML 
> 4.01, the
> other for XHTML Basic. These XSLs are exactly the same, 
> except for these
> parts of my XSL:
> 
> HTML 4.01
> ---------
> 
> <xsl:stylesheet version="1.0" 
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>     
> <xsl:output method="html"
>     doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" 
>     doctype-system="http://www.w3.org/TR/html4/loose.dtd"
>     encoding="iso-8859-1" 
>     indent="yes"/>
> 
> ...and 
> 
> XHTML 1.0
> ---------
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" 
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:html="http://www.w3.org/1999/xhtml">
>     
> <xsl:output method="xml"
>     doctype-public="-//W3C//DTD XHTML Basic 1.0//EN" 
>     
> doctype-system="http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"
>     encoding="iso-8859-1" 
>     indent="yes"
>     omit-xml-declaration="yes"/>
> 
> Does someone know an easy way in which I could have two 
> files, one with
> the HTML 4.01 header and one with the XHTML 1.0 header, and I could
> reuse them whenever I wanted by calling them in XSLs when needed. For
> example, could I just do an include of these headers rather 
> than having
> to copy them in each file? 

Well, 1) you could have a third stylesheet that does that actual work, generates a document in XHTML namespace. Then you reprocess the results with a stylesheet for XHTML that's just an identity transformation that adds a doctype, or with a stylesheet for HTML that's an identity transformation that copies all elements into null-namespace and adds a doctype. Or 2) your stylesheet that does all the work generates all elements using <xsl:element name="whatever" namespace="{$target-NS}"> and in the stylesheet for HTML or XHTML where you import the workhorse stylesheet you define $target-NS as either "" or "http://www.w3.org/1999/xhtml", respectively.

There are probably other and better strategies you could use described in XSLT books; don't remember if Jeni wrote about a situation like this.

Cheers,

Jarno - In Strict Confidence: Zauberschloss

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Maintainability Problem
    • Tim Kyle - Mon, 3 Mar 2003 08:58:55 -0500 (EST)
      • Michael Kay - Mon, 3 Mar 2003 18:55:10 -0500 (EST)
        • Tim Kyle - Wed, 5 Mar 2003 07:07:41 -0500 (EST)
      • <Possible follow-ups>
      • Jarno . Elovirta - Mon, 3 Mar 2003 09:59:08 -0500 (EST) <=
        • Paul - Tue, 18 Mar 2003 15:37:29 -0500 (EST)
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member