Undesired (maybe) attributes in root element of XSLT output

Discussion in 'XML' started by Wolfgang, Apr 9, 2004.

  1. Wolfgang

    Wolfgang Guest

    XSLT transformations by default seem to pass name space attributes
    into the root element of their output (example below).

    QUESTION: Is it possible to control this, i.e. not genrating a name
    space attribute in the root of the output, or generating other
    attributes in the root?

    The following illustrates the case. The XSLT script specifies an
    output root element

    <ROOT-OF-REPORT-DOCUMENT>

    which in the output appears as

    <ROOT-OF-REPORT-DOCUMENT xmlns:adn="http://adn.dlese.org">

    like this:

    The XSLT script
    ===============
    <?xml version="1.0"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:adn="http://adn.dlese.org">

    <xsl:template match="/">

    <ROOT-OF-REPORT-DOCUMENT>

    <!-- DO ALL THE WORK HERE -- GENERATE RESULT OUTPUT -->

    </ROOT-OF-REPORT-DOCUMENT>

    </xsl:template>
    </xsl:stylesheet>

    OUTPUT - RESULT OF THE ABOVE XSLT
    =================================
    <?xml version="1.0" encoding="UTF-8"?>

    <ROOT-OF-REPORT-DOCUMENT xmlns:adn="http://adn.dlese.org">

    <!-- MAIN CONTENT GETS PUT HERE -->

    </ROOT-OF-REPORT-DOCUMENT>


    Similarly, the output has an UTF encoding, like

    <?xml version="1.0" encoding="UTF-8"?>

    which wasn't given in the XSLT script.


    Thanks for any help and advice.

    Wolfgang,
    Santa Barbara, CA
    Wolfgang, Apr 9, 2004
    #1
    1. Advertising

  2. In article <>,
    Wolfgang <> wrote:

    % XSLT transformations by default seem to pass name space attributes
    % into the root element of their output (example below).

    [...]

    % which in the output appears as
    %
    % <ROOT-OF-REPORT-DOCUMENT xmlns:adn="http://adn.dlese.org">

    Try starting your script like this:

    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:adn="http://adn.dlese.org"
    exclude-result-prefixes='adn'>

    ...
    </xsl:stylesheet>

    % Similarly, the output has an UTF encoding, like
    %
    % <?xml version="1.0" encoding="UTF-8"?>
    %
    % which wasn't given in the XSLT script.

    You can specify the encoding in the xsl:eek:utput element, but it shouldn't
    matter if you use standard tools for processing the data.
    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, Apr 9, 2004
    #2
    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. Wolfgang
    Replies:
    2
    Views:
    817
    Wolfgang
    Apr 9, 2004
  2. Wolfgang
    Replies:
    0
    Views:
    407
    Wolfgang
    Apr 6, 2004
  3. hilz
    Replies:
    1
    Views:
    501
    Richard Tobin
    Jan 18, 2006
  4. Guest
    Replies:
    5
    Views:
    598
  5. Ville Vainio
    Replies:
    11
    Views:
    582
    Hamish Lawson
    Aug 10, 2004
Loading...

Share This Page