TEIC / TEI

The Text Encoding Initiative Guidelines
https://www.tei-c.org
Other
279 stars 88 forks source link

“Deprecation” message: <content> gets 1 and only 1 child #2410

Closed sydb closed 1 year ago

sydb commented 1 year ago

Here is what I did:

Here is what the warning messages look like (whitespace altered for readability) …

2+ TEI children:

In the near future the <content> element will be limited to 1 and
only 1 child element. This <content> element is in an elementSpec
with an @ident of "constraintSpec" and has 2 children, which
could be wrapped in a <sequence> element.

2+ RELAX NG children:

In the near future the <content> element will be limited to 1 and
only 1 child element. This <content> element is in a moduleRef
with a @url of "http://www.w3.org/Math/RelaxNG/mathml3/mathml3.rng"
and has 2 children, which could be wrapped in an <rng:div> element.

2+ children, not all TEI, not all RELAX NG:

In the near future the <content> element will be limited to 1 and
only 1 child element. This <content> element is in an elementSpec
with an @ident of "publicationStmt" and has 3 children, but those
children are neither all TEI elements nor all RELAX NG elements,
and thus this <content> is invalid and can not be easily rectified.

What I did not do was use role="warning" on the <sch:assert> and <sch:report> elements. I probably should have, and may well fix that and commit shortly.

sydb commented 1 year ago

More:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.tei-c.org/ns/1.0"
  xmlns:tei="http://www.tei-c.org/ns/1.0"
  xmlns:rng="http://relaxng.org/ns/structure/1.0"
  xmlns:rna="http://relaxng.org/ns/compatibility/annotations/1.0"
  xpath-default-namespace="http://www.tei-c.org/ns/1.0"
  exclude-result-prefixes="#all"
  version="3.0">

  <xsl:output method="xml" indent="yes"/>
  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:template match="content[ *[2] ]" as="element(content)">
    <xsl:variable name="wrapperGI">
      <xsl:choose>
        <xsl:when test="tei:* and not( rng:* | rna:* )">sequence</xsl:when>
        <xsl:when test="( rng:* | rna:* ) and not( tei:* )">rng:div</xsl:when>
        <xsl:otherwise>
          <xsl:sequence select="'HUMAN_FIX_THIS'"/>
          <xsl:message>ERROR: content element with children that are neither all TEI nor all RELAX NG; contents will be wrapped in an invalid &lt;HUMAN_FIX_THIS> element.</xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:element name="{$wrapperGI}">
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>