Project

Profile

Help

Schema and indentation

Added by T Hata over 5 years ago

With this set of files

  • test.dita
<?xml version="1.0" encoding="UTF-8"?>
<topic id="topic_akt_22s_b3b" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd"
><title /><body
><table><tgroup cols="1"><tbody><row><entry /></row></tbody></tgroup></table
><section><table><tgroup cols="1"><tbody><row><entry /></row></tbody></tgroup></table></section
></body></topic>
  • test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="3.0"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" />
	<xsl:template as="document-node()" match="document-node()">
		<xsl:copy-of select="." validation="strict" />
	</xsl:template>
</xsl:stylesheet>

running the transformation does not indent the second <table> at all:

C:\test>java -cp "saxon9ee.jar;resolver.jar" net.sf.saxon.Transform -catalog:dita-v1.3-errata02-os-part2-tech-content-complete-grammars\catalog.xml -expand:off -s:test.dita -sa -t -xsl:test.xsl
...
Saxon-EE 9.9.1.3J from Saxonica
Java version 1.8.0_181
Using license serial number V......
...
<?xml version="1.0" encoding="UTF-8"?>
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       id="topic_akt_22s_b3b"
       xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
   <title/>
   <body>
      <table>
         <tgroup cols="1">
            <tbody>
               <row>
                  <entry/>
               </row>
            </tbody>
         </tgroup>
      </table>
      <section><table><tgroup cols="1"><tbody><row><entry/></row></tbody></tgroup></table></section>
   </body>
</topic>

Is it by design?

I expected something like this:

<?xml version="1.0" encoding="UTF-8"?>
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       id="topic_akt_22s_b3b"
       xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
   <title />
   <body>
      <table>
         <tgroup cols="1">
            <tbody>
               <row>
                  <entry />
               </row>
            </tbody>
         </tgroup>
      </table>
      <section><table>
            <tgroup cols="1">
               <tbody>
                  <row>
                     <entry />
                  </row>
               </tbody>
            </tgroup>
         </table></section>
   </body>
</topic>

Replies (2)

RE: Schema and indentation - Added by Michael Kay over 5 years ago

The section element has mixed content, while the table element has element-only content.

The serialization spec says: Whitespace characters SHOULD NOT be added, elided or replaced in places where the characters would constitute significant whitespace, for example, in the immediate content of an element that is annotated with a type other than xs:untyped or xs:anyType, and whose content model is known to be mixed. [my emphasis]

Saxon implements this rule effectively by treating a mixed-content element as if suppress-indentation was specified; that is, it suppresses indentation not only for the element's immediate content, but also for nested content. This is not required by the rules, but it is permitted by the rules, and it simplifies the implementation. Having element-only content within a mixed content element may be regarded as a bit of an edge case.

RE: Schema and indentation - Added by T Hata over 5 years ago

Thanks for the clarification, though the current implementation is a bit disappointing.

    (1-2/2)

    Please register to reply