Misplaced Pages

Schematron

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a structural schema language expressed in XML using a small number of elements and XPath languages. In many implementations, the Schematron XML is processed into XSLT code for deployment anywhere that XSLT can be used.

#320679

56-655: Schematron is capable of expressing constraints in ways that other XML schema languages like XML Schema and DTD cannot. For example, it can require that the content of an element be controlled by one of its siblings. Or it can request or require that the root element, regardless of what element that is, must have specific attributes. Schematron can also specify required relationships between multiple XML files. Constraints and content rules may be associated with "plain-English" (or any language) validation error messages, allowing translation of numeric Schematron error codes into meaningful user error messages. Users of Schematron define all

112-549: A numeric character reference . Consider the Chinese character "中", whose numeric code in Unicode is hexadecimal 4E2D, or decimal 20,013. A user whose keyboard offers no method for entering this character could still insert it in an XML document encoded either as &#20013; or &#x4e2d; . Similarly, the string "I <3 Jörg" could be encoded for inclusion in an XML document as I &lt;3 J&#xF6;rg . &#0;

168-675: A W3C Recommendation in April 2012 , which means it is an approved W3C specification. Significant new features in XSD 1.1 are: Until the Proposed Recommendation draft, XSD 1.1 also proposed the addition of a new numeric data type, precisionDecimal. This proved controversial, and was therefore dropped from the specification at a late stage of development. W3C XML Schema 1.0 Specification W3C XML Schema 1.1 Specification Other XML Extensible Markup Language ( XML )

224-520: A complex type may be constrained by assertions— XPath 2.0 expressions evaluated against the content that must evaluate to true. After XML Schema-based validation, it is possible to express an XML document's structure and content in terms of the data model that was implicit during validation. The XML Schema data model includes: This collection of information is called the Post-Schema-Validation Infoset (PSVI). The PSVI gives

280-459: A document, to assure it adheres to the description of the element it is placed in. Like all XML schema languages , XSD can be used to express a set of rules to which an XML document must conform to be considered "valid" according to that schema. However, unlike most other schema languages, XSD was also designed with the intent that determination of a document's validity would produce a collection of information adhering to specific data types . Such

336-448: A list of syntax rules provided in the specification. Some key points in the fairly lengthy list include: The definition of an XML document excludes texts that contain violations of well-formedness rules; they are simply not XML. An XML processor that encounters such a violation is required to report such errors and to cease normal processing. This policy, occasionally referred to as " draconian error handling", stands in notable contrast to

392-522: A mechanism whereby an XML processor can reliably, without any prior knowledge, determine which encoding is being used. Encodings other than UTF-8 and UTF-16 are not necessarily recognized by every XML parser (and in some cases not even UTF-16, even though the standard mandates it to also be recognized). XML provides escape facilities for including characters that are problematic to include directly. For example: There are five predefined entities : All permitted Unicode characters may be represented with

448-555: A more compact non-XML syntax; the two syntaxes are isomorphic and James Clark 's conversion tool— Trang —can convert between them without loss of information. RELAX NG has a simpler definition and validation framework than XML Schema, making it easier to use and implement. It also has the ability to use datatype framework plug-ins ; a RELAX NG schema author, for example, can require values in an XML document to conform to definitions in XML Schema Datatypes. Schematron

504-560: A post-validation infoset can be useful in the development of XML document processing software. XML Schema , published as a W3C recommendation in May 2001, is one of several XML schema languages . It was the first separate schema language for XML to achieve Recommendation status by the W3C. Because of confusion between XML Schema as a specific W3C specification, and the use of the same term to describe schema languages in general, some parts of

560-506: A rich datatyping system and allow for more detailed constraints on an XML document's logical structure. XSDs also use an XML-based format, which makes it possible to use ordinary XML tools to help process them. xs:schema element that defines a schema: RELAX NG (Regular Language for XML Next Generation) was initially specified by OASIS and is now a standard (Part 2: Regular-grammar-based validation of ISO/IEC 19757 – DSDL ). RELAX NG schemas may be written in either an XML based syntax or

616-435: A set of schema components : chiefly element and attribute declarations and complex and simple type definitions. These components are usually created by processing a collection of schema documents , which contain the source language definitions of these components. In popular usage, however, a schema document is often referred to as a schema. Schema documents are organized by namespace: all the named schema components belong to

SECTION 10

#1732790469321

672-404: A target namespace, and the target namespace is a property of the schema document as a whole. A schema document may include other schema documents for the same namespace, and may import schema documents for a different namespace. When an instance document is validated against a schema (a process known as assessment ), the schema to be used for validation can either be supplied as a parameter to

728-468: A valid XML document its "type" and facilitates treating the document as an object, using object-oriented programming (OOP) paradigms. The primary reason for defining an XML schema is to formally describe an XML document; however the resulting schema has a number of other uses that go beyond simple validation. The schema can be used to generate code, referred to as XML Data Binding . This code allows contents of XML documents to be treated as objects within

784-421: A validity error must be able to report it, but may continue normal processing. A DTD is an example of a schema or grammar . Since the initial publication of XML 1.0, there has been substantial work in the area of schema languages for XML. Such schema languages typically constrain the set of elements that may be used in a document, which attributes may be applied to them, the order in which they may appear, and

840-527: A vocabulary to refer to the constructs within an XML document, but does not provide any guidance on how to access this information. A variety of APIs for accessing XML have been developed and used, and some have been standardized. Existing APIs for XML processing tend to fall into these categories: Stream-oriented facilities require less memory and, for certain tasks based on a linear traversal of an XML document, are faster and simpler than other alternatives. Tree-traversal and data-binding APIs typically require

896-461: Is a lexical , event-driven API in which a document is read serially and its contents are reported as callbacks to various methods on a handler object of the user's design. SAX is fast and efficient to implement, but difficult to use for extracting information at random from the XML, since it tends to burden the application author with keeping track of what part of the document is being processed. It

952-456: Is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable . The World Wide Web Consortium 's XML 1.0 Specification of 1998 and several other related specifications —all of them free open standards —define XML. The design goals of XML emphasize simplicity, generality, and usability across

1008-726: Is a language for making assertions about the presence or absence of patterns in an XML document. It typically uses XPath expressions. Schematron is now a standard (Part 3: Rule-based validation of ISO/IEC 19757 – DSDL ). DSDL (Document Schema Definition Languages) is a multi-part ISO/IEC standard (ISO/IEC 19757) that brings together a comprehensive set of small schema languages, each targeted at specific problems. DSDL includes RELAX NG full and compact syntax, Schematron assertion language, and languages for defining datatypes, character repertoire constraints, renaming and entity expansion, and namespace-based routing of document fragments to different validators. DSDL schema languages do not have

1064-604: Is also a compromise among them. Of those languages, XDR and SOX continued to be used and supported for a while after XML Schema was published. A number of Microsoft products supported XDR until the release of MSXML 6.0 (which dropped XDR in favor of XML Schema) in December 2006. Commerce One , Inc. supported its SOX schema language until declaring bankruptcy in late 2004. The most obvious features offered in XSD that are not available in XML's native Document Type Definitions (DTDs) are namespace awareness and datatypes, that is,

1120-578: Is an XML industry data standard. XML is used extensively to underpin various publishing formats. One of the applications of XML is in the transfer of Operational meteorology (OPMET) information based on IWXXM standards. The material in this section is based on the XML Specification . This is not an exhaustive list of all the constructs that appear in XML; it provides an introduction to the key constructs most often encountered in day-to-day use. XML documents consist entirely of characters from

1176-498: Is better suited to situations in which certain types of information are always handled the same way, no matter where they occur in the document. Pull parsing treats the document as a series of items read in sequence using the iterator design pattern . This allows for writing of recursive descent parsers in which the structure of the code performing the parsing mirrors the structure of the XML being parsed, and intermediate parsed results can be used and accessed as local variables within

SECTION 20

#1732790469321

1232-442: Is not permitted because the null character is one of the control characters excluded from XML, even when using a numeric character reference. An alternative encoding mechanism such as Base64 is needed to represent such characters. Comments may appear anywhere in a document outside other markup. Comments cannot appear before the XML declaration. Comments begin with <!-- and end with --> . For compatibility with SGML ,

1288-441: Is successful in that it has been widely adopted and largely achieves what it set out to, it has been the subject of a great deal of severe criticism, perhaps more so than any other W3C Recommendation. Good summaries of the criticisms are provided by James Clark, Anders Møller and Michael Schwartzbach, Rick Jelliffe and David Webber. General problems: Practical limitations of expressibility: Technical problems: XSD 1.1 became

1344-509: The Internet . It is a textual data format with strong support via Unicode for different human languages . Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structures , such as those used in web services . Several schema systems exist to aid in the definition of XML-based languages, while programmers have developed many application programming interfaces (APIs) to aid

1400-458: The Unicode repertoire. Except for a small number of specifically excluded control characters , any character defined by Unicode may appear within the content of an XML document. XML includes facilities for identifying the encoding of the Unicode characters that make up the document, and for expressing characters that, for one reason or another, cannot be used directly. Unicode code points in

1456-410: The infoset augmentation facility and attribute defaults. RELAX NG and Schematron intentionally do not provide these. A cluster of specifications closely related to XML have been developed, starting soon after the initial publication of XML 1.0. It is frequently the case that the term "XML" is used to refer to XML together with one or more of these other technologies that have come to be seen as part of

1512-602: The Java implementation from Innovimax/ INRIA , QuiXSchematron , that also do streaming . XML Schema (W3C) 1.0, Part 2 Datatypes (Recommendation) , 1.1, Part 1 Structures (Recommendation) , XSD ( XML Schema Definition ), a recommendation of the World Wide Web Consortium ( W3C ), specifies how to formally describe the elements in an Extensible Markup Language ( XML ) document. It can be used by programmers to verify each piece of item content in

1568-429: The XML core. Some other specifications conceived as part of the "XML Core" have failed to find wide adoption, including XInclude , XLink , and XPointer . The design goals of XML include, "It shall be easy to write programs which process XML documents." Despite this, the XML specification contains almost no information about how programmers might go about doing such processing. The XML Infoset specification provides

1624-506: The XML processor inserts in the DTD itself and in the XML document wherever they are referenced, like character escapes. DTD technology is still used in many applications because of its ubiquity. A newer schema language, described by the W3C as the successor of DTDs, is XML Schema , often referred to by the initialism for XML Schema instances, XSD (XML Schema Definition). XSDs are far more powerful than DTDs in describing XML languages. They use

1680-399: The ability to define element and attribute content as containing values such as integers and dates rather than arbitrary text. The XSD 1.0 specification was originally published in 2001, with a second edition following in 2004 to correct large numbers of errors. XSD 1.1 became a W3C Recommendation in April 2012 . Technically, a schema is an abstract collection of metadata, consisting of

1736-434: The allowable parent/child relationships. The oldest schema language for XML is the document type definition (DTD), inherited from SGML. DTDs have the following benefits: DTDs have the following limitations: Two peculiar features that distinguish DTDs from other schema types are the syntactic support for embedding a DTD within XML documents and for defining entities , which are arbitrary fragments of text or markup that

Schematron - Misplaced Pages Continue

1792-621: The base language for communication protocols such as SOAP and XMPP . It is one of the message exchange formats used in the Asynchronous JavaScript and XML (AJAX) programming technique. Many industry data standards, such as Health Level 7 , OpenTravel Alliance , FpML , MISMO , and National Information Exchange Model are based on XML and the rich features of the XML schema specification. In publishing, Darwin Information Typing Architecture

1848-401: The behavior of programs that process HTML , which are designed to produce a reasonable result even in the presence of severe markup errors. XML's policy in this area has been criticized as a violation of Postel's law ("Be conservative in what you send; be liberal in what you accept"). The XML specification defines a valid XML document as a well-formed XML document which also conforms to

1904-423: The case of C1 characters, this restriction is a backwards incompatibility; it was introduced to allow common encoding errors to be detected. The code point U+0000 (Null) is the only character that is not permitted in any XML 1.1 document. The Unicode character set can be encoded into bytes for storage or transmission in a variety of different ways, called "encodings". Unicode itself defines encodings that cover

1960-429: The data structure and contain metadata . What is within the tags is data, encoded in the way the XML standard specifies. An additional XML schema (XSD) defines the necessary metadata for interpreting and validating XML. (This is also referred to as the canonical schema.) An XML document that adheres to basic XML rules is "well-formed"; one that adheres to its schema is "valid." IETF RFC 7303 (which supersedes

2016-442: The direct use of almost any Unicode character in element names, attributes, comments, character data, and processing instructions (other than the ones that have special symbolic meaning in XML itself, such as the less-than sign, "<"). The following is a well-formed XML document including Chinese , Armenian and Cyrillic characters: The XML specification defines an XML document as a well-formed text, meaning that it satisfies

2072-523: The entire repertoire; well-known ones include UTF-8 (which the XML standard recommends using, without a BOM ) and UTF-16 . There are many other text encodings that predate Unicode, such as ASCII and various ISO/IEC 8859 ; their character repertoires are in every case subsets of the Unicode character set. XML allows the use of any of the Unicode-defined encodings and any other encodings whose characters also appear in Unicode. XML also provides

2128-589: The error messages themselves. The current ISO recommendation is Information technology, Document Schema Definition Languages (DSDL) , Part 3: Rule-based validation, Schematron (ISO/IEC 19757-3:2020). Constraints are specified in Schematron using an XPath-based language that can be deployed as XSLT code, making it practical for applications such as the following: Schematron was invented by Rick Jelliffe while at Academia Sinica Computing Centre, Taiwan. He described Schematron as "a feather duster to reach

2184-413: The filename extension ".xsd". A unique Internet Media Type is not yet registered for XSDs, so "application/xml" or "text/xml" should be used, as per RFC 3023. The main components of a schema are: Other more specialized components include annotations, assertions, notations, and the schema component which contains information about the schema as a whole. Simple types (also called data types) constrain

2240-1187: The following namespace: Schematron rules can be created using a standard XML editor or XForms application. The following is a sample schema: This rule checks to make sure that the ContractDate XML element has a date that is before the current date. If this rule fails the validation will fail and an error message which is the body of the assert element will be returned to the user. Schematron schemas are suitable for use in XML Pipelines , thereby allowing workflow process designers to build and maintain rules using XML manipulation tools. The W3C's XProc pipelining language, for example, has native support for Schematron schema processing through its "validate-with-schematron" step. Since Schematron schemas can be transformed into XSLT stylesheets, these can themselves be used in XML Pipelines which support XSLT transformation. An Apache Ant task can be used to convert Schematron rules into XSLT files. There exists also native Schematron implementation, like

2296-498: The following ranges are valid in XML 1.0 documents: XML 1.1 extends the set of allowed characters to include all the above, plus the remaining characters in the range U+0001–U+001F. At the same time, however, it restricts the use of C0 and C1 control characters other than U+0009 (Horizontal Tab), U+000A (Line Feed), U+000D (Carriage Return), and U+0085 (Next Line) by requiring them to be written in escaped form (for example U+0001 must be written as &#x01; or its equivalent). In

Schematron - Misplaced Pages Continue

2352-708: The functions performing the parsing, or passed down (as function parameters) into lower-level functions, or returned (as function return values) to higher-level functions. Examples of pull parsers include Data::Edit::Xml in Perl , StAX in the Java programming language, XMLPullParser in Smalltalk , XMLReader in PHP , ElementTree.iterparse in Python , SmartXML in Red , System.Xml.XmlReader in

2408-550: The older RFC 3023 ), provides rules for the construction of media types for use in XML message. It defines three media types: application/xml ( text/xml is an alias), application/xml-external-parsed-entity ( text/xml-external-parsed-entity is an alias) and application/xml-dtd . They are used for transmitting raw XML files without exposing their internal semantics . RFC 7303 further recommends that XML-based languages be given media types ending in +xml , for example, image/svg+xml for SVG . Further guidelines for

2464-639: The parts other schema languages cannot reach". The most common versions of Schematron are: Schematron has been standardized by the ISO as Information technology, Document Schema Definition Languages (DSDL) , Part 3: Rule-based validation, Schematron (ISO/IEC 19757-3:2020). This standard is currently not listed on the ISO Publicly Available Specifications list. Paper versions may be purchased from ISO or national standards bodies. Schemas that use ISO/IEC FDIS 19757-3 should use

2520-451: The permitted content of an element, including its element and text children and its attributes. A complex type definition consists of a set of attribute uses and a content model. Varieties of content model include: A complex type can be derived from another complex type by restriction (disallowing some elements, attributes, or values that the base type permits) or by extension (allowing additional attributes and elements to appear). In XSD 1.1,

2576-449: The processing of XML data. The main purpose of XML is serialization , i.e. storing, transmitting, and reconstructing arbitrary data. For two disparate systems to exchange information, they need to agree upon a file format. XML standardizes this process. It is therefore analogous to a lingua franca for representing information. As a markup language , XML labels, categorizes, and structurally organizes information. XML tags represent

2632-469: The programming environment. The schema can be used to generate human-readable documentation of an XML file structure; this is especially useful where the authors have made use of the annotation elements. No formal standard exists for documentation generation, but a number of tools are available, such as the Xs3p stylesheet, that will produce high-quality readable HTML and printed material. Although XML Schema

2688-487: The rules of a Document Type Definition (DTD). In addition to being well formed, an XML document may be valid . This means that it contains a reference to a Document Type Definition (DTD), and that its elements and attributes are declared in that DTD and follow the grammatical rules for them that the DTD specifies. XML processors are classified as validating or non-validating depending on whether or not they check XML documents for validity. A processor that discovers

2744-470: The specification itself, and further derived types can be defined by users in their own schemas. The mechanisms available for restricting data types include the ability to specify minimum and maximum values, regular expressions, constraints on the length of strings, and constraints on the number of digits in decimal values. XSD 1.1 again adds assertions, the ability to specify an arbitrary constraint by means of an XPath 2.0 expression. Complex types describe

2800-469: The string "--" (double-hyphen) is not allowed inside comments; this means comments cannot be nested. The ampersand has no special significance within comments, so entity and character references are not recognized as such, and there is no way to represent characters outside the character set of the document encoding. An example of a valid comment: <!--no need to escape <code> & such in comments--> XML 1.0 (Fifth Edition) and XML 1.1 support

2856-668: The textual values that may appear in an element or attribute. This is one of the more significant ways in which XML Schema differs from DTDs. For example, an attribute might be constrained to hold only a valid date or a decimal number. XSD provides a set of 19 primitive data types ( anyURI , base64Binary , boolean , date , dateTime , decimal , double , duration , float , hexBinary , gDay , gMonth , gMonthDay , gYear , gYearMonth , NOTATION , QName , string , and time ). It allows new data types to be constructed from these primitives by three mechanisms: Twenty-five derived types are defined within

SECTION 50

#1732790469321

2912-530: The use of XML in a networked context appear in RFC 3470 , also known as IETF BCP 70, a document covering many aspects of designing and deploying an XML-based language. XML has come into common use for the interchange of data over the Internet. Hundreds of document formats using XML syntax have been developed, including RSS , Atom , Office Open XML , OpenDocument , SVG , COLLADA , and XHTML . XML also provides

2968-472: The use of much more memory, but are often found more convenient for use by programmers; some include declarative retrieval of document components via the use of XPath expressions. XSLT is designed for declarative description of XML document transformations, and has been widely implemented both in server-side packages and Web browsers. XQuery overlaps XSLT in its functionality, but is designed more for searching of large XML databases . Simple API for XML (SAX)

3024-510: The user community referred to this language as WXS , an initialism for W3C XML Schema, while others referred to it as XSD , an initialism for XML Schema Definition. In Version 1.1 the W3C has chosen to adopt XSD as the preferred name, and that is the name used in this article. In its appendix of references, the XSD specification acknowledges the influence of DTDs and other early XML schema efforts such as DDML , SOX , XML-Data, and XDR . It has adopted features from each of these proposals but

3080-469: The validation engine, or it can be referenced directly from the instance document using two special attributes, xsi:schemaLocation and xsi:noNamespaceSchemaLocation . (The latter mechanism requires the client invoking validation to trust the document sufficiently to know that it is being validated against the correct schema. "xsi" is the conventional prefix for the namespace " http://www.w3.org/2001/XMLSchema-instance ".) XML Schema Documents usually have

3136-426: The vendor support of XML Schemas yet, and are to some extent a grassroots reaction of industrial publishers to the lack of utility of XML Schemas for publishing . Some schema languages not only describe the structure of a particular XML format but also offer limited facilities to influence processing of individual XML files that conform to this format. DTDs and XSDs both have this ability; they can for instance provide

#320679