Hi Pavani,
Thanks for the patch. I decided to use only the "new" version of
checkContent--no reason keeping the old one around. I also included an
XSDocumentInfo as a parameter to save the trouble of looking that up (and
also the fact that XSDAbstractTraverser knows nothing about Documents right
now).
Thanks for your help!
Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone: 905-413-3519, T/L 969-3519
E-mail: [EMAIL PROTECTED]
Pavani Mukthipudi <[EMAIL PROTECTED]> on 10/01/2001 12:13:33 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: Re: code for checkContent() of XSDAbstractTraverser
Hi Neil,
> But the problem with multiple ID
> attributes being invalidly detected still will arise, except on the
parent
> element; this problem will arise inevitably if
> XSAttributeChecker.checkAttributes is called more than once on any
element
> (as it is here since whoever's traversing the parent must have called
this
> method on the parent).
>
Yes, you are right.
> From 3.13.2 of the structures spec, describing the schema component
> properties derived from the XML representation:
>
> {attributes}
> A sequence of attribute information items, namely those allowed by the
> attribute wildcard in the type definition for the
> <annotation>
> item itself or for the enclosing items which correspond to the component
> within which the annotation component is located.
>
Thanks for the explanation.
> For this reason I think we need to add a parameter for the caller to pass
> in their attributes. Once traverseAnnotation actually returns something
we
> can add yet one more parameter to pass that back to the caller so that
most
> (if perhaps not all) of the traversers can still use this method. This
> will require some modifications to the traversers, but since multiple
calls
> to checkAttributes(...) is a non-starter this seems to be the only
> solution.
>
Yes, adding a parameter to pass the attributes is the only solution i can
think of at this point.
I have added the new parameter and commented the code for now.
>
> Well, actually... I was thinking of the reportSchemaError method in the
> XSDAbstractTraverser class. The reason for using this instead of
> reportGenericSchemaError is that we can put the textual part of error
> messages into a properties file which will make internationalization
> infinitely easier if we ever need to go down that road. Also, the PSVI
> requires that identifiers be attached to assessment outcomes; this Sandy
> also built right into the error infrastructure. You can see how he did
> this by looking in XSElementDecl.
I think the error checks should be taken care of by the traverser
bec' the 'key' we pass to reportSchemaError() is specific to the
'parent' element in whose context this method is called. Also, i have
found that the traversers which are using this method are making the
checks. If this is the case, then 'isEmpty' parameter is not required.
Please find the attached diff for XSDAbstractTraverser with the
above changes.
Regards,
Pavani
--
Pavani Mukthipudi
Sun Microsystems Inc.
Phone: 080 - 2298989 Extn: 87390
Index: XSDAbstractTraverser.java
===================================================================
RCS file:
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDAbstractTraverser.java,v
retrieving revision 1.20
diff -u -r1.20 XSDAbstractTraverser.java
--- XSDAbstractTraverser.java 2001/09/25 22:46:07 1.20
+++ XSDAbstractTraverser.java 2001/10/01 16:04:01
@@ -232,14 +232,65 @@
// false if must have some element (with possible
preceding <annotation?>)
//
- //REVISIT: Implement
//REVISIT: if we want to expose annotation information to the
application,
// then we should never call this method. different traversers
// should call traverseAnnotationDecl() directly, and store
the
// returned value.
Element checkContent( Element elm, Element content, boolean isEmpty )
{
+
+ if (content == null) {
+ return content;
+ }
+
+ if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ Document doc = DOMUtil.getDocument(content);
+ XSDocumentInfo docInfo =
fSchemaHandler.fDoc2XSDocumentMap(doc);
+ boolean isGlobal = false;
+
+ if (DOMUtil.getParent(elm).getLocalName
().equals(SchemaSymbols.ELT_SCHEMA))
+ isGlobal = true;
+
+ Object[] parentAttrs = fAttrChecker.checkAttributes(elm,
isGlobal, docInfo);
+
+ traverseAnnotationDecl(content, parentAttrs, false, docInfo);
+
+ fAttrChecker.returnAttrArray(parentAttrs, docInfo);
+ content = DOMUtil.getNextSiblingElement(content);
+
+ // REVISIT : should we make these checks here ??
+
+ if (content == null && !isEmpty) {
+ reportGenericSchemaError("Element '"+ elm.getLocalName()
+"' cannot have empty content");
+ }
+ else if (content != null && isEmpty) {
+ reportGenericSchemaError("Element '"+
elm.getLocalName() +"' should be empty");
+ }
+ }
+
+ return content;
+ }
+
+ /* new checkContent(Element, Object[])
+
+ Element checkContent( Element content, Object[] parentAttrs ) {
+
+ if (content == null) {
+ return content;
+ }
+
+ if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
+ Document doc = DOMUtil.getDocument(content);
+ XSDocumentInfo docInfo =
fSchemaHandler.fDoc2XSDocumentMap(doc);
+
+ traverseAnnotationDecl(content, parentAttrs, false, docInfo);
+
+ content = DOMUtil.getNextSiblingElement(content);
+ }
+
return content;
}
+
+ *** end of commented part */
/**
* Element/Attribute traversers call this method to check whether
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]