You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by je...@locus.apache.org on 2000/10/31 19:41:48 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes IDDatatypeValidator.java StringDatatypeValidator.java
jeffreyr 00/10/31 10:41:47
Modified: java/src/org/apache/xerces/impl/validation/datatypes Tag:
xerces_j_2 IDDatatypeValidator.java
StringDatatypeValidator.java
Log:
IDDatatypeValidator.java
Revision Changes Path
No revision
No revision
1.1.2.4 +79 -7 xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/IDDatatypeValidator.java
Index: IDDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/IDDatatypeValidator.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- IDDatatypeValidator.java 2000/10/27 01:14:24 1.1.2.3
+++ IDDatatypeValidator.java 2000/10/31 18:41:45 1.1.2.4
@@ -70,14 +70,65 @@
import java.util.NoSuchElementException;
-//import org.apache.xerces.utils.XMLMessages;
-
/**
- * DataTypeValidator defines the interface that data type validators must obey.
- * These validators can be supplied by the application writer and may be useful as
- * standalone code as well as plugins to the validator architecture.
+ * <P>IDDatatypeValidator - ID represents the ID attribute
+ * type from XML 1.0 Recommendation. The value space
+ * od ID is the set of all strings that match the
+ * NCName production and have been used in an XML
+ * document. The lexical space of ID is the set of all
+ * strings that match the NCName production.</P>
+ * <P>The value space of ID is scoped to a specific
+ * instance document.</P>
+ * <P>The following constraint applies:
+ * An ID must not appear more than once in an XML
+ * document as a value of this type; i.e., ID values
+ * must uniquely identify the elements which bear
+ * them.</P>
+ * <P>An ID validator is a statefull validator, it needs
+ * read/write access to the associated instant document
+ * table of IDs.</P>
+ * <P>
+ * The following snippet shows typical use of the
+ * the IDDatatype:</P>
+ * <CODE>
+ * <PRE>
+ * DatatypeValidator idData = tstRegistry.getDatatypeValidator( "ID" );
+ *
+ * if ( idData != null ) {
+ * ((IDDatatypeValidator) idData).initialize();
+ * try {
+ * idData.validate( "a1", null );
+ * idData.validate( "a2", null );
+ * } catch ( Exception ex ) {
+ * ex.printStackTrace();
+ * }
+ * Hashtable tst = (Hashtable)((IDDatatypeValidator) idData).getTableIds();
+ * if (tst != null) {
+ * System.out.println("Table of ID = " + tst.toString());
+ * }
+ *
+ * }
+ *
+ * DatatypeValidator idRefData = tstRegistry.getDatatypeValidator("IDREF" );
+ * if( idRefData != null ){
+ * IDREFDatatypeValidator refData = (IDREFDatatypeValidator) idRefData;
+ * refData.initialize( ((IDDatatypeValidator) idData).getTableIds());
+ * try {
+ * refData.validate( "a1", null );
+ * refData.validate( "a2", null );
+ * //refData.validate( "a3", null );//Should throw exception at validate()
+ * refData.validate();
+ * } catch( Exception ex ){
+ * ex.printStackTrace();
+ * }
+ * }
+ * </PRE>
+ * </CODE>
+ *
* @author Jeffrey Rodriguez
- * @version $Id: IDDatatypeValidator.java,v 1.1.2.3 2000/10/27 01:14:24 jeffreyr Exp $
+ * @version $Id: IDDatatypeValidator.java,v 1.1.2.4 2000/10/31 18:41:45 jeffreyr Exp $
+ * @see org.apache.xerces.impl.validation.datatypes.AbstractDatatypeValidator
+ * @see org.apache.xerces.impl.validation.DatatypeValidator
*/
public class IDDatatypeValidator extends AbstractDatatypeValidator {
private DatatypeValidator fBaseValidator;
@@ -126,6 +177,12 @@
}
}
+ /**
+ * Initializes internal table of IDs used
+ * by ID datatype validator to keep track
+ * of ID's.
+ * This method is unique to IDDatatypeValidator.
+ */
public void initialize(){
if ( this.fTableOfId != null) {
this.fTableOfId.clear();
@@ -157,6 +214,14 @@
throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
}
+ /**
+ * This method is unique to IDDatatypeValidator.
+ * It returns a reference to the internal ID table.
+ * This method should be used by the IDREF datatype
+ * validator which needs read access to ID table.
+ *
+ * @return
+ */
public Object getTableIds(){
return fTableOfId;
}
@@ -173,7 +238,14 @@
fBaseValidator = base;
}
- /** addId. */
+ /**
+ * Adds validated ID to internal table of ID's.
+ * We check ID uniqueness constraint.
+ *
+ * @param content
+ * @return If ID validated is not unique we return a false and
+ * then validate method throws a validation exception.
+ */
private boolean addId(String content) {
//System.out.println("Added ID = " + content );
if ( fTableOfId == null ) {
1.1.2.5 +2 -2 xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/StringDatatypeValidator.java
Index: StringDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/datatypes/Attic/StringDatatypeValidator.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- StringDatatypeValidator.java 2000/10/17 02:01:05 1.1.2.4
+++ StringDatatypeValidator.java 2000/10/31 18:41:46 1.1.2.5
@@ -1,4 +1,4 @@
-/*
+/* :q
* The Apache Software License, Version 1.1
*
*
@@ -74,7 +74,7 @@
/**
* StringValidator validates that XML content is a W3C string type.
- * @version $Id: StringDatatypeValidator.java,v 1.1.2.4 2000/10/17 02:01:05 jeffreyr Exp $
+ * @version $Id: StringDatatypeValidator.java,v 1.1.2.5 2000/10/31 18:41:46 jeffreyr Exp $
*/
public class StringDatatypeValidator extends AbstractDatatypeValidator{
private Locale fLocale = null;