XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Schematron Best Practice: A Schematron schema's area of responsibility?

Thanks Bryan.  As always, excellent input.

I would like to extend my question a bit.

Consider this sequence of activities:

XML instance --> grammar-based validation --> rule-based validation -->
process the XML document

Read as: first validate an XML instance document using a grammar-based
language (e.g. DTD, Relax NG, XML Schema), then validate using a
rule-based language (i.e. Schematron) and then if both validations are
successful process the XML document.

Is this sequence of activities best practice for assessing the
constraints in an XML document?

Does this mean that a Schematron schema may assume that any grammar
type of constraints have already been validated?

For example, consider the classification attribute on this Para
element:

     <Para classification="unclassified">
           One if by land, two if by sea;
     </Para>

The value of the classification attribute is legal only if it is one of
top-secret, secret, confidential or unclassified. 

This constraint can be implemented using a grammar-based language, e.g.
here's how to do it using XML Schema:

<attribute name="classification">
    <simpleType>
        <enumeration value="top-secret" />
        <enumeration value="secret" />
        <enumeration value="confidential" />
        <enumeration value="unclassified" />
    </simpleType>
</attribute>

But it can also be easily implemented using Schematron.

However, if best practice is the sequence shown above (i.e. perform
grammar-based validation and then perform Schematron validation) then a
Schematron schema can safely leave the job of validating the value of
the classification attribute to the grammar-based validation, and focus
on what it does best (co-constraint checking, cardinality checking,
algorithmic checking).

What do you think about these as recommended best practices:

1. Validate the grammar of XML instance documents using a grammar-based
schema language, and then validate co-constraints, data cardinality,
and algorithmic checks using a Schematron schema.

2. A Schematron schema may safely assume all grammar type of
constraints have already been implemented and validated by a
grammar-based validation. 

3. A Schematron schema should focus on just implementing
co-constraints, data cardinality checks, and algorithmic checks (things
that grammar-based languages can't express).


/Roger






-----Original Message-----
From: bryan rasmussen [mailto:rasmussen.bryan@gmail.com] 
Sent: Thursday, June 28, 2007 12:03 PM
To: Costello, Roger L.
Cc: xml-dev@lists.xml.org
Subject: Re: [xml-dev] Schematron Best Practice: A Schematron schema's
area of responsibility?

Well, questions to ask about languages when they are equivalent in
abilities are which one would it be easiest to implement it in. Which
one would be easiest to maintain and extend.

one might be able to put this kind of co-constraint thing into a
grammar based language but you would tie yourself in knots to do it.
it would make your grammar based language difficult to maintain, just
as doing many grammar things in schematron would make it difficult to
maintain.

cheers,
Bryan Rasmussen

On 6/28/07, Costello, Roger L. <costello@mitre.org> wrote:
> ISSUE
>
> When implementing an XML instance document's set of constraints, what
> is a Schematron schema's area of responsibility?
>
> EXAMPLE
>
> Consider this XML instance document:
>
> <?xml version="1.0"?>
> <Document classification="secret">
>     <Para classification="unclassified">
>           One if by land, two if by sea;
>     </Para>
> </Document>
>
> Schematron is very well-suited for implementing this co-constraint:
>
> Security Classification Policy: For the instance document to be valid
> no <Para> element may have a classification value higher than the
> <Document>'s classification value.
>
> The implementation of this co-constraint is shown at the bottom of
this
> message.
>
> RESPONSIBILITY OF A SCHEMATRON SCHEMA
>
> The implementation makes some assumptions.  For example, it assumes
> that the classification attributes have already been verified to have
> legal values (top-secret, secret, confidential, and unclassified).
>
> The Schematron schema *could* validate that the classification
> attributes have legal values.  But so could a grammar-based schema
> language (e.g. Relax NG, XML Schema).
>
> QUESTIONS
>
> 1. What is the responsibility of a Schematron schema?
>
> 2. Should a Schematron schema implement constraints that could be
done
> by a grammar-based schema language?
>
> 3. Should a Schematron schema implement only those constraints which
> cannot be implemented by a grammar-based schema languages such as
> co-constraints, data cardinality checks, and algorithmic checks?
>
> 4. How much intersection should there be between the set of
constraints
> implemented by a Schematron schema and the set of constraints
> implemented by a grammar-based schema?
>
> IMPLEMENTATION OF THE SECURITY CLASSIFICATION POLICY
>
>    <sch:pattern name="Security Classification Policy">
>
>       <sch:p>A Para's classification value cannot be more sensitive
>              than the Document's classification value.</sch:p>
>
>       <sch:rule context="Para[@classification='top-secret']">
>
>          <sch:assert test="/Document/@classification='top-secret'">
>              If there is a Para labeled "top-secret" then the
Document
>
>              must be labeled top-secret
>          </sch:assert>
>
>       </sch:rule>
>
>       <sch:rule context="Para[@classification='secret']">
>
>          <sch:assert test="(/Document/@classification='top-secret')
or
>                            (/Document/@classification='secret')">
>              If there is a Para labeled "secret" then the Document
>              must be labeled either secret or top-secret
>          </sch:assert>
>
>       </sch:rule>
>
>       <sch:rule context="Para[@classification='confidential']">
>
>          <sch:assert test="(/Document/@classification='top-secret')
or
>                            (/Document/@classification='secret') or
>
(/Document/@classification='confidential')">
>              If there is a Para labeled "confidential" then the
> Document
>              must be labeled either confidential, secret or
top-secret
>          </sch:assert>
>
>       </sch:rule>
>
>    </sch:pattern>
>
> /Roger
>
>
>
_______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS