PIZZADOMU.INFO

Got love setvalidating android saxparserfactory job

 

Code examples for Parsing XML documents

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

if(schemaValidation == true) {  //Using JAXP 1.2 to validate an XML document using an external schema.  if (xmlSchema != null) {  spf = SAXParserFactory.newInstance();  parser= spf.newSAXParser();  reader = parser.getXMLReader();    parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);  parser.setProperty(JAXP_SCHEMA_SOURCE, xmlSchema);    spf.setNamespaceAware(true);  spf.setValidating(true);  }  //Using JAXP 1.2 to validate an XML document using the xsi:noNamespaceSchemaLocation value.  else {  spf = SAXParserFactory.newInstance();    spf.setNamespaceAware(true);  spf.setValidating(true);   
if(schemaValidation == true) {  //Using JAXP 1.2 to validate an XML document using an external schema.  if (xmlSchema != null) {  spf = SAXParserFactory.newInstance();  parser= spf.newSAXParser();  reader = parser.getXMLReader();    parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);  parser.setProperty(JAXP_SCHEMA_SOURCE, xmlSchema);    spf.setNamespaceAware(true);  spf.setValidating(true);  }  //Using JAXP 1.2 to validate an XML document using the xsi:noNamespaceSchemaLocation value.  else {  spf = SAXParserFactory.newInstance();    spf.setNamespaceAware(true);  spf.setValidating(true);    parser= spf.newSAXParser();  reader = parser.getXMLReader();    parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);  }    }  //Validating an XML document using the DOCTYPE value.  else{  spf = SAXParserFactory.newInstance();  parser= spf.newSAXParser();  reader = parser.getXMLReader();  //Validate document using DTD.  reader.setFeature("http://xml.org/sax/features/validation", true);    }  Handler dh = new Handler();    File _anXMLFile = new File(xmlDoc);  if (_anXMLFile.exists()) parser.parse(_anXMLFile, dh);  }  catch (IOException ioe) {  ioe.printStackTrace();  setError(true);  }  Full Snippet Info
sp.parse(file, handlerBase);  }    @Override  public void parse(File file, DefaultHandler defaultHandler) throws SAXException, IOException {  sp.parse(file, defaultHandler);  }    @Override  @SuppressWarnings("deprecation")  public void parse(InputSource inputSource, org.xml.sax.HandlerBase handlerBase) throws SAXException, IOException {  sp.parse(inputSource, handlerBase);  }    @Override  public void parse(InputSource inputSource, DefaultHandler defaultHandler) throws SAXException, IOException {  sp.parse(inputSource, defaultHandler);  }    @Override  Full Snippet Info
try{  valList = new ArrayList<Value>();  DefaultHandler handler = new XMLParser(valList);  SAXParserFactory factory = SAXParserFactory.newInstance();  SAXParser parser = factory.newSAXParser();  parser.parse(in, handler);  vLen = valList.size();  vIdx = 0;  } catch (Exception ex) {  throw new RuntimeException(ex);  }  }    @Override  public byte readByte(String tag) throws IOException {  Value v = next();  if (!"ex:i1".equals(v.getType())) {  throw new IOException("Error deserializing "+tag+".");  }  return Byte.parseByte(v.getValue());  Full Snippet Info
private Map<String, String> readInfo(File sceneFolder)  throws ParserConfigurationException, SAXException, IOException {  final Map<String, String> values = new HashMap<String, String>();  SAXParserFactory spf = SAXParserFactory.newInstance();  SAXParser sp = spf.newSAXParser();  sp.parse(new File(sceneFolder, "Info.plist"), new DefaultHandler() {  private String key = "", val = "";  private boolean expectKey;    @Override  public void startElement(String uri, String localName,  String qName, Attributes attributes) throws SAXException {  expectKey = localName.equalsIgnoreCase("key");  if (expectKey) {  key = val = "";  }  }    @Override  public void characters(char[] ch, int start, int length)  Full Snippet Info
sf.setNamespaceAware(true);  sf.setValidating(true);    // Create parser and let it do XSD-based validation  SAXParser sp = sf.newSAXParser();  sp.setProperty(SCHEMA_LANGUAGE, XML_SCHEMA);  sp.setProperty(SCHEMA_SOURCE, xsdFile);    // Validate by parsing  Validator v = new Validator();  sp.parse(new File(xmlFile), v);    // Done  if (v.error) {  printFailure(xmlFile);  return false;  } else {  printSuccess(xmlFile);  return true;   }  Full Snippet Info
* @throws Exception  */  public AccessPointParserHelper(InputStream in) throws Exception {  SAXParserFactory factory = SAXParserFactory.newInstance();  SAXParser saxParser = factory.newSAXParser();  saxParser.parse(in, mHandler);  }    public List<WifiConfiguration> getNetworkConfigurations() throws Exception {  return networks;  }  }  Full Snippet Info
// ahhh... xml in java....  SAXParserFactory sf = SAXParserFactory.newInstance();  sf.setNamespaceAware(true);   sf.setValidating(true);   SAXParser parser = sf.newSAXParser();  parser.setProperty(  "http://java.sun.com/xml/jaxp/properties/schemaLanguage",   "http://www.w3.org/2001/XMLSchema");    // SAXParser parser = SAXParserFactory.newInstance().newSAXParser();  // parser.setProperty("http://xml.org/sax/features/validation", Boolean.TRUE);  //   // parser.setProperty("http://apache.org/xml/features/validation/schema",  // Boolean.TRUE);  // parser.setProperty("http://apache.org/xml/features/validation/schema-full-checking",  // Boolean.TRUE);    if ( schemaLocation != null ) {  parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaLocation);  // if ( targetNamespace != null ) { 
// ahhh... xml in java....  SAXParserFactory sf = SAXParserFactory.newInstance();  sf.setNamespaceAware(true);   sf.setValidating(true);   SAXParser parser = sf.newSAXParser();  parser.setProperty(  "http://java.sun.com/xml/jaxp/properties/schemaLanguage",   "http://www.w3.org/2001/XMLSchema");    // SAXParser parser = SAXParserFactory.newInstance().newSAXParser();  // parser.setProperty("http://xml.org/sax/features/validation", Boolean.TRUE);  //   // parser.setProperty("http://apache.org/xml/features/validation/schema",  // Boolean.TRUE);  // parser.setProperty("http://apache.org/xml/features/validation/schema-full-checking",  // Boolean.TRUE);    if ( schemaLocation != null ) {  parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaLocation);  // if ( targetNamespace != null ) {  // parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",  // targetNamespace + " " + schemaLocation );   // }  }    parser.parse( in, errorHandler);    }   catch( Exception e ) {  String msg = "Error reading : " + xml;  throw new RuntimeException ( msg, e );  Full Snippet Info
  public List<YourActionFeed> parse() throws Exception {  SAXParserFactory factory = SAXParserFactory.newInstance();  SAXParser parser = factory.newSAXParser();  RssHandler handler = new RssHandler();  parser.parse(this.getInputStream(), handler);  return handler.getFeeds();  }    final static HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {  public boolean verify(String hostname, SSLSession session) {  return true;  }  };  }  Full Snippet Info
}    SAXParser saxParser = null;  try {  saxParser = saxFactory.newSAXParser();  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");  if(useExternalSchema) {  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", tmpSchema);  }  }  catch (SAXException e) {  logger.error("Cannot create a validating parser. Reason: "+e.getMessage());  return false;  }  catch(ParserConfigurationException e) {  logger.error("Cannot create a validating parser. Reason: "+e.getMessage());  return false;  }    try { 
}    SAXParser saxParser = null;  try {  saxParser = saxFactory.newSAXParser();  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");  if(useExternalSchema) {  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", tmpSchema);  }  }  catch (SAXException e) {  logger.error("Cannot create a validating parser. Reason: "+e.getMessage());  return false;  }  catch(ParserConfigurationException e) {  logger.error("Cannot create a validating parser. Reason: "+e.getMessage());  return false;  }    try {  saxParser.parse(new File(fileName), handler);  }  catch(SAXException e) {  logger.error("A SAX exception was produced during the validation process. Maybe this has already been logged.");  return false;  }  Full Snippet Info
AliceHandle aliceReader = new AliceHandle();  SAXParserFactory factory = SAXParserFactory.newInstance();  SAXParser saxParser;  try {  saxParser = factory.newSAXParser();  saxParser.parse(aliceXml, aliceReader);  } catch (Exception e) {  e.printStackTrace();  }  supportedAlices = aliceReader.getSupportedAlices();  }    public Keygen getKeygen(ScanResult result) {  final Keygen keygen = getKeygen(result.SSID,  result.BSSID.toUpperCase(),  WifiManager.calculateSignalLevel(result.level, 4),  result.capabilities);    if( keygen != null )  keygen.setScanResult(result);  Full Snippet Info
https://www.codota.com/android/tasks/5100178b8864f1a0de00005d/parsing-xml-documents