conor 2003/01/17 02:27:12
Modified: src/main/org/apache/tools/ant/helper ProjectHelper2.java
src/main/org/apache/tools/ant/util JAXPUtils.java
Log:
Actually enable namespace support in ProjectHelper2
Revision Changes Path
1.13 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
Index: ProjectHelper2.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -u -r1.12 -r1.13
--- ProjectHelper2.java 9 Jan 2003 03:39:53 -0000 1.12
+++ ProjectHelper2.java 17 Jan 2003 10:27:12 -0000 1.13
@@ -161,7 +161,7 @@
/**
* SAX 2 style parser used to parse the given file.
*/
- context.parser =JAXPUtils.getXMLReader();
+ context.parser =JAXPUtils.getNamespaceXMLReader();
String uri = fu.toURI(context.buildFile.getAbsolutePath());
1.5 +49 -7
jakarta-ant/src/main/org/apache/tools/ant/util/JAXPUtils.java
Index: JAXPUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/JAXPUtils.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- JAXPUtils.java 10 Dec 2002 16:38:26 -0000 1.4
+++ JAXPUtils.java 17 Jan 2003 10:27:12 -0000 1.5
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -91,6 +91,14 @@
private static SAXParserFactory parserFactory = null;
/**
+ * Parser Factory to create Namespace aware parsers.
+ *
+ * @since Ant 1.6
+ */
+ private static SAXParserFactory nsParserFactory = null;
+
+
+ /**
* Returns the parser factory to use. Only one parser factory is
* ever created by this method and is then cached for future use.
*
@@ -108,6 +116,24 @@
}
/**
+ * Returns the parser factory to use to create namespace aware parsers.
+ *
+ * @return a SAXParserFactory to use which supports manufacture of
+ * namespace aware parsers
+ *
+ * @since Ant 1.6
+ */
+ public synchronized static SAXParserFactory getNSParserFactory()
+ throws BuildException {
+
+ if (nsParserFactory == null) {
+ nsParserFactory = newParserFactory();
+ nsParserFactory.setNamespaceAware(true);
+ }
+ return nsParserFactory;
+ }
+
+ /**
* Returns a new parser factory instance.
*
* @since Ant 1.5
@@ -133,7 +159,7 @@
*/
public static Parser getParser() throws BuildException {
try {
- return newSAXParser().getParser();
+ return newSAXParser(getParserFactory()).getParser();
} catch (SAXException e) {
throw convertToBuildException(e);
}
@@ -149,7 +175,22 @@
*/
public static XMLReader getXMLReader() throws BuildException {
try {
- return newSAXParser().getXMLReader();
+ return newSAXParser(getParserFactory()).getXMLReader();
+ } catch (SAXException e) {
+ throw convertToBuildException(e);
+ }
+ }
+
+ /**
+ * Returns a newly created SAX 2 XMLReader, which is namespace aware
+ *
+ * @return a SAX 2 XMLReader.
+ * @see #getParserFactory
+ * @since Ant 1.6
+ */
+ public static XMLReader getNamespaceXMLReader() throws BuildException {
+ try {
+ return newSAXParser(getNSParserFactory()).getXMLReader();
} catch (SAXException e) {
throw convertToBuildException(e);
}
@@ -174,9 +215,10 @@
*
* @since Ant 1.5
*/
- private static SAXParser newSAXParser() throws BuildException {
+ private static SAXParser newSAXParser(SAXParserFactory factory)
+ throws BuildException {
try {
- return getParserFactory().newSAXParser();
+ return factory.newSAXParser();
} catch (ParserConfigurationException e) {
throw new BuildException("Cannot create parser for the given "
+ "configuration: " + e.getMessage(),
e);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>