30 // $Id: ParserAdapter.java,v 1.3 2004/11/03 22:53:09 jsuttor Exp $ |
30 // $Id: ParserAdapter.java,v 1.3 2004/11/03 22:53:09 jsuttor Exp $ |
31 |
31 |
32 package org.xml.sax.helpers; |
32 package org.xml.sax.helpers; |
33 |
33 |
34 import java.io.IOException; |
34 import java.io.IOException; |
|
35 import java.util.ArrayList; |
35 import java.util.Enumeration; |
36 import java.util.Enumeration; |
36 import java.util.Vector; |
37 import java.util.List; |
37 import jdk.xml.internal.SecuritySupport; |
38 import jdk.xml.internal.SecuritySupport; |
38 import org.xml.sax.AttributeList; // deprecated |
39 import org.xml.sax.AttributeList; // deprecated |
39 import org.xml.sax.Attributes; |
40 import org.xml.sax.Attributes; |
40 import org.xml.sax.ContentHandler; |
41 import org.xml.sax.ContentHandler; |
41 import org.xml.sax.DTDHandler; |
42 import org.xml.sax.DTDHandler; |
506 { |
507 { |
507 // These are exceptions from the |
508 // These are exceptions from the |
508 // first pass; they should be |
509 // first pass; they should be |
509 // ignored if there's a second pass, |
510 // ignored if there's a second pass, |
510 // but reported otherwise. |
511 // but reported otherwise. |
511 Vector exceptions = null; |
512 List<SAXException> exceptions = null; |
512 |
513 |
513 // If we're not doing Namespace |
514 // If we're not doing Namespace |
514 // processing, dispatch this quickly. |
515 // processing, dispatch this quickly. |
515 if (!namespaces) { |
516 if (!namespaces) { |
516 if (contentHandler != null) { |
517 if (contentHandler != null) { |
600 String attName[] = processName(attQName, true, true); |
601 String attName[] = processName(attQName, true, true); |
601 atts.addAttribute(attName[0], attName[1], attName[2], |
602 atts.addAttribute(attName[0], attName[1], attName[2], |
602 type, value); |
603 type, value); |
603 } catch (SAXException e) { |
604 } catch (SAXException e) { |
604 if (exceptions == null) |
605 if (exceptions == null) |
605 exceptions = new Vector(); |
606 exceptions = new ArrayList<>(); |
606 exceptions.addElement(e); |
607 exceptions.add(e); |
607 atts.addAttribute("", attQName, attQName, type, value); |
608 atts.addAttribute("", attQName, attQName, type, value); |
608 } |
609 } |
609 } |
610 } |
610 |
611 |
611 // now handle the deferred exception reports |
612 // now handle the deferred exception reports |
612 if (exceptions != null && errorHandler != null) { |
613 if (exceptions != null && errorHandler != null) { |
613 for (int i = 0; i < exceptions.size(); i++) |
614 for (int i = 0; i < exceptions.size(); i++) |
614 errorHandler.error((SAXParseException) |
615 errorHandler.error((SAXParseException) |
615 (exceptions.elementAt(i))); |
616 (exceptions.get(i))); |
616 } |
617 } |
617 |
618 |
618 // OK, finally report the event. |
619 // OK, finally report the event. |
619 if (contentHandler != null) { |
620 if (contentHandler != null) { |
620 String name[] = processName(qName, false, false); |
621 String name[] = processName(qName, false, false); |
646 |
647 |
647 // Split the name. |
648 // Split the name. |
648 String names[] = processName(qName, false, false); |
649 String names[] = processName(qName, false, false); |
649 if (contentHandler != null) { |
650 if (contentHandler != null) { |
650 contentHandler.endElement(names[0], names[1], names[2]); |
651 contentHandler.endElement(names[0], names[1], names[2]); |
651 Enumeration prefixes = nsSupport.getDeclaredPrefixes(); |
652 Enumeration<String> ePrefixes = nsSupport.getDeclaredPrefixes(); |
652 while (prefixes.hasMoreElements()) { |
653 while (ePrefixes.hasMoreElements()) { |
653 String prefix = (String)prefixes.nextElement(); |
654 String prefix = ePrefixes.nextElement(); |
654 contentHandler.endPrefixMapping(prefix); |
655 contentHandler.endPrefixMapping(prefix); |
655 } |
656 } |
656 } |
657 } |
657 nsSupport.popContext(); |
658 nsSupport.popContext(); |
658 } |
659 } |