[xsl] How can the mere switch from DTD to XSD in the source document affect how a stylesheet handles white space?

Subject: [xsl] How can the mere switch from DTD to XSD in the source document affect how a stylesheet handles white space?
From: "Wolfhart Totschnig wolfhart.totschnig@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Feb 2021 19:23:46 -0000
Dear list,

After switching from DTD to XSD in my project, I encountered -- apart from the odd behavior of Chrome described in my post from two days ago -- another puzzling problem, namely that, after this switch, one of the stylesheets of my project produced unexpected output, specifically in the handling of white space. I was able to find a solution to the problem. Still, I do not understand how the problem could arise. That is, I do not understand how the mere switch from DTD to XSD in the source file can affect how a stylesheet handles white space. I would like to ask whether one of you can explain it to me.

In order to show the phenomenon, I have produced the following minimal example.

Before the switch from DTD to XSD, I had the following XML document:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../zettel.xsl"?>
<!DOCTYPE zettel SYSTEM "../zettel.dtd">
<zettel>
B B  <head>
B B B B B  <keywords>
B B B B B B B B  <author>
B B B B B B B B B B B  <first>Sally</first>
B B B B B B B B B B B  <last>Adee</last>
B B B B B B B B  </author>
B B B B B  </keywords>
B B  </head>
</zettel>

I transformed this document with the following stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
B B B <xsl:output method="text" omit-xml-declaration="yes"/>
B B B <xsl:template match="author">
B B B B B B B <xsl:text>Some text: </xsl:text>
B B B B B B B <xsl:value-of select="."/>
B B B B B B B <xsl:text>&#10;</xsl:text>
B B B </xsl:template>
</xsl:stylesheet>


This produced the following output (with Saxon 9 HE):

Some text: SallyAdee

Then I switched from DTD to XSD. That is, now the source document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../zettel.xsl"?>
<zettel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="../zettel.xsd">
B B B <head>
B B B B B B B <keywords>
B B B B B B B B B B B <author>
B B B B B B B B B B B B B B B <first>Sally</first>
B B B B B B B B B B B B B B B <last>Adee</last>
B B B B B B B B B B B </author>
B B B B B B B </keywords>
B B B </head>
</zettel>


And now the output of the same stylesheet is different:

B B B B B B B B B B B  Some text:
B B B B B B B B B B B B B B B  Sally
B B B B B B B B B B B B B B B  Adee

That is, there is a lot of additional white space. (I am here omitting from the output several empty lines.) I figured out that I need to add "<xsl:strip-space elements="*"/>" to the stylesheet to receive the old output with the new source document. But I do not understand why this is necessary, or why it was not necessary before. How can the mere switch from DTD to XSD in the source document change how the stylesheet handles white space? The DTD and the XSD are, as far as I can tell, equivalent (i.e., the XSD is a translation of the DTD), and neither, as far as I can see, says anything about the handling of white space. So I am at a loss.

Thanks in advance for your help!
Wolfhart

Current Thread