Search in sources :

Example 21 with KXmlParser

use of org.kxml2.io.KXmlParser in project robovm by robovm.

the class KxmlPullParserDtdTest method newPullParser.

@Override
XmlPullParser newPullParser() throws XmlPullParserException {
    KXmlParser result = new KXmlParser();
    result.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, true);
    return result;
}
Also used : KXmlParser(org.kxml2.io.KXmlParser)

Example 22 with KXmlParser

use of org.kxml2.io.KXmlParser in project android-shape-imageview by siyamed.

the class SvgToPath method parse.

private static PathInfo parse(InputStream in, boolean ignoreDefs, float dpi) {
    try {
        XmlPullParser xr = new KXmlParser();
        SvgToPath svgHandler = new SvgToPath(xr);
        svgHandler.setDpi(dpi);
        if (ignoreDefs) {
            xr.setInput(new InputStreamReader(in));
            svgHandler.processSvg();
        } else {
            CopyInputStream cin = new CopyInputStream(in);
            XmlPullParser ids = new KXmlParser();
            ids.setInput(new InputStreamReader(cin.getCopy()));
            IdHandler idHandler = new IdHandler(ids);
            idHandler.processIds();
            svgHandler.idXml = idHandler.idXml;
            xr.setInput(new InputStreamReader(cin.getCopy()));
            svgHandler.processSvg();
        }
        return svgHandler.pathInfo;
    } catch (Exception e) {
        Log.w(TAG, "Parse error: " + e);
        throw new RuntimeException(e);
    }
}
Also used : KXmlParser(org.kxml2.io.KXmlParser) InputStreamReader(java.io.InputStreamReader) XmlPullParser(org.xmlpull.v1.XmlPullParser) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 23 with KXmlParser

use of org.kxml2.io.KXmlParser in project android_frameworks_base by AOSPA.

the class ExpatPerformanceTest method runJavaPullParser.

private void runJavaPullParser() throws XmlPullParserException, IOException {
    XmlPullParser pullParser;
    long start = System.currentTimeMillis();
    pullParser = new KXmlParser();
    pullParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    pullParser.setInput(newInputStream(), "UTF-8");
    withPullParser(pullParser);
    long elapsed = System.currentTimeMillis() - start;
    Log.i(TAG, "java pull parser: " + elapsed + "ms");
}
Also used : KXmlParser(org.kxml2.io.KXmlParser) XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 24 with KXmlParser

use of org.kxml2.io.KXmlParser in project XobotOS by xamarin.

the class Xml method newPullParser.

/**
     * Returns a new pull parser with namespace support.
     */
public static XmlPullParser newPullParser() {
    try {
        KXmlParser parser = new KXmlParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, true);
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
        return parser;
    } catch (XmlPullParserException e) {
        throw new AssertionError();
    }
}
Also used : KXmlParser(org.kxml2.io.KXmlParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 25 with KXmlParser

use of org.kxml2.io.KXmlParser in project kotlin by JetBrains.

the class LayoutInflationDetector method hasLayoutParams.

@VisibleForTesting
static boolean hasLayoutParams(@NonNull Reader reader) throws XmlPullParserException, IOException {
    KXmlParser parser = new KXmlParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(reader);
    while (true) {
        int event = parser.next();
        if (event == XmlPullParser.START_TAG) {
            for (int i = 0; i < parser.getAttributeCount(); i++) {
                if (parser.getAttributeName(i).startsWith(ATTR_LAYOUT_RESOURCE_PREFIX)) {
                    String prefix = parser.getAttributePrefix(i);
                    if (prefix != null && !prefix.isEmpty() && ANDROID_URI.equals(parser.getNamespace(prefix))) {
                        return true;
                    }
                }
            }
            return false;
        } else if (event == XmlPullParser.END_DOCUMENT) {
            return false;
        }
    }
}
Also used : KXmlParser(org.kxml2.io.KXmlParser) VisibleForTesting(com.android.annotations.VisibleForTesting)

Aggregations

KXmlParser (org.kxml2.io.KXmlParser)32 XmlPullParser (org.xmlpull.v1.XmlPullParser)14 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)14 StringReader (java.io.StringReader)8 IOException (java.io.IOException)6 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3 DocumentImpl (org.apache.harmony.xml.dom.DocumentImpl)3 DocumentType (org.w3c.dom.DocumentType)3 SAXParseException (org.xml.sax.SAXParseException)3 LocatorImpl (org.xml.sax.helpers.LocatorImpl)3 XmlAttribute (com.intellij.psi.xml.XmlAttribute)2 XmlFile (com.intellij.psi.xml.XmlFile)2 XmlTag (com.intellij.psi.xml.XmlTag)2 InputStreamReader (java.io.InputStreamReader)2 TreeSet (java.util.TreeSet)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 PsiElement (com.intellij.psi.PsiElement)1 StringWriter (java.io.StringWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1