With a schema [...], the schema-validity of an element information item can be assessed. Three primary approaches to this are possible:
- The user or application identifies a complex type definition from among the {type definitions} of the schema, and appeals to Schema-Validity Assessment (Element) (§3.3.4) (clause 1.2);
- The user or application identifies a element declaration from among the {element declarations} of the schema, checks that its {name} and {target namespace} match the [local name] and [namespace name] of the item, and appeals to Schema-Validity Assessment (Element) (§3.3.4) (clause 1.1);
- The processor starts from Schema-Validity Assessment (Element) (§3.3.4) with no stipulated declaration or definition, and either strict or lax assessment ensues, depending on whether or not the element information and the schema determine either an element declaration (by name) or a type definition (via xsi:type) or not.
validity_by_type(Element,Type,Result). validity_by_decl(Element,Elemdecl,Result). validity(Element,Result).The last of these forms seeks an xsi:type attribute or an element declaration, and then invokes the appropriate predicate with the type definition or element declaration it finds:
validity(Element,Result) :- xsitype_label(Element,Type), !, validity_by_type(Element,Type,Result). validity(Element,Result) :- qnamelookup(Element,Decl), !, validity_by_decl(Element,Decl,Result).Continued in < 2 >
validity(Element,Result) :- validity_lax(Element,Result).
Note that every element and attribute information item participating in the assessment will also have a [validation context] property which refers back to the element information item at which assessment began. [Definition:] This item, that is the element information item at which assessment began, is called the validation root.
/* Top-level invocation of schema-validity assessment with a type: recur to validity_by_type/4, passing starting element as validation root. Ditto for assessment with an element declaration. */ validity_by_type(Element,Type,Result) :- validity_by_type(Element,Type,Element,Result). validity_by_decl(Element,Decl,Result) :- validity_by_decl(Element,Decl,Element,Result). /* Top-level invocation of schema-validity assessment without any type or declaration: find one, if you can, otherwise go lax. */ validity(Element,Result) :- xsitype_label(Element,Type), !, validity_by_type(Element,Type,Element,Result). validity(Element,Result) :- Element = element(Ns:Local,_,_), qname_lookup(elementDeclarations,Ns,Local,Decl), !, validity_by_decl(Element,Decl,Element,Result). validity(Element,Result) :- validity_lax(Element,Element,Result).
node(schema, [], [typeDefinitions([...]), attributeDeclarations([...]), elementDeclarations([...]), attributeGroupDefinitions([...]), modelGroupDefinitions([...]), notationDeclarations([...]), ])
qname_lookup(Comptype,Ns,Local,Result) :- the_schema(S), qname_lookup(S,Comptype,Ns,Local,Result). qname_lookup(S,Comptype,Ns,Local,Result) :- S^^Comptype(List), listfind_by_qname(List,Ns,Local,Result). /* If the head of the list has the right namespace * and local name, we have found the item we seek. * Otherwise, look in the tail of the list. */ listfind_by_qname([Head|Tail],Ns,Local,Head) :- Head^^targetNamespace(Ns), Head^^name(Local). listfind_by_qname([_|Tail],Ns,Local,Result) :- listfind_by_qname(Tail,Ns,Local,Result).
[validation context] | The nearest ancestor element information item with a {schema information} property (or this element item itself if it has such a property). |
[validity] |
The appropriate case
among the following:
|
[validation attempted] |
The appropriate case
among the following:
|
[schema error code] |
The appropriate case
among the following:
|
[element declaration] | an item isomorphic to the declaration component itself |
[nil] | true if clause 3.2 of Element Locally Valid (Element) above is satisfied, otherwise false |
[schema normalized value] |
The appropriate case
among the following:
|
[type definition] | An item isomorphic to the type definition component itself. |
[member type definition] | If and only if that type definition is a
simple type definition with {variety} union, or a complex type
definition whose {content type} is a simple
|
[type definition type] | simple or complex, depending on the type definition. |
[type definition namespace] | The target namespace of the type definition. |
[type definition anonymous] | true if the name of the type definition is absent, otherwise false. |
[type definition name] | The name of the type definition, if it is not absent. If it is absent, schema processors may, but need not, provide a value unique to the definition. |
[member type definition namespace] | The {target namespace} of the actual member type definition. |
[member type definition anonymous] | true if the {name} of the actual member type definition is absent, otherwise false. |
[member type definition name] | The {name} of the actual member type definition, if it is not absent. If it is absent, schema processors may, but need not, provide a value unique to the definition. |
[schema default] | The canonical lexical representation of the declaration's {value constraint} value. |
[schema specified] |
The appropriate case
among the following:
|
[validation context] | The nearest ancestor element information item with a {schema information} property. |
[validity] |
The appropriate case
among the following:
|
[validation attempted] |
The appropriate case
among the following:
|
[schema specified] | infoset. See Attribute Default Value for the other possible value. |
[schema error code] |
The appropriate case
among the following:
|
[attribute declaration] | An item isomorphic to the declaration component itself. |
[schema normalized value] | The normalized value of the item as validated. |
[type definition] | An item isomorphic to the relevant attribute declaration's {type definition} component. |
[member type definition] | If and only if that type definition has {variety} union, then an item isomorphic to that member of its {member type definitions} which actually validated the attribute item's [normalized value]. |
[type definition type] | simple. |
[type definition namespace] | The {target namespace} of the type definition. |
[type definition anonymous] | true if the {name} of the type definition is absent, otherwise false. |
[type definition name] | The {name} of the type definition, if it is not absent. If it is absent, schema processors may, but need not, provide a value unique to the definition. |
[member type definition namespace] | The {target namespace} of the actual member type definition. |
[member type definition anonymous] | true if the {name} of the actual member type definition is absent, otherwise false. |
[member type definition name] | The {name} of the actual member type definition, if it is not absent. If it is absent, schema processors may, but need not, provide a value unique to the definition. |
[schema default] | The canonical lexical representation of the declaration's {value constraint} value. |
Base particle | |||||
---|---|---|---|---|---|
Derived particle | elt | any | all | choice | sequence |
elt | NameAnd- TypeOK | NSCompat | Recurse- AsIfGroup | Recurse- AsIfGroup | RecurseAs- IfGroup |
any | NSSubset | Forbidden | Forbidden | Forbidden | Forbidden |
all | NSRecurse- CheckCardinality | Recurse | Forbidden | Forbidden | Forbidden |
choice | NSRecurse- CheckCardinality | RecurseLax | Forbidden | Forbidden | Forbidden |
seq- uence | NSRecurse- CheckCardinality | Recurse- Unordered | MapAndSum | Recurse | Forbidden |
<xs:complexType> <xs:complexContent> <xs:restriction base="xs:urType"> . . . <xs:any . . . processContents="skip"/> . . . </xs:restriction> </xs:complexContent> </xs:complexType>
[ID/IDREF table] | A (possibly empty) set of ID/IDREF binding information items, as specified below. |
[id] | The string identified above. |
[binding] | A set consisting of every element information item for which
all of the following are true:
|
Selector ::= Path ( '|' Path )* Path ::= ('.//')? Step ( '/' Step )* Step ::= '.' | NameTest NameTest ::= QName | '*' | NCName ':' '*'
token ::= '.' | '/' | '//' | '|' | '@' | NameTest whitespace ::= S
Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )This production differs from the one above in allowing the final step to match an attribute node.
[identity-constraint table] |
one
Identity-constraint Binding
information item for each eligible identity-constraint, with
properties as follows:
|
[notation] | An item isomorphic to the notation declaration whose {name} and {target namespace} match the local name and namespace name (as defined in QName Interpretation) of the attribute item's actual value |
[notation system] | The value of the {system identifier} of that notation declaration. |
[notation public] | The value of the {public identifier} of that notation declaration. |
[schema information] | A set of namespace schema information information items, one for each namespace name which appears as the
target namespace of any schema component in the schema used for that
assessment, and one for absent if any schema
component in the schema had no target namespace. Each namespace schema information information item has the
following properties and values:
|
Abramson, Harvey. 1984. “Definite Clause Translation Grammars”. Proceedings of the 1984 International Symposium on Logic Programming, Atlantic City, New Jersey, February 6-9, 1984, pp. 233-240. (IEEE-CS 1984, ISBN 0-8186-0522-7)
Abramson, Harvey, and Veronica Dahl. 1989. Logic Grammars. Symbolic Computation AI Series. Springer-Verlag, 1989.
Abramson, Harvey, and Veronica Dahl, rev. Jocelyn Paine. 1990. DCTG: Prolog definite clause translation grammar translator. (Prolog code for translating from DCTG notation to standard Prolog. Note says syntax extended slightly by Jocelyn Paine to accept && between specifications of grammatical attributes, to minimize need for parentheses. Available from numerous AI/NLP software repositotries, including http://www-2.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/prolog/code/syntax/dctg/0.html, http://www.ims.uni-stuttgart.de/ftp/pub/languages/prolog/libraries/imperial_college/dctg.tar.gz, and http://www.ifs.org.uk/~popx/prolog/dctg/.)
Alblas, Henk. 1991. “Introduction to attribute grammars”. Attribute grammars, applications and systems: International Summer School SAGA, Prague, Czechoslovakia, June 4-13, 1991, Proceedings, pp. 1-15. Berlin: Springer, 1991. Lecture Notes in Computer Science, 545.
Bratko, Ivan. 1990. Prolog programming for artificial intelligence. Second edition. Wokingham: Addison-Wesley. xxi, 597 pp.
Brown, Allen L., Jr., and Howard A. Blair. 1990. “A logic grammar foundation for document representation and layout”. In EP90: Proceedings of the International Conference on Electronic Publishing, Document Manipulation and Typography, ed. Richard Furuta. Cambridge: Cambridge University Press, 1990, pp. 47-64.
Brown, Allen L., Jr., Toshiro Wakayama, and Howard A. Blair. 1992. “A reconstruction of context-dependent document processing in SGML”. In EP92: Proceedings of Electronic Publishing, 1992, ed. C. Vanoirbeek and G. Coray. Cambridge: Cambridge University Press, 1992. Pages 1-25.
Brüggemann-Klein, Anne. 1993. Formal models in document processing. Habilitationsschrift, Freiburg i.Br., 1993. 110 pp. Available at ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps (Cover pages archival copy also at http://www.oasis-open.org/cover/bruggDissert-ps.gz).
Clocksin, W. F., and C. S. Mellish. Programming in Prolog. Second edition. Berlin: Springer, 1984.
Gal, Annie, Guy Lapalme, Patrick Saint-Dizier, and Harold Somers. 1991. Prolog for natural language processing. Chichester: Wiley, 1991. xiii, 306 pp.
Gazdar, Gerald, and Chris Mellish. 1989. Natural language processing in PROLOG: An introduction to computational linguistics. Wokingham: Addison-Wesley, 1989. xv, 504 pp.
Grune, Dick, and Ceriel J. H. Jacobs. 1990. Parsing techniques: a practical guide. New York, London: Ellis Horwood, 1990. Postscript of the book is available from the first author's Web site at http://www.cs.vu.nl/~dick/PTAPG.html
Knuth, D. E. 1968. “Semantics of context-free languages”. Mathematical Systems Theory 2: 127-145.
König, Esther, and Roland Seiffert. Grundkurs PROLOG für Linguisten. Tübingen: Francke, 1989. [= Uni-Taschenbücher 1525]
Sperberg-McQueen, C. M. 2003a. “Notes on logic grammars and XML Schema”. Working paper prepared for the W3C XML Schema Working Group. [Incomplete; current draft is at dctgnotes.html. Introduction to logic grammar notation, illustrative translation of purchase-order schema into logic grammar form.]
Sperberg-McQueen, C. M. 2003b. “An XML Schema validator in logic-grammar form”. Working paper prepared for the W3C XML Schema Working Group. [Incomplete; incomplete outline is at xsvlgf.html. Will provide a DCTG representation of the schema for schemas, with actions to perform the XML-to-component transformation and code to check the constraints on schemas.]
Stepney, Susan. 1993. High-integrity compilation. Prentice-Hall. Available from http://www-users.cs.york.ac.uk/~susan/bib/ss/hic/index.htm. Chapter 3 (Using Prolog) provides a terse introduction to DCTG notation and use.
[W3C 1999] W3C. XML Path Language, ed. James Clark and Steve DeRose. W3C Recommendation 16 November 1999. [Cambridge, Sophia-Antipolis, and Tokyo]: World Wide Web Consortium. See http://www.w3.org/TR/1999/REC-xpath-19991116
[W3C 2000] W3C. Extensible Markup Language (XML) 1.0, Second Edition, ed. Tim Bray et al. W3C Recommendation 6 October 2000. [Cambridge, Sophia-Antipolis, and Tokyo]: World Wide Web Consortium. http://www.w3.org/TR/2000/REC-xml-20001006
[W3C 2001a] “XML Schema Part 0: Primer”, ed. David Fallside. W3C Recommendation, 2 May 2001. [Cambridge, Sophia-Antipolis, Tokyo: W3C] http://www.w3.org/TR/xmlschema-0/.
[W3C 2001b] 2001. XML Schema Part 1: Structures, ed. Henry S. Thompson, David Beech, Murray Maloney, and Noah Mendelsohn. W3C Recommendation 2 May 2001. [Cambridge, Sophia-Antipolis, and Tokyo]: World Wide Web Consortium. http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/
[W3C 2001c] W3C. 2001. XML Schema Part 2: Datatypes, ed. Biron, Paul V. and Ashok Malhotra. W3C Recommendation 2 May 2001. [Cambridge, Sophia-Antipolis, and Tokyo]: World Wide Web Consortium. http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/
Wielemaker, Jan. “SWI-Prolog SGML/XML parser: Version 1.0.14, March 2001”. http://www.swi-prolog.org/packages/sgml2pl.html