Refine search
int eventType = parser.getEventType(); do { if (eventType == parser.START_TAG) { return readThisValueXml(parser, name, null); } else if (eventType == parser.END_TAG) { throw new XmlPullParserException( "Unexpected end tag at: " + parser.getName()); } else if (eventType == parser.TEXT) { throw new XmlPullParserException( "Unexpected text: " + parser.getText()); eventType = parser.next(); } while (eventType != parser.END_DOCUMENT); throw new XmlPullParserException( "Unexpected end of document");
XmlPullParser parser = PlatformUtil.newXMLPullParser(); int tok; parser.setInput(is, "UTF-8"); MapRulType parentCategory = null; while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { if (tok == XmlPullParser.START_TAG) { String name = parser.getName(); if (name.equals("category")) { //$NON-NLS-1$ parentCategory = parseCategoryFromXml(parser); } catch (XmlPullParserException e) { log.error("Unexpected error", e); //$NON-NLS-1$ e.printStackTrace(); throw new RuntimeException(e);
document.setDocumentURI(systemId); KXmlParser parser = new KXmlParser(); try { parser.keepNamespaceAttributes(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware); parser.require(XmlPullParser.END_DOCUMENT, null, null); } catch (XmlPullParserException ex) { if (ex.getDetail() instanceof IOException) { throw (IOException) ex.getDetail(); if (ex.getDetail() instanceof RuntimeException) { throw (RuntimeException) ex.getDetail(); locator.setLineNumber(ex.getLineNumber()); locator.setColumnNumber(ex.getColumnNumber()); SAXParseException newEx = new SAXParseException(ex.getMessage(), locator);
public void parseSubTree(XmlPullParser pp) throws SAXException, IOException { this.pp = pp; final boolean namespaceAware = pp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES); try { if(pp.getEventType() != XmlPullParser.START_TAG) { throw new SAXException( "start tag must be read before skiping subtree"+pp.getPositionDescription()); } catch (XmlPullParserException ex) { final SAXParseException saxException = new SAXParseException("parsing error: "+ex, this, ex); ex.printStackTrace(); errorHandler.fatalError(saxException);
public static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException { int type; while ((type=parser.next()) != parser.START_TAG && type != parser.END_DOCUMENT) { } if (type != parser.START_TAG) { throw new XmlPullParserException("No start tag found"); } if (!parser.getName().equals(firstElementName)) { throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() + ", expected " + firstElementName); } }
/** * {@inheritDoc} */ @Override public void action( Dsmlv2Container container ) throws XmlPullParserException { AddRequestDsml addRequest = ( AddRequestDsml ) container.getBatchRequest().getCurrentRequest(); XmlPullParser xpp = container.getParser(); // Checking and adding the request's attributes String attributeValue; // name attributeValue = xpp.getAttributeValue( "", NAME ); if ( attributeValue != null ) { try { addRequest.addAttributeType( attributeValue ); } catch ( LdapException le ) { throw new XmlPullParserException( I18n.err( I18n.ERR_03020_CANT_ADD_ATTRIBUTE_VALUE ), xpp, le ); } } else { throw new XmlPullParserException( I18n.err( I18n.ERR_03002_NAME_ATTRIBUTE_REQUIRED ), xpp, null ); } } };
parser.require(XmlPullParser.START_DOCUMENT, null, null); parser.nextTag(); if (parser.getName().equals("bundles")) parseOscar(parser); else { e.printStackTrace(); throw new IllegalArgumentException("XML unregognized around: " + e.getLineNumber() + " " + e.getMessage());
/** * Processes the task required in the grammar to the given tag type * * @param container the DSML container * @param tagType the tag type * @throws XmlPullParserException when an error occurs during the parsing */ private static void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException { XmlPullParser xpp = container.getParser(); String tagName = Strings.lowerCase( xpp.getName() ); GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) ); if ( transition != null ) { container.setState( transition.getNextState() ); if ( transition.hasAction() ) { transition.getAction().action( container ); } } else { throw new XmlPullParserException( I18n.err( I18n.ERR_03036_MISSING_TAG, new Tag( tagName, tagType ) ), xpp, null ); } }
public static OpenPgpContentElement parseOpenPgpContentElement(XmlPullParser parser) throws XmlPullParserException { try { switch (parser.getName()) { case SigncryptElement.ELEMENT: return SigncryptElementProvider.INSTANCE.parse(parser); case SignElement.ELEMENT: return SignElementProvider.INSTANCE.parse(parser); case CryptElement.ELEMENT: return CryptElementProvider.INSTANCE.parse(parser); default: throw new XmlPullParserException("Expected <crypt/>, <sign/> or <signcrypt/> element, " + "but got neither of them."); } } catch (Exception e) { throw new XmlPullParserException(e.getMessage()); } }
static ColorStateList createFromXmlInner(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException { final String name = parser.getName(); if (!name.equals("selector")) { throw new XmlPullParserException( parser.getPositionDescription() + ": invalid color state list tag " + name); } return inflateColorStateList(context, parser, attrs); }
/** * {@inheritDoc} */ @Override public void action( Dsmlv2Container container ) throws XmlPullParserException { ExtendedResponse extendedResponse = ( ExtendedResponse ) container.getBatchResponse().getCurrentResponse(); XmlPullParser xpp = container.getParser(); try { String nextText = xpp.nextText(); if ( !Strings.isEmpty( nextText ) ) { extendedResponse.setResponseName( Oid.fromString( nextText.trim() ).toString() ); } } catch ( IOException ioe ) { throw new XmlPullParserException( I18n.err( I18n.ERR_03008_UNEXPECTED_ERROR, ioe.getMessage() ), xpp, ioe ); } catch ( DecoderException de ) { throw new XmlPullParserException( de.getMessage(), xpp, de ); } } };
private static final Object readThisPrimitiveValueXml(XmlPullParser parser, String tagName) throws XmlPullParserException, java.io.IOException { try { if (tagName.equals("int")) { return Integer.parseInt(parser.getAttributeValue(null, "value")); } else if (tagName.equals("long")) { return Long.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("float")) { return Float.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("double")) { return Double.valueOf(parser.getAttributeValue(null, "value")); } else if (tagName.equals("boolean")) { return Boolean.valueOf(parser.getAttributeValue(null, "value")); } else { return null; } } catch (NullPointerException e) { throw new XmlPullParserException("Need value attribute in <" + tagName + ">"); } catch (NumberFormatException e) { throw new XmlPullParserException( "Not a number in value attribute in <" + tagName + ">"); } }
public void parse(XmlPullParser xml) { int eventType = -1; while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { handleStartTag(xml); } else if (eventType == XmlPullParser.END_TAG) { handleEndTag(xml); } try { eventType = xml.next(); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
/** * Resets the parser using the latest connection's reader. Reseting the parser is necessary * when the plain connection has been secured or when a new opening stream element is going * to be sent by the server. */ private void resetParser() { try { parser = new MXParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(connection.reader); } catch (XmlPullParserException xppe) { xppe.printStackTrace(); } }
@Override public void setFeature(String name, boolean value) throws XmlPullParserException { throw new XmlPullParserException(E_NOT_SUPPORTED); }
private void setInput(XmlPullParser xpp) { if (mStringSource != null) { try { xpp.setInput(mStringSource); } catch (XmlPullParserException e) { e.printStackTrace(); } } else { try { xpp.setInput(mInputStreamSource, mInputEncoding); } catch (XmlPullParserException e) { e.printStackTrace(); } } }
protected char requireNextS() throws XmlPullParserException, IOException { final char ch = more(); if(!isS(ch)) { throw new XmlPullParserException( "white space is required and not "+printable(ch), this, null); } return skipS(ch); }
public int nextTag() throws XmlPullParserException, IOException { next(); if(eventType == TEXT && isWhitespace()) { // skip whitespace next(); } if (eventType != START_TAG && eventType != END_TAG) { throw new XmlPullParserException("expected START_TAG or END_TAG not " +TYPES[ getEventType() ], this, null); } return eventType; }
private void readInternalSubset() throws IOException, XmlPullParserException { read('['); skip(); if (peekCharacter() == ']') { position++; return; throw new XmlPullParserException( "Parameter entity references are not supported", this, null); throw new XmlPullParserException("Unexpected token", this, null);
throw new XmlPullParserException("No start tag found"); e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace();