Generating HTML from XSLT using <xsl:copy>

Discussion in 'XML' started by Andy Dingley, Mar 27, 2007.

  1. Andy Dingley

    Andy Dingley Guest

    >From a thread over in c.i.w.a.h
    "RFC: From XHTML to HTML via XSLT"
    http://groups.google.co.uk/group/comp.infosystems.www.authoring.html/msg/f112c230061ffe86


    As is well-known, the XSLT HTML output method should generate <br>
    rather than <br /> or <br></br>
    From: <http://www.w3.org/TR/xslt#section-HTML-Output-Method>

    :> The html output method should not output an end-tag for empty
    elements. For HTML 4.0, the empty elements
    :> are area, base, basefont, br, col, frame, hr, img, input,
    isindex, link, meta and param. For example, an element
    :> written as <br/> or <br></br> in the stylesheet should be output
    as <br>.

    So what happens if this "br" element is generated by an <xsl:copy>
    from an XHTML input document, bound to the XHTML namespace URI ?
    Should the XSLT transfrom treat it "as HTML" (<br>) or "as XML" (<br /
    >) ?


    What do practical transform engines do here? Are they consistent?
    Andy Dingley, Mar 27, 2007
    #1
    1. Advertising

  2. * Andy Dingley wrote in comp.text.xml:
    >So what happens if this "br" element is generated by an <xsl:copy>
    >from an XHTML input document, bound to the XHTML namespace URI ?
    >Should the XSLT transfrom treat it "as HTML" (<br>) or "as XML" (<br /
    >>) ?


    Well, read the text right before what you quoted?

    The html output method should not output an element differently from
    the xml output method unless the expanded-name of the element has a
    null namespace URI; an element whose expanded-name has a non-null
    namespace URI should be output as XML.

    Some time ago I wrote a quick and dirty XHTML-to-HTML XSLT document,
    see <http://www.bjoernsworld.de/temp/xhtml-to-html4.xslt>.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Mar 27, 2007
    #2
    1. Advertising

  3. Andy Dingley

    Andy Dingley Guest

    On 27 Mar, 11:51, Bjoern Hoehrmann <> wrote:

    > Well, read the text right before what you quoted?


    RTFM you mean? :cool:


    > The html output method should not output an element differently from
    > the xml output method unless the expanded-name of the element has a
    > null namespace URI;


    Thanks! I'd never noticed that. I'd always assumed that XHTML and the
    standard XHTML namespace URI was treated as HTML.
    Andy Dingley, Mar 27, 2007
    #3
  4. Andy Dingley wrote:

    > I'd always assumed that XHTML and the
    > standard XHTML namespace URI was treated as HTML.


    With XSLT 2.0 there is an output method 'xhtml' which is supposed to
    serialize XHTML so that it can be served as text/html, see
    <http://www.w3.org/TR/xslt-xquery-serialization/#xhtml-output>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 27, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vijay singh
    Replies:
    1
    Views:
    433
    Martin Honnen
    Nov 4, 2004
  2. Brent
    Replies:
    3
    Views:
    765
    Peter Flynn
    Mar 22, 2005
  3. Replies:
    1
    Views:
    3,595
    A. Bolmarcich
    May 27, 2005
  4. Replies:
    6
    Views:
    3,403
    jon001
    Nov 7, 2011
  5. Alex
    Replies:
    2
    Views:
    1,217
Loading...

Share This Page