Browse Source

Move to Xerces parser - needs some context loader setup

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272877 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
97738f8eed
4 changed files with 33 additions and 6 deletions
  1. BIN
      proposal/mutant/lib/parser/xercesImpl.jar
  2. BIN
      proposal/mutant/lib/parser/xml-apis.jar
  3. +9
    -4
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ElementHandler.java
  4. +24
    -2
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ParseContext.java

BIN
proposal/mutant/lib/parser/xercesImpl.jar View File


BIN
proposal/mutant/lib/parser/xml-apis.jar View File


+ 9
- 4
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ElementHandler.java View File

@@ -341,10 +341,15 @@ public abstract class ElementHandler extends DefaultHandler {
}
String localName = attributes.getLocalName(i);
String qName = attributes.getQName(i);
if (uri == null && qName.indexOf(":") != -1) {
// try to resolve through known namespaces
uri = context.resolveNamespace(qName);
localName = qName.substring(qName.indexOf(":") + 1);
if (uri == null) {
if (qName.indexOf(":") != -1) {
// try to resolve through known namespaces
uri = context.resolveNamespace(qName);
localName = qName.substring(qName.indexOf(":") + 1);
} else {
localName = qName;
}
}

String attributeValue = attributes.getValue(i);


+ 24
- 2
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ParseContext.java View File

@@ -86,8 +86,19 @@ public class ParseContext {
= new CircularDependencyChecker("parsing XML");

/** The factory used to create SAX parsers. */
private SAXParserFactory parserFactory = SAXParserFactory.newInstance();
private SAXParserFactory parserFactory;

public ParseContext() {
Thread thread = Thread.currentThread();
ClassLoader currentContextLoader = thread.getContextClassLoader();
try {
ClassLoader thisLoader = this.getClass().getClassLoader();
thread.setContextClassLoader(thisLoader);
parserFactory = SAXParserFactory.newInstance();
} finally {
thread.setContextClassLoader(currentContextLoader);
}
}

/**
* Parse a URL using the given root handler
@@ -119,7 +130,18 @@ public class ParseContext {
checker.visitNode(source);

// create a parser for this source
SAXParser saxParser = parserFactory.newSAXParser();
SAXParser saxParser = null;
Thread thread = Thread.currentThread();
ClassLoader currentContextLoader = thread.getContextClassLoader();
try {
ClassLoader thisLoader = this.getClass().getClassLoader();
thread.setContextClassLoader(thisLoader);
saxParser = parserFactory.newSAXParser();
} finally {
thread.setContextClassLoader(currentContextLoader);
}
XMLReader xmlReader = saxParser.getXMLReader();

// create a root handler for this


Loading…
Cancel
Save