Patched Service Binder to use kxml2 to avoid licensing issues with
kxml1, thanks goes to Jan S. Rellermeyer. (FELIX-93)
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@422004 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.servicebinder/pom.xml b/org.apache.felix.servicebinder/pom.xml
index bb984ba..f9c981e 100644
--- a/org.apache.felix.servicebinder/pom.xml
+++ b/org.apache.felix.servicebinder/pom.xml
@@ -16,9 +16,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>kxml</groupId>
- <artifactId>kxml</artifactId>
- <version>1.21</version>
+ <groupId>kxml2</groupId>
+ <artifactId>kxml2</artifactId>
+ <version>2.2.2</version>
</dependency>
</dependencies>
<build>
diff --git a/org.apache.felix.servicebinder/src/main/java/org/apache/felix/servicebinder/parser/KxmlParser.java b/org.apache.felix.servicebinder/src/main/java/org/apache/felix/servicebinder/parser/KxmlParser.java
index 4a553ff..c42444e 100644
--- a/org.apache.felix.servicebinder/src/main/java/org/apache/felix/servicebinder/parser/KxmlParser.java
+++ b/org.apache.felix.servicebinder/src/main/java/org/apache/felix/servicebinder/parser/KxmlParser.java
@@ -17,13 +17,11 @@
package org.apache.felix.servicebinder.parser;
import org.apache.felix.servicebinder.XmlHandler;
-import org.kxml.parser.XmlParser;
-import org.kxml.parser.ParseEvent;
-import org.kxml.Xml;
-import org.kxml.Attribute;
-
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import java.io.IOException;
import java.io.Reader;
-
import java.util.Properties;
/**
@@ -32,46 +30,50 @@
*
* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
*/
-public class KxmlParser extends XmlParser
+public class KxmlParser extends KXmlParser
{
/**
- * The constructor for a parser, it receives a java.io.Reader.
- *
- * @param r The reader
- * @exception java.io.IOException thrown by the superclass
- */
- public KxmlParser(Reader r) throws java.io.IOException
+ * The constructor for a parser, it receives a java.io.Reader.
+ *
+ * @param reader The reader
+ * @throws XmlPullParserException thrown by the super class.
+ */
+ public KxmlParser(final Reader reader) throws XmlPullParserException
{
- super(r);
+ super();
+ setInput(reader);
}
/**
- * Parser from the reader provided in the constructor, and call
- * the startElement and endElement in a KxmlHandler
- *
- * @param handler The handler
- * @exception java.io.IOException thrown by the superclass
- */
- public void parseXML(XmlHandler handler) throws java.io.IOException, ParseException
+ * Parser from the reader provided in the constructor, and call the
+ * startElement and endElement in a KxmlHandler
+ *
+ * @param handler The handler
+ * @throws XmlPullParserException thrown by the super class.
+ * @throws IOException thrown by the super class.
+ * @throws ParseException thrown by the handler.
+ */
+ public void parseXML(final XmlHandler handler)
+ throws XmlPullParserException, IOException, ParseException
{
- ParseEvent evt=null;
- do
+ while (next() != XmlPullParser.END_DOCUMENT)
{
- evt = read();
- if (evt.getType() == Xml.START_TAG)
+ switch (getEventType())
{
- Properties props = new Properties();
- for (int i=0; i<evt.getAttributeCount();i++)
- {
- Attribute attr = evt.getAttribute(i);
- props.put(attr.getName(),attr.getValue());
- }
- handler.startElement("uri",evt.getName(),evt.getName(),props);
+ case XmlPullParser.START_TAG:
+ Properties props = new Properties();
+ for (int i = 0; i < getAttributeCount(); i++)
+ {
+ props.put(getAttributeName(i), getAttributeValue(i));
+ }
+ handler.startElement(getNamespace(), getName(), getName(), props);
+ break;
+ case XmlPullParser.END_TAG:
+ handler.endElement(getNamespace(), getName(), getName());
+ break;
+ default:
+ continue;
}
- if (evt.getType() == Xml.END_TAG)
- {
- handler.endElement("uri",evt.getName(),evt.getName());
- }
- }while(evt.getType()!=Xml.END_DOCUMENT);
+ }
}
-}
+}
\ No newline at end of file