Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

during ODD compilation, in attribute classes with mode="change", following siblings of attList are not copied #254

Closed
bansp opened this issue Apr 3, 2017 · 10 comments
Assignees

Comments

@bansp
Copy link
Member

bansp commented Apr 3, 2017

Assume an attribute class of the following skeletal form:

<classSpec ... ident="test_class" type="atts" module="tei">
   <attList>
	<attDef ident="name1" usage="opt">
			<desc versionDate="2017-03-21" xml:lang="en">blah</desc>
			<datatype>
				<dataRef key="teidata.enumerated"/>
			</datatype>
			<defaultVal>old_default</defaultVal>
			<valList type="closed">...</valList>
       </attDef>
             <!-- and so on -->
  </attList>
  <remarks>These remarks are going to vanish.</remarks>
</classSpec>

In your ODD, do:

<classSpec ident="test_class" mode="change" type="atts" module="tei">
                    <attList>
                        <attDef ident="name1" usage="opt" mode="change">
                            <defaultVal>new_default</defaultVal>
                        </attDef>
                    </attList>
</classSpec>

I assume that this sentence from ch. 23 (paraphrased for classSpec) holds: "Note that the 'mode' attribute on the elementSpec now takes the value 'change' to indicate that those parts of the element specification not supplied are to be inherited from the standard definition." However, in the above case, the default value is changed as intended, but <remarks> are not inherited.

The vanishing takes place at the stage of ODD compilation (I compared a compiled ODD without the classSpec[@mode="change"] with one containing that instruction).

@bansp
Copy link
Member Author

bansp commented Apr 3, 2017

Oh, it's more general: everything apart from that <attList> vanishes, i.e. both <exemplum> and <remarks>. So now I'm asking myself: is this a bug report because an identity transform fails to get fired at following siblings of the attList, or am I simply doing something wrong in my ODD (in the second example)? Thanks.

@martindholmes
Copy link
Contributor

If it's only the attlist you want to change, what happens when you put the @mode="change" on attList instead of on the spec?

@bansp
Copy link
Member Author

bansp commented Apr 3, 2017

attList doesn't accept a @mode, and you always have to have a @mode at the top, i.e. on the *Spec. I mean, to my knowledge (?)

@bansp
Copy link
Member Author

bansp commented Apr 3, 2017

Here you can see a somewhat analogous example: http://www.tei-c.org/release/doc/tei-p5-doc/en/html/USE.html#MDMDAL

@lb42
Copy link
Member

lb42 commented Apr 3, 2017

I can't reproduce this behaviour. If I process a simple ODD which contains this

 <classSpec type="atts" ident="att.global" mode="change">
          <attList>
            <attDef ident="xml:space" mode="delete"/>
            <attDef ident="xml:base" mode="delete"/>
            <attDef ident="n" mode="change">
              <defaultVal>42</defaultVal>
            </attDef>
          </attList>    
       </classSpec>

The generated HTML has my new default value, but also the remarks which were in the original (see attached screenshot).

Maybe you could post the ODD which is misbehaving? It's hard to debug without evidence.
piotr

@bansp
Copy link
Member Author

bansp commented Apr 3, 2017

As far as I can see, att.global doesn't have a 'global' exemplum or remarks. Would you please try with att.internetMedia, att.typed, or anything analogous? I can't strip down a test case at this moment.

It's the siblings of <attList> that appear to be affected.

@lb42
Copy link
Member

lb42 commented Apr 3, 2017

Ah, now I see it. OK, I confirm that this is a bug. Modifying the attribute list of an attribute class has the side effect of suppressing any following-sibling elements of the attList in that specification, notably any <remarkss> or a <listRef> .

@bansp bansp changed the title during ODD compilation with mode="change", <remarks> vanish from a classSpec during ODD compilation, in attribute classes with mode="change", following siblings of attList are not copied Apr 4, 2017
@martindholmes
Copy link
Contributor

Simple test ODD for this bug:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" type="application/xml"
	schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <teiHeader>
      <fileDesc>
         <titleStmt>
            <title>Test for Stylesheets issue #254</title>
         </titleStmt>
         <publicationStmt>
            <p>Public</p>
         </publicationStmt>
         <sourceDesc>
            <p>Information about the source</p>
         </sourceDesc>
      </fileDesc>
  </teiHeader>
  <text>
      <body>
         <schemaSpec ident="myTEI">
            <moduleRef key="tei"/>
            <moduleRef key="core"/>
            <moduleRef key="header"/>
            <moduleRef key="textstructure"/>
            <classSpec ident="att.internetMedia" mode="change" type="atts" module="tei">
               <attList>
                  <attDef ident="mimeType" usage="opt" mode="change">
                     <valList mode="add">
                        <valItem ident="image/jpeg">
                           <gloss>JPEG image</gloss>
                        </valItem>
                        <valItem ident="image/png">
                           <gloss>PNG image</gloss>
                        </valItem>
                     </valList>
                  </attDef>
               </attList>
            </classSpec>
      </schemaSpec>
      </body>
  </text>
</TEI>

The problem occurs in odd2odd processing (expanding the ODD).

@martindholmes
Copy link
Contributor

martindholmes commented Jun 1, 2017

This is our first pass at a solution: a change to a template in odd2odd.xsl, at line 1145:

<xsl:template match="tei:classSpec" mode="odd2odd-change">
    <xsl:variable name="className" select="tei:uniqueName(.)"/>
    <xsl:variable name="ORIGINAL" select="."/>
    <xsl:copy>
      <xsl:attribute name="rend">change</xsl:attribute>
      <xsl:apply-templates mode="odd2odd-change" select="@*"/>
      <!-- for each section of the class spec, 
     go through the sections one by one
     and see if they are present in the change mode version -->
      <xsl:for-each select="$ODD">
        <xsl:for-each select="key('odd2odd-CHANGE',$className)">
          <!-- context is now a classSpec in change mode in the ODD spec -->
          <!-- description -->
          <xsl:choose>
            <xsl:when test="$stripped='true'"/>
            <xsl:when test="tei:gloss">
              <xsl:apply-templates mode="justcopy" select="tei:gloss"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:gloss"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="tei:altIdent">
              <xsl:apply-templates mode="justcopy" select="tei:altIdent"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:altIdent"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="tei:equiv">
              <xsl:apply-templates mode="justcopy" select="tei:equiv"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:equiv"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="$stripped='true'"/>
            <xsl:when test="tei:desc">
              <xsl:apply-templates mode="justcopy" select="tei:desc"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:desc"/>
            </xsl:otherwise>
          </xsl:choose>
          <!-- classes -->
          <classes xmlns="http://www.tei-c.org/ns/1.0">
            <xsl:choose>
              <xsl:when test="tei:classes[@mode eq 'change']">
                <xsl:for-each select="tei:classes/tei:memberOf">
                  <xsl:choose>
                    <xsl:when test="@mode eq 'delete'"/>
                    <xsl:when test="@mode eq 'add' or not (@mode)">
                      <memberOf key="{@key}">
                        <xsl:copy-of select="@min|@max"/>
                      </memberOf>
                    </xsl:when>
                  </xsl:choose>
                </xsl:for-each>
                <xsl:for-each select="$ORIGINAL">
                  <xsl:for-each select="tei:classes/tei:memberOf">
                    <xsl:variable name="me">
                      <xsl:value-of select="@key"/>
                    </xsl:variable>
                    <xsl:variable name="metoo">
                      <xsl:value-of select="concat(../../@ident,@key)"/>
                    </xsl:variable>
                      <xsl:choose>
                        <xsl:when test="$ODD/key('odd2odd-DELETE',$me)"> </xsl:when>
                        <xsl:when test="$ODD/key('odd2odd-MEMBEROFDELETE',$metoo)"> </xsl:when>
                        <xsl:when test="$ODD/key('odd2odd-MEMBEROFADD',$metoo)"> </xsl:when>
                        <xsl:otherwise>
                          <memberOf key="{$me}"/>
                        </xsl:otherwise>
                      </xsl:choose>
                  </xsl:for-each>
                </xsl:for-each>
              </xsl:when>
              <xsl:when test="tei:classes">
                <xsl:for-each select="tei:classes/tei:memberOf">
                  <xsl:copy-of select="."/>
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="$ORIGINAL">
                  <xsl:for-each select="tei:classes/tei:memberOf">
                    <xsl:variable name="me">
                      <xsl:value-of select="@key"/>
                    </xsl:variable>
                    <xsl:for-each select="$ODD">
                      <xsl:if test="not(key('odd2odd-DELETE',$me))">
                        <memberOf key="{$me}"/>
                      </xsl:if>
                    </xsl:for-each>
                  </xsl:for-each>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
          </classes>
          <!-- constraints -->
          <xsl:call-template name="odd2odd-processConstraints">
            <xsl:with-param name="ORIGINAL" select="$ORIGINAL"/>
            <xsl:with-param name="elementName" select="$className"/>
          </xsl:call-template>
          <!-- attList -->
          <attList xmlns="http://www.tei-c.org/ns/1.0">
            <xsl:call-template name="odd2odd-processAttributes">
              <xsl:with-param name="ORIGINAL" select="$ORIGINAL"/>
              <xsl:with-param name="objectName" select="$className"/>
            </xsl:call-template>
          </attList>
          <xsl:choose>
            <xsl:when test="$stripped='true'"/>
            <xsl:when test="tei:exemplum">
              <xsl:apply-templates mode="justcopy" select="tei:exemplum"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:exemplum"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="$stripped='true'"/>
            <xsl:when test="tei:remarks">
              <xsl:apply-templates mode="justcopy" select="tei:remarks"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:remarks"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="$stripped='true'"/>
            <xsl:when test="tei:listRef">
              <xsl:apply-templates mode="justcopy" select="tei:listRef"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates mode="justcopy" select="$ORIGINAL/tei:listRef"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>

This needs:

  1. Optimizing?
  2. Commenting.
  3. Testing directly.
  4. Running through the Stylesheet test suite.

sydb added a commit that referenced this issue Jun 1, 2017
Implement change worked out on this morning on conference call to addrss #254
@sydb
Copy link
Member

sydb commented Jun 2, 2017

Fixed at fbf7979 (actual fix in 8e71c23, then get expected_results right in fbf7979)

@sydb sydb closed this as completed Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants