sandygao 2002/10/25 09:57:15 Modified: java/samples/xni PSVIWriter.java Log: 1. Schema assessment doesn't augment the infoset for character information items, so our PSVIWriter sample doesn't need to output information abou characters. 2. All PSVI properties for elements are available on endElement calls, so we choose to output them all together. 3. When "validation attempted" is none, no other property is meaningful, so we don't need to output any other properties than "validation context", "validity" and "validation attempted". This also fixes bug [13276], because we won't try to access the "type definition" property when it's null. Revision Changes Path 1.13 +52 -68 xml-xerces/java/samples/xni/PSVIWriter.java Index: PSVIWriter.java =================================================================== RCS file: /home/cvs/xml-xerces/java/samples/xni/PSVIWriter.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- PSVIWriter.java 24 Sep 2002 23:07:52 -0000 1.12 +++ PSVIWriter.java 25 Oct 2002 16:57:15 -0000 1.13 @@ -125,6 +125,9 @@ protected static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY; + /** Feature id: augment Post-Schema-Validation-Infoset */ + protected static final String PSVINFOSET = + Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI; /** Feature id: include ignorable whitespace. */ protected static final String INCLUDE_IGNORABLE_WHITESPACE = @@ -139,14 +142,14 @@ private static final String[] RECOGNIZED_FEATURES = { NAMESPACE_BINDER, INCLUDE_IGNORABLE_WHITESPACE, - // PSVINFOSET, + PSVINFOSET, }; /** Feature defaults. */ private static final Boolean[] FEATURE_DEFAULTS = { Boolean.TRUE, // ??? Boolean.TRUE, // ??? - // ??? + null, }; /** Recognized properties. */ @@ -221,15 +224,12 @@ public void reset(XMLComponentManager componentManager) throws XNIException { - // Feature's name for PSVIWriter is not yet decided. -/* try { + try { fPSVInfoset = componentManager.getFeature(PSVINFOSET); } catch (XMLConfigurationException e) { fPSVInfoset = false; - }*/ - /**For Testing */ - fPSVInfoset = true; + } fNamespaceBinder = (XMLNamespaceBinder)componentManager.getProperty(NAMESPACE_BINDER); fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE); @@ -654,24 +654,6 @@ */ public void characters(XMLString text, Augmentations augs) throws XNIException { - // REVISIT: 2.6. Character Information Items requires character property for - // each character. However, it also says: - // "Each character is a logically separate information item, - // but XML applications are free to chunk characters into larger - // groups as necessary or desirable" - // XSV outputs each character separately. - ElementPSVI elemPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI); - - checkForChildren(); - if (elemPSVI != null) { - if (!elemPSVI.getIsSchemaSpecified()){ // value was specified in the instance! - printIndentTag("<character>"); - printElement("characterCode", text.toString()); - printElement("elementContentWhitespace", "false"); - printUnIndentTag("</character>"); - } - } - if (fDocumentHandler != null) { fDocumentHandler.characters(text,augs); } @@ -842,32 +824,6 @@ if (elemPSVI != null) { // REVISIT: Should we store the values till end element call? - printElement("psv:validationContext",elemPSVI.getValidationContext()); - - XSTypeDefinition type = elemPSVI.getTypeDefinition(); - short definationType = type.getTypeCategory(); - if (definationType == XSTypeDecl.SIMPLE_TYPE) { - printElement("psv:typeDefinitionType","simple"); - } - else if (definationType == XSTypeDecl.COMPLEX_TYPE) { - printElement("psv:typeDefinitionType","complex"); - } - printElement("psv:typeDefinitionNamespace ",type.getNamespace()); - printElement("psv:typeDefinitionAnonymous",String.valueOf(type.getIsAnonymous())); - printElement("psv:typeDefinitionName",type.getName()); - - XSSimpleTypeDefinition memtype = elemPSVI.getMemberTypeDefinition(); - if (memtype != null) { - printElement("psv:memberTypeDefinitionAnonymous",String.valueOf(memtype.getIsAnonymous())); - printElement("psv:memberTypeDefinitionName",memtype.getName()); - printElement("psv:memberTypeDefinitionNamespace",memtype.getNamespace()); - } - - XSNotationDeclaration notation = elemPSVI.getNotation(); - if (notation != null) { - printElement("psv:notationSystem",notation.getSystemId()); - printElement("psv:notationPublic",notation.getPublicId()); - } } } @@ -882,10 +838,23 @@ ElementPSVI elemPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI); if (elemPSVI != null) { + printElement("psv:validationContext",elemPSVI.getValidationContext()); + + short validity = elemPSVI.getValidity(); + if (validity == ItemPSVI.VALIDITY_UNKNOWN) { + printElement("psv:validity","unknown"); + } + else if (validity == ItemPSVI.VALIDITY_VALID) { + printElement("psv:validity","valid"); + } + else if (validity == ItemPSVI.VALIDITY_INVALID) { + printElement("psv:validity","invalid"); + } short validation = elemPSVI.getValidationAttempted(); if (validation == ItemPSVI.VALIDATION_NONE) { printElement("psv:validationAttempted","none"); + return; } else if (validation == ItemPSVI.VALIDATION_PARTIAL) { printElement("psv:validationAttempted","partial"); @@ -894,17 +863,31 @@ printElement("psv:validationAttempted","full"); } - - short validity = elemPSVI.getValidity(); - if (validity == ItemPSVI.VALIDITY_UNKNOWN) { - printElement("psv:validity","unknown"); + XSTypeDefinition type = elemPSVI.getTypeDefinition(); + short definationType = type.getTypeCategory(); + if (definationType == XSTypeDecl.SIMPLE_TYPE) { + printElement("psv:typeDefinitionType","simple"); } - else if (validity == ItemPSVI.VALIDITY_VALID) { - printElement("psv:validity","valid"); + else if (definationType == XSTypeDecl.COMPLEX_TYPE) { + printElement("psv:typeDefinitionType","complex"); } - else if (validity == ItemPSVI.VALIDITY_INVALID) { - printElement("psv:validity","invalid"); + printElement("psv:typeDefinitionNamespace ",type.getNamespace()); + printElement("psv:typeDefinitionAnonymous",String.valueOf(type.getIsAnonymous())); + printElement("psv:typeDefinitionName",type.getName()); + + XSSimpleTypeDefinition memtype = elemPSVI.getMemberTypeDefinition(); + if (memtype != null) { + printElement("psv:memberTypeDefinitionAnonymous",String.valueOf(memtype.getIsAnonymous())); + printElement("psv:memberTypeDefinitionName",memtype.getName()); + printElement("psv:memberTypeDefinitionNamespace",memtype.getNamespace()); } + + XSNotationDeclaration notation = elemPSVI.getNotation(); + if (notation != null) { + printElement("psv:notationSystem",notation.getSystemId()); + printElement("psv:notationPublic",notation.getPublicId()); + } + //revisit StringList errorCode = elemPSVI.getErrorCodes(); if (errorCode != null) { @@ -929,14 +912,6 @@ AttributePSVI attrPSVI =(AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI); if (attrPSVI !=null) { - short validation = attrPSVI.getValidationAttempted(); - if (validation == ItemPSVI.VALIDATION_NONE) { - printElement("psv:validationAttempted","none"); - } - else if (validation == ItemPSVI.VALIDATION_FULL) { - printElement("psv:validationAttempted","full"); - } - printElement("psv:validationContext",attrPSVI.getValidationContext()); short validity = attrPSVI.getValidity(); @@ -948,6 +923,15 @@ } else if (validity == ItemPSVI.VALIDITY_INVALID) { printElement("psv:validity","invalid"); + } + + short validation = attrPSVI.getValidationAttempted(); + if (validation == ItemPSVI.VALIDATION_NONE) { + printElement("psv:validationAttempted","none"); + return; + } + else if (validation == ItemPSVI.VALIDATION_FULL) { + printElement("psv:validationAttempted","full"); } StringList errorCode = attrPSVI.getErrorCodes();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]