W3C home > Mailing lists > Public > public-i18n-its@w3.org > January to March 2006

[Bug 3039] Proposal: check constraints in global rules

From: <bugzilla@wiggum.w3.org>
Date: Fri, 24 Mar 2006 02:11:17 +0000
CC:
To: public-i18n-its@w3.org
Message-Id: <E1FMbll-0003dE-LS@wiggum.w3.org>

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3039

           Summary: Proposal: check constraints in global rules
           Product: ITS
           Version: WorkingDraft
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ITS tagset
        AssignedTo: fsasaki@w3.org
        ReportedBy: fsasaki@w3.org
         QAContact: public-i18n-its@w3.org


I propose to have a non-normative example in the spec how to check constraints
on the global rules.
Example: the constraint that an its:locInfoRule element must not have both an
its:locInfo child element and an @its:locInfoPointer attribute.

We could give an example of a schematron document that describes what to check.

<schema xmlns="http://www.ascc.net/xml/schematron" >
<ns prefix="its" uri="http://www.w3.org/2005/11/its"/>
     <pattern name="Check ITS Global Rules Constraint">
          <rule context="its:locInfoRule">
               <report test="its:locInfo and @its:locInfoPointer">An
its:locInfoRule element must not have both an its:locInfo child element and an
@its:locInfoPointer attribute.</report>
<!--               <assert test="@name">AAA misses attribute name.</assert>
               <report test="@name">AAA contains attribute name.</report>-->
          </rule>
     </pattern>
</schema>

Out of this, we generate an xslt stylesheet via e.g. the existing schematron
processor skeleton1-5.xsl:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sch="http://www.ascc.net/xml/schematron"
xmlns:its="http://www.w3.org/2005/11/its" version="1.0" its:dummy-for-xmlns="">
   <xsl:template match="*|@*" mode="schematron-get-full-path">
      <xsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
      <xsl:text>/</xsl:text>
      <xsl:if test="count(. | ../@*) = count(../@*)">@</xsl:if>
      <xsl:value-of select="name()"/>
      <xsl:text>[</xsl:text>
      <xsl:value-of
select="1+count(preceding-sibling::*[name()=name(current())])"/>
      <xsl:text>]</xsl:text>
   </xsl:template>
   <xsl:template match="/">
      <xsl:apply-templates select="/" mode="M1"/>
   </xsl:template>
   <xsl:template match="its:locInfoRule" priority="4000" mode="M1">
      <xsl:if test="its:locInfo and @its:locInfoPointer">
<xsl:apply-templates mode="schematron-get-full-path"/>
<xsl:text>An its:locInfoRule element must not have both an its:locInfo child
element and an @its:locInfoPointer attribute.</xsl:text></xsl:if>
      <xsl:apply-templates mode="M1"/>
   </xsl:template>
   <xsl:template match="text()" priority="-1" mode="M1"/>
   <xsl:template match="text()" priority="-1"/>
</xsl:stylesheet>

Applying this stylesheet to the erronous file
<its:documentRules xmlns:its="http://www.w3.org/2005/11/its">
<its:locInfoRule its:select="//p" its:locInfoPointer="@existing-locInfo">
<its:locInfo>New locInfo</its:locInfo>
</its:locInfoRule>
</its:documentRules>

Will give the following result:
/its:documentRules[1]/its:locInfoRule[1]/its:locInfo[1]
An its:locInfoRule element must not have both an its:locInfo child element and
an @its:locInfoPointer attribute.
Received on Friday, 24 March 2006 02:11:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:43:06 UTC