Re: exclude-result-prefixes

Discussion in 'XML' started by Alain Ketterlin, Mar 14, 2007.

  1. Simon Brooke <> writes:

    > I'm struggling to understand what 'exclude-result-prefixes' does and is
    > for; the language of the standard
    >
    > http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#literal-result-element


    (BTW, the rec. is also available via www.w3c.org)

    The purpose of exclude-result-prefixes is to avoid the output of
    namespace declarations (xmlns:blah pseudo-attributes) that appear in
    the source document but _never_ appear in the result document. It
    means that if a namespace (like the XHTML namespace in your example)
    is used in the result document, it will be declared in the output
    (because it has to), whatever the value of exclude-result-prefixes is.
    This is what you observe, since you use the XHTML ns in the output.

    (The reason for this is that, if you declare a namespace in your
    xsl:stylesheet element, all literal result elements are in the scope
    of the namespace declaration, so a corresponding namespace
    declaration is (may be) output, even if you do not use that namespace.)

    > <xsl:eek:utput indent="yes" method="html"
    > doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    > doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
    >
    > <xsl:template match="xhtml:html">
    > <xhtml:html><xhtml:body>Hello world!</xhtml:body></xhtml:html>
    > </xsl:template>


    This doesn't make much sense. You ask for HTML output, but provide
    only namespace-qualified XML literal output. The XSLT rec. specifies
    that 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" (sec 16.2). That means your
    HTML-output request is ignored, because your result elements are
    namespace-qualified (I'm talking about the <xhtml:html> element, _not_
    the "xhtml:html" match pattern.)

    If you need HTML output, to comply with browser requirements, use the
    HTML output method and literal result elements that are in the null
    namespace (i.e., have no namespace prefix, and such that
    <xsl:stylesheet> doesn't declare a default namespace). If your
    stylesheet outputs superfluous namespace declarations, add that
    namespaces' prefixes to exclude-result-prefixes. Also, change the
    public and system ids to point to HTML (no X).

    -- Alain.
    Alain Ketterlin, Mar 14, 2007
    #1
    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. mayur
    Replies:
    2
    Views:
    1,012
    Natty Gur
    Jul 2, 2004
  2. Martin Honnen

    Re: exclude-result-prefixes

    Martin Honnen, Mar 14, 2007, in forum: XML
    Replies:
    1
    Views:
    680
    Simon Brooke
    Mar 14, 2007
  3. Richard Tobin

    Re: exclude-result-prefixes

    Richard Tobin, Mar 14, 2007, in forum: XML
    Replies:
    6
    Views:
    697
    Simon Brooke
    Mar 19, 2007
  4. Cameron McCormack
    Replies:
    3
    Views:
    14,932
    Cameron McCormack
    Jul 3, 2007
  5. Michael Tan
    Replies:
    32
    Views:
    956
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page