[Mike Skells] Now with the code attached [Mike Skells]
Hi, I have been working on a small contribution that supports the Post Schema Validation Infoset in dom4j I am happy to contribute this code, I have tested it with Apache Xerces 2.6.2 only, but I would appreciate some discussion :- about the best way to package this support? should it be part of the DOM4j behaviors? (SAXReader, BaseElement) The changes are are simple, but a little cludgy, as I could see a way of doing what I needed within the existing io features. Outstanding issues How to specify the PSVI provider in a transparent manner, the demo forces JAXP, and makes some assumptions that may not hold true for SAX implementations other than apache. Should there be a PSVIProvider property for instance, Should the SAXReader provide a capturePSVI boolean property, or should the we use inheritance, as the demo uses Where should be a neater way to perform the interception of the element and attribute creation to allow for the PSVI details to be detailed. I initially tried to use the dispatch handler, but this is package level class, as is ElementStack etc, hence the packaging in dom4j.io How to set the features that are required. Xerces has a number of features that can be set. I don't know if there are standard features, and the appropriate sets of options that will support other implementations Test against other implementations (are there any?) The demo requires the a.xml and a.xsd file to be in top of the C drive. (Any non windows users will have to modifythe code in the Text.java) There is a demo file Test.java, which can be executed, and prints out the content of the annotation in the xsd, accessed via PSVI I would appreciate any comments Mike
Test.java
Description: Binary data
SchemaAwareSAXReader.java
Description: Binary data
SchemaAwareSAXContentHandler.java
Description: Binary data
SchemaAwareElement.java
Description: Binary data
SchemaAware.java
Description: Binary data
SchemaAwareAttribute.java
Description: Binary data
DefaultSchemaElement.java
Description: Binary data
DefaultSchemaAttribute.java
Description: Binary data
DefaultSchemaDocumentFactory.java
Description: Binary data
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!--W3C Schema generated by XMLSpy v2005 sp2 U (http://www.altova.com)--> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="x"> <xs:annotation> <xs:appinfo> <hello/> this is an annotation</xs:appinfo> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="contentElement-X" form="unqualified"/> </xs:sequence> <xs:attribute name="optional-attribute-1" type="xs:boolean" default="true"/> <xs:attribute name="optional-attribute-2" type="xs:string" default="help"/> </xs:complexType> </xs:element> <xs:element name="y"> <xs:complexType> <xs:attribute name="fred" use="required"> <xs:simpleType> <xs:restriction base="xs:byte"> <xs:enumeration value="22"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> </xs:schema>
<?xml version="1.0" encoding="UTF-8"?> <x xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///a.xsd"> <contentElement-X/> </x>