Project

Profile

Help

Support #5870

closed

If the root element is html, indent=yes by default

Added by David Cramer about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2023-02-03
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

In Saxon 10.6 (e.g. using the debugger in XML Editor 24.1), if you do an identity transform of a document with a root element <html> (either in no namespace or in the xhtml namespace), the result document is treated as if you'd added <xsl:output indent="yes"/> unless you explicitly add <xsl:output indent="no"/> . In all other contexts that I'm aware of, <xsl:output indent="no"/> is the default. I believe this was the behavior in older versions of Saxon since a user found a regression where whitespace was being added from an XSLT that we've been using for some time.

Actions #1

Updated by Michael Kay about 1 year ago

This is entirely in accordance with the specification. Two quotes from the (very long!) section 26 of the XSLT 3.0 spec:

If the expanded QName of this first element child has local part html (in any combination of upper and lower case) and a null namespace URI, then the default output method is html.

The value of the indent attribute provides the value of the indent parameter to the serialization method. The default value is yes in the case of the html and xhtml output methods, no in the case of the xml output method.

(It fails to state a default for the JSON method, I notice.)

If you have specific evidence that the product got it wrong in the past, I'll take a look at it, though I can't see it changing anything.

Actions #2

Updated by David Cramer about 1 year ago

One other detail: the above is true if the XSLT version is 2.0 or 3.0. If it's set to 1.0, then indent="no" is again the default.

Actions #3

Updated by Michael Kay about 1 year ago

You're probably encountering the rule:

If the expanded QName of this first element child has local part html (in lower case), and namespace URI http://www.w3.org/1999/xhtml, then the default output method is normally xhtml. However, if the effective version of the outermost element of the principal stylesheet module in the top-level package has the value 1.0, and if the result tree is generated implicitly (rather than by an explicit xsl:result-document instruction), then the default output method in this situation is xml.

The XHTML output method didn't exist in 1.0, and the default for HTML in the XHTML namespace was the XML output method, and the default for the XML output method was indent="no".

Actions #4

Updated by David Cramer about 1 year ago

Ok, interesting and thanks. I just checked with 9.9 and the behavior is the same.

Actions #5

Updated by Michael Kay about 1 year ago

If there's a regression in a user stylesheet, it's probably because we made a minor tweak to the indentation behaviour; for example some while ago I think we improved the handling of comments.

Actions #6

Updated by Michael Kay about 1 year ago

  • Tracker changed from Bug to Support
  • Status changed from New to Closed

Closing as resolved without product change. Working as intended.

Please register to edit this issue

Also available in: Atom PDF