sandygao 2002/08/14 15:49:28 Modified: java/src/org/apache/xerces/impl/xs SchemaNamespaceSupport.java Log: 1. Fixing an obvious typo. The condition to resize an array should be if it too *small". So '<' should be used instead of '>'. 2. The "fixed" size of an SchemaNamespaceSupport should be 3: - an empty context (which all NamespaceSupport objects have); - an context for "xml" and "xmlns" decls (ditto); - an context for global namespace decls on <xs:schema>. Revision Changes Path 1.4 +24 -27 xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaNamespaceSupport.java Index: SchemaNamespaceSupport.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/SchemaNamespaceSupport.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SchemaNamespaceSupport.java 12 Apr 2002 15:54:40 -0000 1.3 +++ SchemaNamespaceSupport.java 14 Aug 2002 22:49:28 -0000 1.4 @@ -100,23 +100,17 @@ */ public void setEffectiveContext (String [] namespaceDecls) { if(namespaceDecls == null || namespaceDecls.length == 0) return; - if(fCurrentContext == fContext.length) { - // expand size of fContext - int[] newContext = new int[fContext.length*2]; - System.arraycopy(fContext, 0, newContext, 0, fContext.length); - fContext = newContext; - } - fContext[++fCurrentContext] = fNamespaceSize; - while(fNamespace.length > fNamespaceSize + namespaceDecls.length) { + pushContext(); + int newSize = fNamespaceSize + namespaceDecls.length; + if (fNamespace.length < newSize) { // expand namespace's size... - String[] tempNSArray = new String[fNamespace.length*2]; - System.arraycopy(fNamespace, 0, tempNSArray, 0, - fNamespace.length); + String[] tempNSArray = new String[newSize]; + System.arraycopy(fNamespace, 0, tempNSArray, 0, fNamespace.length); fNamespace = tempNSArray; } System.arraycopy(namespaceDecls, 0, fNamespace, fNamespaceSize, - namespaceDecls.length); - fNamespaceSize += namespaceDecls.length; + namespaceDecls.length); + fNamespaceSize = newSize; } // setEffectiveContext(String):void /** @@ -126,26 +120,29 @@ */ public String [] getEffectiveLocalContext() { // the trick here is to recognize that all local contexts - // happen to start at fContext[2]. - int bottomLocalContext = (fCurrentContext >= 2) ? fContext[2]:-1; - if (bottomLocalContext == -1) { - // no local decls! - return null; + // happen to start at fContext[3]. + // context 1: empty + // context 2: decls for xml and xmlns; + // context 3: decls on <xs:schema>: the global ones + String[] returnVal = null; + if (fCurrentContext >= 3) { + int bottomLocalContext = fContext[3]; + int copyCount = fNamespaceSize - bottomLocalContext; + if (copyCount > 0) { + returnVal = new String[copyCount]; + System.arraycopy(fNamespace, bottomLocalContext, returnVal, 0, + copyCount); + } } - String [] returnVal = new String[fNamespaceSize-bottomLocalContext]; - System.arraycopy(fNamespace, bottomLocalContext, returnVal, 0, - fNamespaceSize-bottomLocalContext); return returnVal; } // getEffectiveLocalContext():String // This method removes from this object all the namespaces // returned by getEffectiveLocalContext. public void makeGlobal() { - int topLocalContext = (fCurrentContext >= 2) ? fContext[2]:-1; - if(topLocalContext == -1) { - return; // nothing to do! + if (fCurrentContext >= 3) { + fCurrentContext = 3; + fNamespaceSize = fContext[3]; } - fCurrentContext = 1; - fNamespaceSize = fContext[fCurrentContext]; } // makeGlobal } // class NamespaceSupport
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]