diff --git a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java index 33b5d2db..97e390a3 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasProvider.java @@ -486,9 +486,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider XmlPullUtil.enter(pp, "LocationList"); - if (pp.isWhitespace()) - pp.next(); - while (XmlPullUtil.test(pp, "StopLocation") || XmlPullUtil.test(pp, "CoordLocation")) { final String name = ParserUtils.resolveEntities(XmlPullUtil.attr(pp, "name")); @@ -521,9 +518,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider XmlPullUtil.enter(pp); XmlPullUtil.exit(pp); } - - if (pp.isWhitespace()) - pp.next(); } XmlPullUtil.exit(pp, "LocationList"); @@ -1123,10 +1117,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider throw new IllegalStateException("error " + code + " " + XmlPullUtil.attr(pp, "text")); } - // workaround for broken firstConDiffersFromReqDate="true" as text node - if (pp.getEventType() == XmlPullParser.TEXT) - pp.nextTag(); - final String c = XmlPullUtil.test(pp, "ConResCtxt") ? XmlPullUtil.text(pp) : null; final Context context; if (previousContext == null) diff --git a/enabler/src/de/schildbach/pte/util/XmlPullUtil.java b/enabler/src/de/schildbach/pte/util/XmlPullUtil.java index 34b3e6eb..9847d9b5 100644 --- a/enabler/src/de/schildbach/pte/util/XmlPullUtil.java +++ b/enabler/src/de/schildbach/pte/util/XmlPullUtil.java @@ -15,13 +15,28 @@ import org.xmlpull.v1.XmlPullParserException; */ public final class XmlPullUtil { + + public static boolean test(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException + { + if (pp.getEventType() == XmlPullParser.TEXT && pp.isWhitespace()) + pp.next(); + + return pp.getEventType() == XmlPullParser.START_TAG && pp.getName().equals(tagName); + } + public static void require(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException { + if (pp.getEventType() == XmlPullParser.TEXT && pp.isWhitespace()) + pp.next(); + pp.require(XmlPullParser.START_TAG, null, tagName); } public static void enter(final XmlPullParser pp) throws XmlPullParserException, IOException { + if (pp.getEventType() == XmlPullParser.TEXT && pp.isWhitespace()) + pp.next(); + if (pp.getEventType() != XmlPullParser.START_TAG) throw new IllegalStateException("expecting start tag to enter"); if (pp.isEmptyElementTag()) @@ -32,6 +47,9 @@ public final class XmlPullUtil public static void enter(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException { + if (pp.getEventType() == XmlPullParser.TEXT && pp.isWhitespace()) + pp.next(); + pp.require(XmlPullParser.START_TAG, null, tagName); enter(pp); } @@ -49,6 +67,7 @@ public final class XmlPullUtil public static void exit(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException { exitSkipToEnd(pp); + pp.require(XmlPullParser.END_TAG, null, tagName); pp.next(); } @@ -66,11 +85,6 @@ public final class XmlPullUtil } } - public static boolean test(final XmlPullParser pp, final String tagName) throws XmlPullParserException - { - return pp.getEventType() == XmlPullParser.START_TAG && pp.getName().equals(tagName); - } - public static void requireSkip(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException { require(pp, tagName);