Undesired (maybe) attributes in root element of XSLT output

W

Wolfgang

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
 
P

Patrick TJ McPhee

% 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top