Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 6529 invoked from network); 29 Oct 2001 16:25:47 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 29 Oct 2001 16:25:47 -0000 Received: (qmail 596 invoked by uid 97); 29 Oct 2001 16:25:49 -0000 Delivered-To: qmlist-jakarta-avalon-cvs-archive@jakarta.apache.org Received: (qmail 584 invoked by uid 97); 29 Oct 2001 16:25:49 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 573 invoked from network); 29 Oct 2001 16:25:48 -0000 Date: 29 Oct 2001 16:16:28 -0000 Message-ID: <20011029161628.36941.qmail@icarus.apache.org> From: bloritsch@apache.org To: jakarta-avalon-cvs@apache.org Subject: cvs commit: jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test SAXConfigurationHandlerTestCase.java X-Spam-Rating: taz3.hyperreal.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bloritsch 01/10/29 08:16:28 Modified: src/java/org/apache/avalon/framework/configuration DefaultConfigurationSerializer.java SAXConfigurationHandler.java src/test/org/apache/avalon/framework/configuration/test SAXConfigurationHandlerTestCase.java Log: Fix SAXConfigurationHandler to handle faulty SAX Readers that do not properly handle prefix mapping. Revision Changes Path 1.4 +1 -1 jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfigurationSerializer.java Index: DefaultConfigurationSerializer.java =================================================================== RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfigurationSerializer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultConfigurationSerializer.java 2001/10/29 14:58:48 1.3 +++ DefaultConfigurationSerializer.java 2001/10/29 16:16:28 1.4 @@ -132,7 +132,7 @@ } else { - qName = prefix + ":" + localName; + qName = nsPrefix + ":" + localName; } this.m_handler.startElement(nsURI, localName, qName, attr); 1.7 +39 -1 jakarta-avalon/src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java Index: SAXConfigurationHandler.java =================================================================== RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SAXConfigurationHandler.java 2001/10/29 14:58:48 1.6 +++ SAXConfigurationHandler.java 2001/10/29 16:16:28 1.7 @@ -8,6 +8,7 @@ package org.apache.avalon.framework.configuration; import java.util.ArrayList; +import java.util.Iterator; import org.xml.sax.Attributes; import org.xml.sax.ErrorHandler; import org.xml.sax.Locator; @@ -15,6 +16,7 @@ import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.NamespaceSupport; +import org.xml.sax.helpers.AttributesImpl; /** * A SAXConfigurationHandler helps build Configurations out of sax events. @@ -27,6 +29,7 @@ implements ErrorHandler { private final ArrayList m_elements = new ArrayList(); + private final ArrayList m_prefixes = new ArrayList(); private Configuration m_configuration; private Locator m_locator; private NamespaceSupport m_namespaceSupport = new NamespaceSupport(); @@ -39,6 +42,12 @@ public void clear() { m_elements.clear(); + Iterator i = m_prefixes.iterator(); + while ( i.hasNext() ) + { + ( (ArrayList) i.next() ).clear(); + } + m_prefixes.clear(); m_locator = null; } @@ -92,6 +101,14 @@ { final int location = m_elements.size() - 1; final Object object = m_elements.remove( location ); + final ArrayList prefixes = (ArrayList) m_prefixes.remove( location ); + + final Iterator i = prefixes.iterator(); + while ( i.hasNext() ) + { + endPrefixMapping( (String) i.next() ); + } + prefixes.clear(); if( 0 == location ) { @@ -117,6 +134,26 @@ throws SAXException { m_namespaceSupport.pushContext(); + final ArrayList prefixes = new ArrayList(); + AttributesImpl componentAttr = new AttributesImpl(); + + for (int i = 0; i < attributes.getLength(); i++) + { + if ( attributes.getQName(i).startsWith("xmlns") ) + { + prefixes.add( attributes.getLocalName(i) ); + this.startPrefixMapping( attributes.getLocalName(i), + attributes.getValue(i) ); + } + else + { + componentAttr.addAttribute( attributes.getURI( i ), + attributes.getLocalName( i ), + attributes.getQName( i ), + attributes.getType( i ), + attributes.getValue( i ) ); + } + } final DefaultConfiguration configuration = createConfiguration( localName, namespaceURI, getLocationString() ); @@ -138,8 +175,9 @@ } m_elements.add( configuration ); + m_prefixes.add( prefixes ); - final int attributesSize = attributes.getLength(); + final int attributesSize = componentAttr.getLength(); for( int i = 0; i < attributesSize; i++ ) { 1.4 +1 -0 jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test/SAXConfigurationHandlerTestCase.java Index: SAXConfigurationHandlerTestCase.java =================================================================== RCS file: /home/cvs/jakarta-avalon/src/test/org/apache/avalon/framework/configuration/test/SAXConfigurationHandlerTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SAXConfigurationHandlerTestCase.java 2001/10/29 15:49:25 1.3 +++ SAXConfigurationHandlerTestCase.java 2001/10/29 16:16:28 1.4 @@ -70,6 +70,7 @@ "CDATA",attValue); final AttributesImpl childAttributes = new AttributesImpl(); + childAttributes.addAttribute("", "child", "xmlns:child", "CDATA", childURI); m_handler.startDocument(); m_handler.startElement( rootURI, rootlocal, rootraw, attributes ); -- To unsubscribe, e-mail: For additional commands, e-mail: