This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3039 - Proposal: check constraints in global rules
Summary: Proposal: check constraints in global rules
Status: CLOSED FIXED
Alias: None
Product: ITS
Classification: Unclassified
Component: ITS tagset (show other bugs)
Version: WorkingDraft
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Felix Sasaki
QA Contact: Felix Sasaki
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-24 02:11 UTC by Felix Sasaki
Modified: 2006-07-24 10:31 UTC (History)
0 users

See Also:


Attachments

Description Felix Sasaki 2006-03-24 02:11:14 UTC
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.
Comment 1 Felix Sasaki 2006-04-20 08:20:56 UTC
closed after discussion at http://www.w3.org/2006/04/18-i18nits-minutes.html#item07 , felix to integrate the result in the spec.
Comment 2 Felix Sasaki 2006-07-24 10:31:36 UTC
Closed, no further action necessary.