By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,366 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,366 IT Pros & Developers. It's quick & easy.

Undesired (maybe) attributes in root element of XSLT output

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <79**************************@posting.google.com >,
Wolfgang <mo******@alexandria.ucsb.edu> 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:output element, but it shouldn't
matter if you use standard tools for processing the data.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.