Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xerces Wiki" for change 
notification.

The "XML_Schema_1.1_Assertions" page has been changed by Mukul Gandhi:
http://wiki.apache.org/xerces/XML_Schema_1.1_Assertions?action=diff&rev1=111&rev2=112

Comment:
making updates to the text

  ## page was renamed from assertions
- This page describes implementation details of 
[[http://www.w3.org/XML/Schema|XML Schema (XSD)]] 1.1 assertions feature, in 
[[http://xerces.apache.org/xerces2-j/|Xerces-J]] XML Schema processor. 
+ This page describes implementation details of 
[[http://www.w3.org/XML/Schema|XML Schema (XSD)]] 1.1 assertions feature, in 
[[http://xerces.apache.org/xerces2-j/|Xerces-J]] XML Schema processor.
  
  ''Assertions'' is a new XML validation facility introduced in XSD 1.1 
language. XSD 1.1 assertions allow us to constrain XML elements and attributes 
in useful ways, which results in a more effective XSD language. XSD Assertions 
are officially described here, in the W3C spec, 
http://www.w3.org/TR/xmlschema11-1/#cAssertions & 
http://www.w3.org/TR/xmlschema11-2/#rf-assertions. For an explanation of 
assertions feature and to know number of practical examples, please read the 
article [2] in "References" section below.
  
- '''Status of assertions development, in Xerces-J:'''<<BR>>
- The assertions implementation in Xerces-J is complete, and Xerces team has 
checked in the code for this, at the SVN repository 
(https://svn.apache.org/repos/asf/xerces/java/branches/xml-schema-1.1-dev/).
+ '''Status of assertions development, in Xerces-J:'''<<BR>> The assertions 
implementation in Xerces-J is complete and Xerces team has checked in the code 
for this, at the SVN repository 
(https://svn.apache.org/repos/asf/xerces/java/branches/xml-schema-1.1-dev/).
  
- The only assertions feature which still needs to be implemented and tested 
is, the '''id''' attribute on '''xs:assert''' and '''xs:assertion''' 
instructions. The work for this is underway.
- 
- The user feedback would be helpful at this point. 
+ The user feedback would be helpful at this point.
  
  '''XSD 1.1 assertions grammar notes (as defined in XSD 1.1 spec)'''
  
  ''Assertions usage in Complex Types'':
  
-  ''1. Complex Type Definition Schema Components''
+  . ''1. Complex Type Definition Schema Components'' <complexType
+   . abstract = boolean : false block = (#all | List of (extension | 
restriction)) final = (#all | List of (extension | restriction)) id = ID mixed 
= boolean name = NCName defaultAttributesApply = boolean : true
- 
-  <complexType
-   abstract = boolean : false
-   block = (#all | List of (extension | restriction))
-   final = (#all | List of (extension | restriction))
-   id = ID
-   mixed = boolean
-   name = NCName
-   defaultAttributesApply = boolean : true
-   {any attributes with non-schema namespace . . .}>
-   Content: (annotation?, (simpleContent | complexContent | (openContent?, 
(group | all | choice | sequence)?, ((attribute | attributeGroup)*, 
anyAttribute?), '''assert'''*)))
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(simpleContent | complexContent | (openContent?, (group | all | choice | 
sequence)?, ((attribute | attributeGroup)*, anyAttribute?), '''assert'''*)))
+  </complexType> ''2. Complex Types with Simple Content'' <simpleContent
-  </complexType>
- 
-  ''2. Complex Types with Simple Content''
- 
-  <simpleContent
-    id = ID
+   . id = ID
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(restriction | extension))
+  </simpleContent> <restriction
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, (restriction | extension))
-  </simpleContent>
- 
-  <restriction
-    base = QName
+   . base = QName id = ID
-    id = ID
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, (simpleType?, (minExclusive | minInclusive | 
maxExclusive |  maxInclusive | totalDigits | fractionDigits | maxScale | 
minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern 
| '''assertion''' | {any with namespace: ##other})*)?, ((attribute | 
attributeGroup)*, anyAttribute?), '''assert'''*)
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(simpleType?, (minExclusive | minInclusive | maxExclusive |  maxInclusive | 
totalDigits | fractionDigits | maxScale | minScale | length | minLength | 
maxLength | enumeration | whiteSpace | pattern | '''assertion''' | {any with 
namespace: ##other})*)?, ((attribute | attributeGroup)*, anyAttribute?), 
'''assert'''*)
+  </restriction> <extension
-  </restriction>
- 
-  <extension
-    base = QName
+   . base = QName id = ID
-    id = ID
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?), 
'''assert'''*)
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
((attribute | attributeGroup)*, anyAttribute?), '''assert'''*)
+  </extension> ''3. Complex Types with Complex Content'' <complexContent
+   . id = ID mixed = boolean
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(restriction | extension))
+  </complexContent> <restriction
+   . base = QName id = ID
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
openContent?, (group | all | choice | sequence)?, ((attribute |  
attributeGroup)*, anyAttribute?), '''assert'''*)
+  </restriction> <extension
+   . base = QName id = ID
+   {any attributes with non-schema namespace . . .}> Content: (annotation?, 
openContent?, ((group | all | choice | sequence)?, ((attribute |  
attributeGroup)*, anyAttribute?), '''assert'''*))
   </extension>
- 
-  ''3. Complex Types with Complex Content''
- 
-  <complexContent
-    id = ID
-    mixed = boolean
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, (restriction | extension))
-  </complexContent>
- 
-  <restriction
-    base = QName
-    id = ID
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, openContent?, (group | all | choice | sequence)?, 
((attribute |  attributeGroup)*, anyAttribute?), '''assert'''*)
-  </restriction>
- 
-  <extension
-    base = QName
-    id = ID
-    {any attributes with non-schema namespace . . .}>
-    Content: (annotation?, openContent?, ((group | all | choice | sequence)?, 
((attribute |  attributeGroup)*, anyAttribute?), '''assert'''*))
-  </extension>
- 
  
  ''Assertions usage in Simple Types'':
  
  <simpleType
+ 
-   final = (#all | List of (list | union | restriction | extension)) 
+  . final = (#all | List of (list | union | restriction | extension))  id = ID 
name = NCName
+  {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(restriction | list | union))
+ 
-   id = ID
-   name = NCName
-   {any attributes with non-schema namespace . . .}>
-   Content: (annotation?, (restriction | list | union))
  </simpleType>
  
  <restriction
+ 
-   base = QName
+  . base = QName id = ID
-   id = ID
-   {any attributes with non-schema namespace . . .}>
-   Content: (annotation?, (simpleType?, (minExclusive | minInclusive | 
maxExclusive | maxInclusive | totalDigits | fractionDigits | maxScale | 
minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern 
| '''assertion''' | {any with namespace: ##other})*))
+  {any attributes with non-schema namespace . . .}> Content: (annotation?, 
(simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | 
totalDigits | fractionDigits | maxScale | minScale | length | minLength | 
maxLength | enumeration | whiteSpace | pattern | '''assertion''' | {any with 
namespace: ##other})*))
+ 
  </restriction>
- 
  
  '''Assertions design approach, within Xerces-J'''
  
@@ -102, +60 @@

  
  To implement assertions for Complex types, the Complex type traverser of 
Xerces is modified.
  
- 
  '''Assertions XPath 2.0 processing implementation'''
  
  Xerces provides a Java interface API, for integrating Xerces with XPath 2.0 
evaluation engines. It should be possible to plug in any compliant XPath 2.0 
engine to the Xerces assertions processor, by writing a small Java layer 
complying to this interface.
  
- Xerces provides a sample implementation of this interface for 
[[http://www.eclipse.org/webtools/|Eclipse XPath2/PsychoPath]] XPath 2.0 
engine. This should be very good enough, for open source Xerces-J product. 
+ Xerces provides a sample implementation of this interface for 
[[http://www.eclipse.org/webtools/|Eclipse XPath2/PsychoPath]] XPath 2.0 
engine. This should be very good enough, for open source Xerces-J product.
  
  We have tried our best, to write an efficient implementation of XPath 2.0 
integration for assertions. For nested elements having assertions, the 
child/descendant elements share the XPath (XDM) tree with the top most element. 
For each distinct XDM tree involved in assertions processing, we keep a 
reference of it's root node, and discard these references when assertions 
evaluation is complete for that tree.
  
+ A caution for Schema authors: If we are specifying assertions for the root 
element of the XML document, a tree will be built for assertions processing, 
which could be as large as the XML document. Where memory is a concern for 
large XML documents, assertions may be specified at an inner level [1] of the 
XML documents, as far as possible. This [1] will cause smaller assertion trees 
to be built, thereby reducing memory footprint of the XML application. It is 
also worth knowing, that assertions trees are generally smaller than 
corresponding generic XML infoset trees, because assertions trees only contain 
element and attribute information, along with certain XML Schema type 
annotations, whereas generic XML trees contain other information like 
processing instructions, comments and so on.
- A caution for Schema authors: If we are specifying assertions for the root 
element of the XML document, a tree will be built for assertions processing, 
which could be as large as the XML document. Where memory is a concern for 
large XML documents, assertions may be specified at an inner level [1] of the 
XML documents, as far as possible. This [1] will cause smaller assertion trees 
to be built, thereby reducing memory footprint of the XML application.
- It is also worth knowing, that assertions trees are generally smaller than 
corresponding generic XML infoset trees, because assertions trees only contain 
element and attribute information, along with certain XML Schema type 
annotations, whereas generic XML trees contain other information like 
processing instructions, comments and so on.
- 
  
  '''Run-time notes'''
  
-  1. By default, the Xerces-J Schema processor would select the 
Eclipse/PsychoPath engine for XPath 2.0 processing. Xerces-J has a provision 
for the user, to select between different XPath 2.0 engines for evaluating 
assertions. This can be done by setting the Java system property, 
'''org.apache.xerces.assertProcessor'''. Xerces-J has an out of the box support 
for PsychoPath XPath 2.0 engine. If the user doesn't set this property, or set 
it's value to, '''org.apache.xerces.impl.xs.XMLAssertPsychopathImpl''', the 
PsychoPath processor would be selected for XPath 2.0 processing. 
+  1. By default, the Xerces-J Schema processor would select the 
Eclipse/PsychoPath engine for XPath 2.0 processing. Xerces-J has a provision 
for the user, to select between different XPath 2.0 engines for evaluating 
assertions. This can be done by setting the Java system property, 
'''org.apache.xerces.assertProcessor'''. Xerces-J has an out of the box support 
for PsychoPath XPath 2.0 engine. If the user doesn't set this property, or set 
it's value to, '''org.apache.xerces.impl.xs.XMLAssertPsychopathImpl''', the 
PsychoPath processor would be selected for XPath 2.0 processing.
  
   1. If user's wish to use an XPath 2.0 engine other than PsychoPath, for 
working with Xerces-J assertions, they need to write a custom Java layer 
similar to org.apache.xerces.impl.xs.XMLAssertPsychopathImpl, and integrate it 
with their own XPath 2.0 engine, using the XPath 2.0 engine's APIs. Xerces-J 
would publish an API, to integrate to any available standard compliant XPath 
2.0 engines.
  
   1. Error codes, and descriptions:
  
  Xerces-J flags error messages during assertions processing, as recommended by 
the XML Schema 1.1 specification. Here's the summary of error codes/messages, 
used by Xerces during assertion processing:
+ 
   a. '''cvc-assertion.3.13.4.1''' -> Xerces uses this error code, with a 
description like following "test.xml:3:11:cvc-assertion.3.13.4.1: Assertion 
evaluation (x = 'hello world') for element 'Example' with type '#anonymous' did 
not succeed.", when any of the assertions evaluate to false.
   a. '''cvc-assertion.3.13.4.1''' -> Here's an example of error description, 
when an assertion facet on a attribute value, evaluates to false: 
"test.xml:2:18:cvc-assertion.3.13.4.1: Assertion evaluation ('$value eq 2') for 
element 'x (attribute => a)' with type '#anonymous' did not succeed.".
   a. '''cvc-assertion.4.3.15.3''' -> This error code is used, with a 
description like following "test.xml:2:15:cvc-assertion.4.3.15.3: Assertion 
evaluation (. = 'hello') for element 'x' with type '#anonymous' did not succeed 
(undefined context).", when an attempt is made to access the XPath context (for 
e.g, with the expression "."), during assertion facet evaluation.
@@ -138, +94 @@

  
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  
-  <xs:element name="test">
+  . <xs:element name="test">
-   <xs:simpleType>
+   . <xs:simpleType>
-    <xs:restriction base="xs:positiveInteger" 
xmlns:xerces="http://xerces.apache.org";>
+    . <xs:restriction base="xs:positiveInteger" 
xmlns:xerces="http://xerces.apache.org";>
-     <xs:assertion test="$value mod 2 = 0" xerces:message="Value of element 
'test' must be divisible by 2" />
+     . <xs:assertion test="$value mod 2 = 0" xerces:message="Value of element 
'test' must be divisible by 2" />
     </xs:restriction>
    </xs:simpleType>
   </xs:element>
-   
+ 
  </xs:schema>
  
  When the above XML document [3], is validated with the corresponding schema 
document [4], following error message is displayed:
@@ -153, +109 @@

  "test.xml:1:15: cvc-assertion.failure: Assertion failure. Value of element 
'test' must be divisible by 2."
  
  Notes:
-  1. The user-defined error messages on assertions, needs to be specified as a 
value, of attribute "message" (which needs to be in the XML namespace, 
"http://xerces.apache.org";) on xs:assert/xs:assertion instruction.
-  1. The mechanism of specifying user-defined error messages on XSD 1.1 
assertions in Xerces-J, may change in future, if XSD WG suggests a specific 
guidance in the final XSD 1.1 language recommendation, regarding this.
  
+  1. The user-defined error messages on assertions needs to be specified as a 
value, of attribute "message" (which needs to be in the XML namespace, 
"http://xerces.apache.org";) on xs:assert/xs:assertion instruction.
+  1. The mechanism of specifying user-defined error messages on XSD 1.1 
assertions in Xerces-J may change in future, if XSD WG suggests a specific 
guidance in the final XSD 1.1 language recommendation, regarding this.
  
  '''References:'''
  
   1. [[http://www.ibm.com/developerworks/xml/library/x-xml11pt1/|An 
introduction to XML Schema 1.1, An overview of the key improvements over XML 
Schema 1.0 and an in-depth look at datatypes]]
   1. [[http://www.ibm.com/developerworks/library/x-xml11pt2/|An introduction 
to XML Schema 1.1, Co-occurence constraints using XPath 2.0]]
  
- 
  ----
- 
  Mukul Gandhi
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to