List of usage examples for javax.xml.parsers SAXParser parse
public void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException
From source file:org.pentaho.platform.repository.solution.SolutionRepositoryServiceImpl.java
private Map<IPermissionRecipient, IPermissionMask> createAclFromXml(final String strXml) throws ParserConfigurationException, SAXException, IOException { SAXParser parser = getSAXParserFactory().newSAXParser(); Map<IPermissionRecipient, IPermissionMask> m = new HashMap<IPermissionRecipient, IPermissionMask>(); DefaultHandler h = new AclParserHandler(m); String encoding = XmlHelper.getEncoding(strXml); InputStream is = new ByteArrayInputStream(strXml.getBytes(encoding)); parser.parse(is, h); return m;/*w w w . j a va 2 s. com*/ }
From source file:org.piraso.api.io.PirasoEntryReader.java
public void start() throws SAXException, ParserConfigurationException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.parse(in, this); }
From source file:org.richfaces.cdk.rd.mojo.ResourceDependencyMojo.java
public ComponentsHandler findComponents(File webSourceDir, Map<String, Components> components, String[] includes, String[] excludes) throws Exception { if (includes == null) { includes = PluginUtils.DEFAULT_PROCESS_INCLUDES; }// ww w . j a v a 2 s . c om if (excludes == null) { excludes = new String[0]; } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(webSourceDir); scanner.setIncludes(includes); scanner.setExcludes(excludes); scanner.addDefaultExcludes(); getLog().info("search *.xhtml files"); scanner.scan(); String[] collectedFiles = scanner.getIncludedFiles(); for (String collectedFile : collectedFiles) { getLog().info(collectedFile + " found"); } ComponentsHandler handler = new ComponentsHandler(getLog()); handler.setComponents(components); handler.setScriptIncludes(scriptIncludes); handler.setScriptExcludes(scriptExcludes); handler.setStyleIncludes(styleIncludes); handler.setStyleExcludes(styleExcludes); handler.setComponentIncludes(componentIncludes); handler.setComponentExcludes(componentExcludes); handler.setNamespaceIncludes(namespaceIncludes); handler.setNamespaceExcludes(namespaceExcludes); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); Log log = getLog(); for (String processFile : collectedFiles) { SAXParser saxParser = saxParserFactory.newSAXParser(); File file = new File(webSourceDir, processFile); if (file.exists()) { if (log.isDebugEnabled()) { log.debug("start process file: " + file.getPath()); } try { saxParser.parse(file, handler); } catch (Exception e) { if (log.isDebugEnabled()) { log.error("Error process file: " + file.getPath() + "\n" + e.getMessage(), e); } else { log.error("Error process file: " + file.getPath() + "\n" + e.getMessage()); } } } } return handler; }
From source file:org.sakaibrary.osid.repository.xserver.AssetIterator.java
/** * This method parses the xml StringBuilder and creates Assets, Records * and Parts in the Repository with the given repositoryId. * * @param xml input xml in "sakaibrary" format * @param log the log being used by the Repository * @param repositoryId the Id of the Repository in which to create Assets, * Records and Parts./*from ww w.j a v a2s . c o m*/ * * @throws org.osid.repository.RepositoryException */ private void createAssets(java.io.ByteArrayInputStream xml, org.osid.shared.Id repositoryId) throws org.osid.repository.RepositoryException { this.repositoryId = repositoryId; recordStructureId = RecordStructure.getInstance().getId(); textBuffer = new StringBuilder(); // use a SAX parser javax.xml.parsers.SAXParserFactory factory; javax.xml.parsers.SAXParser saxParser; // set up the parser factory = javax.xml.parsers.SAXParserFactory.newInstance(); factory.setNamespaceAware(true); // start parsing try { saxParser = factory.newSAXParser(); saxParser.parse(xml, this); xml.close(); } catch (SAXParseException spe) { // Use the contained exception, if any Exception x = spe; if (spe.getException() != null) { x = spe.getException(); } // Error generated by the parser LOG.warn("createAssets() parsing exception: " + spe.getMessage() + " - xml line " + spe.getLineNumber() + ", uri " + spe.getSystemId(), x); } catch (SAXException sxe) { // Error generated by this application // (or a parser-initialization error) Exception x = sxe; if (sxe.getException() != null) { x = sxe.getException(); } LOG.warn("createAssets() SAX exception: " + sxe.getMessage(), x); } catch (ParserConfigurationException pce) { // Parser with specified options can't be built LOG.warn("createAssets() SAX parser cannot be built with " + "specified options"); } catch (IOException ioe) { // I/O error LOG.warn("createAssets() IO exception", ioe); } }
From source file:org.sakaibrary.xserver.XMLCleanup.java
public ByteArrayOutputStream cleanup(InputStream xml) throws XServerException { inputXml = xml;/*from w w w .j a va 2s . c om*/ // Use the default (non-validating) parser SAXParserFactory factory = SAXParserFactory.newInstance(); try { // Parse the input SAXParser saxParser = factory.newSAXParser(); saxParser.parse(inputXml, this); // close the stream inputXml.close(); } catch (SAXParseException spe) { // Use the contained exception, if any Exception x = spe; if (spe.getException() != null) { x = spe.getException(); } // Error generated by the parser LOG.warn("XMLCleanup.cleanup() parsing exception: " + spe.getMessage() + " - xml line " + spe.getLineNumber() + ", uri " + spe.getSystemId(), x); } catch (SAXException sxe) { // Error generated by this application // (or a parser-initialization error) Exception x = sxe; if (sxe.getException() != null) { x = sxe.getException(); } LOG.warn("XMLCleanup.cleanup() SAX exception: " + sxe.getMessage(), x); } catch (ParserConfigurationException pce) { // Parser with specified options can't be built LOG.warn("XMLCleanup.cleanup() SAX parser cannot be built with " + "specified options"); } catch (IOException ioe) { // I/O error LOG.warn("XMLCleanup.cleanup() IO exception", ioe); } catch (Throwable t) { LOG.warn("XMLCleanup.cleanup() exception", t); } if (error) { throw new XServerException(error_code, error_text); } return bytes; }
From source file:org.sakaiproject.assignment.impl.conversion.AssignmentSubmissionAccess.java
/** * @param xml//w w w . j ava2s . c om * @throws EntityParseException */ public void parse(String xml) throws Exception { Reader r = new StringReader(xml); InputSource ss = new InputSource(r); SAXParser p = null; if (parserFactory == null) { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(false); parserFactory.setValidating(false); } try { p = parserFactory.newSAXParser(); } catch (ParserConfigurationException e) { log.warn("{}:parse {}", this, e.getMessage()); throw new SAXException("Failed to get a parser ", e); } final Map<String, Object> props = new HashMap<String, Object>(); saxSerializableProperties.setSerializableProperties(props); p.parse(ss, new DefaultHandler() { /* * (non-Javadoc) * * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if ("property".equals(qName)) { String name = attributes.getValue("name"); String enc = StringUtils.trimToNull(attributes.getValue("enc")); String value = null; if ("BASE64".equalsIgnoreCase(enc)) { String charset = StringUtils.trimToNull(attributes.getValue("charset")); if (charset == null) charset = "UTF-8"; value = Xml.decode(charset, attributes.getValue("value")); } else { value = attributes.getValue("value"); } // deal with multiple valued lists if ("list".equals(attributes.getValue("list"))) { // accumulate multiple values in a list Object current = props.get(name); // if we don't have a value yet, make a list to // hold // this one if (current == null) { List values = new ArrayList(); props.put(name, values); values.add(value); } // if we do and it's a list, add this one else if (current instanceof List) { ((List) current).add(value); } // if it's not a list, it's wrong! else { log.warn("construct(el): value set not a list: {}", name); } } else { props.put(name, value); } } else if ("submission".equals(qName)) { setId(attributes.getValue("id")); setAssignment(StringUtils.trimToNull(attributes.getValue("assignment"))); setContext(StringUtils.trimToNull(attributes.getValue("context"))); setDatereturned(StringUtils.trimToNull(attributes.getValue("datereturned"))); setDatesubmitted(StringUtils.trimToNull(attributes.getValue("datesubmitted"))); setFeedbackcomment(StringUtils.trimToNull(attributes.getValue("feedbackcomment"))); if (StringUtils.trimToNull(attributes.getValue("feedbackcomment-html")) != null) { setFeedbackcomment_html( StringUtils.trimToNull(attributes.getValue("feedbackcomment-html"))); } else if (StringUtils.trimToNull(attributes.getValue("feedbackcomment-formatted")) != null) { setFeedbackcomment_html( StringUtils.trimToNull(attributes.getValue("feedbackcomment-formatted"))); } setFeedbacktext(StringUtils.trimToNull(attributes.getValue("feedbacktext"))); if (StringUtils.trimToNull(attributes.getValue("feedbacktext-html")) != null) { setFeedbacktext_html(StringUtils.trimToNull(attributes.getValue("feedbacktext-html"))); } else if (StringUtils.trimToNull(attributes.getValue("feedbacktext-formatted")) != null) { setFeedbacktext_html(StringUtils.trimToNull(attributes.getValue("feedbacktext-formatted"))); } // get number of decimals String factor = StringUtils.trimToNull(attributes.getValue("scaled_factor")); if (factor == null) { factor = String.valueOf(AssignmentConstants.DEFAULT_SCALED_FACTOR); } m_factor = Integer.valueOf(factor); // get grade String grade = StringUtils.trimToNull(attributes.getValue("scaled_grade")); if (grade == null) { grade = StringUtils.trimToNull(attributes.getValue("grade")); if (grade != null) { try { Integer.parseInt(grade); // for the grades in points, multiple those by factor grade = grade + factor.substring(1); } catch (Exception e) { log.warn("{}:parse grade {}", this, e.getMessage()); } } } setGrade(grade); setGraded(StringUtils.trimToNull(attributes.getValue("graded"))); setGradedBy(StringUtils.trimToNull(attributes.getValue("gradedBy"))); setGradereleased(StringUtils.trimToNull(attributes.getValue("gradereleased"))); setLastmod(StringUtils.trimToNull(attributes.getValue("lastmod"))); addElementsToList("feedbackattachment", feedbackattachments, attributes, false); addElementsToList("submittedattachment", submittedattachments, attributes, false); setPledgeflag(StringUtils.trimToNull(attributes.getValue("pledgeflag"))); setReturned(StringUtils.trimToNull(attributes.getValue("returned"))); setReviewReport(StringUtils.trimToNull(attributes.getValue("reviewReport"))); setReviewScore(StringUtils.trimToNull(attributes.getValue("reviewScore"))); setReviewStatus(StringUtils.trimToNull(attributes.getValue("reviewStatus"))); setSubmitted(StringUtils.trimToNull(attributes.getValue("submitted"))); // submittedtext and submittedtext_html are base-64 setSubmittedtext(StringUtils.trimToNull(attributes.getValue("submittedtext"))); setSubmittedtext_html(StringUtils.trimToNull(attributes.getValue("submittedtext-html"))); setSubmitterId(StringUtils.trimToNull(attributes.getValue("submitterid"))); addElementsToList("submitter", submitters, attributes, false); // for backward compatibility of assignments without submitter ids if (getSubmitterId() == null && submitters.size() > 0) { setSubmitterId(submitters.get(0)); } addElementsToList("grade", grades, attributes, false); } } }); }
From source file:org.sakaiproject.assignment.impl.conversion.impl.AssignmentSubmissionAccess.java
/** * @param xml/*w ww .j av a 2 s .c o m*/ * @throws EntityParseException */ public void parse(String xml) throws Exception { Reader r = new StringReader(xml); InputSource ss = new InputSource(r); SAXParser p = null; if (parserFactory == null) { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(false); parserFactory.setValidating(false); } try { p = parserFactory.newSAXParser(); } catch (ParserConfigurationException e) { log.warn(this + ":parse " + e.getMessage()); throw new SAXException("Failed to get a parser ", e); } final Map<String, Object> props = new HashMap<String, Object>(); saxSerializableProperties.setSerializableProperties(props); p.parse(ss, new DefaultHandler() { /* * (non-Javadoc) * * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if ("property".equals(qName)) { String name = attributes.getValue("name"); String enc = StringUtils.trimToNull(attributes.getValue("enc")); String value = null; if ("BASE64".equalsIgnoreCase(enc)) { String charset = StringUtils.trimToNull(attributes.getValue("charset")); if (charset == null) charset = "UTF-8"; value = Xml.decode(charset, attributes.getValue("value")); } else { value = attributes.getValue("value"); } // deal with multiple valued lists if ("list".equals(attributes.getValue("list"))) { // accumulate multiple values in a list Object current = props.get(name); // if we don't have a value yet, make a list to // hold // this one if (current == null) { List values = new ArrayList(); props.put(name, values); values.add(value); } // if we do and it's a list, add this one else if (current instanceof List) { ((List) current).add(value); } // if it's not a list, it's wrong! else { log.warn("construct(el): value set not a list: " + name); } } else { props.put(name, value); } } else if ("submission".equals(qName)) { setId(attributes.getValue("id")); setAssignment(StringUtils.trimToNull(attributes.getValue("assignment"))); setContext(StringUtils.trimToNull(attributes.getValue("context"))); setDatereturned(StringUtils.trimToNull(attributes.getValue("datereturned"))); setDatesubmitted(StringUtils.trimToNull(attributes.getValue("datesubmitted"))); setFeedbackcomment(StringUtils.trimToNull(attributes.getValue("feedbackcomment"))); if (StringUtils.trimToNull(attributes.getValue("feedbackcomment-html")) != null) { setFeedbackcomment_html( StringUtils.trimToNull(attributes.getValue("feedbackcomment-html"))); } else if (StringUtils.trimToNull(attributes.getValue("feedbackcomment-formatted")) != null) { setFeedbackcomment_html( StringUtils.trimToNull(attributes.getValue("feedbackcomment-formatted"))); } setFeedbacktext(StringUtils.trimToNull(attributes.getValue("feedbacktext"))); if (StringUtils.trimToNull(attributes.getValue("feedbacktext-html")) != null) { setFeedbacktext_html(StringUtils.trimToNull(attributes.getValue("feedbacktext-html"))); } else if (StringUtils.trimToNull(attributes.getValue("feedbacktext-formatted")) != null) { setFeedbacktext_html(StringUtils.trimToNull(attributes.getValue("feedbacktext-formatted"))); } // get number of decimals String factor = StringUtils.trimToNull(attributes.getValue("scaled_factor")); if (factor == null) { factor = String.valueOf(AssignmentConstants.DEFAULT_SCALED_FACTOR); } m_factor = Integer.valueOf(factor); // get grade String grade = StringUtils.trimToNull(attributes.getValue("scaled_grade")); if (grade == null) { grade = StringUtils.trimToNull(attributes.getValue("grade")); if (grade != null) { try { Integer.parseInt(grade); // for the grades in points, multiple those by factor grade = grade + factor.substring(1); } catch (Exception e) { log.warn(this + ":parse grade " + e.getMessage()); } } } setGrade(grade); setGraded(StringUtils.trimToNull(attributes.getValue("graded"))); setGradedBy(StringUtils.trimToNull(attributes.getValue("gradedBy"))); setGradereleased(StringUtils.trimToNull(attributes.getValue("gradereleased"))); setLastmod(StringUtils.trimToNull(attributes.getValue("lastmod"))); addElementsToList("feedbackattachment", feedbackattachments, attributes, false); addElementsToList("submittedattachment", submittedattachments, attributes, false); setPledgeflag(StringUtils.trimToNull(attributes.getValue("pledgeflag"))); setReturned(StringUtils.trimToNull(attributes.getValue("returned"))); setReviewReport(StringUtils.trimToNull(attributes.getValue("reviewReport"))); setReviewScore(StringUtils.trimToNull(attributes.getValue("reviewScore"))); setReviewStatus(StringUtils.trimToNull(attributes.getValue("reviewStatus"))); setSubmitted(StringUtils.trimToNull(attributes.getValue("submitted"))); // submittedtext and submittedtext_html are base-64 setSubmittedtext(StringUtils.trimToNull(attributes.getValue("submittedtext"))); setSubmittedtext_html(StringUtils.trimToNull(attributes.getValue("submittedtext-html"))); setSubmitterId(StringUtils.trimToNull(attributes.getValue("submitterid"))); addElementsToList("submitter", submitters, attributes, false); addElementsToList("log", submissionLog, attributes, false); addElementsToList("grade", grades, attributes, false); } } }); }
From source file:org.sakaiproject.content.impl.serialize.impl.conversion.SAXSerializableCollectionAccess.java
/** * @param xml/* w w w . j av a 2 s . c o m*/ */ public void parse(String xml) throws Exception { Reader r = new StringReader(xml); InputSource ss = new InputSource(r); SAXParser p = null; if (parserFactory == null) { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(false); parserFactory.setValidating(false); } try { p = parserFactory.newSAXParser(); } catch (ParserConfigurationException e) { throw new SAXException("Failed to get a parser ", e); } final Map<String, Object> props = new HashMap<String, Object>(); saxSerializableProperties.setSerializableProperties(props); p.parse(ss, new DefaultHandler() { /* * (non-Javadoc) * * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if ("property".equals(qName)) { String name = attributes.getValue("name"); String enc = StringUtils.trimToNull(attributes.getValue("enc")); String value = null; if ("BASE64".equalsIgnoreCase(enc)) { String charset = StringUtils.trimToNull(attributes.getValue("charset")); if (charset == null) charset = "UTF-8"; value = Xml.decode(charset, attributes.getValue("value")); } else { value = attributes.getValue("value"); } // deal with multiple valued lists if ("list".equals(attributes.getValue("list"))) { // accumulate multiple values in a list Object current = props.get(name); // if we don't have a value yet, make a list to // hold // this one if (current == null) { List values = new Vector(); props.put(name, values); values.add(value); } // if we do and it's a list, add this one else if (current instanceof List) { ((List) current).add(value); } // if it's not a list, it's wrong! else { log.warn("construct(el): value set not a list: " + name); } } else { props.put(name, value); } } else if ("collection".equals(qName)) { id = attributes.getValue("id"); resourceType = ResourceType.TYPE_FOLDER; // extract access accessMode = AccessMode.INHERITED; String access_mode = attributes.getValue("sakai:access_mode"); if (access_mode != null && !access_mode.trim().equals("")) { accessMode = AccessMode.fromString(access_mode); } if (accessMode == null || AccessMode.SITE == accessMode) { accessMode = AccessMode.INHERITED; } // extract release date // m_releaseDate = TimeService.newTime(0); String date0 = attributes.getValue("sakai:release_date"); if (date0 != null && !date0.trim().equals("")) { releaseDate = conversionTimeService.newTimeGmt(date0); if (releaseDate.getTime() <= START_OF_TIME) { releaseDate = null; } } // extract retract date // m_retractDate = TimeService.newTimeGmt(9999,12, // 31, 23, 59, 59, 999); String date1 = attributes.getValue("sakai:retract_date"); if (date1 != null && !date1.trim().equals("")) { retractDate = conversionTimeService.newTimeGmt(date1); if (retractDate.getTime() >= END_OF_TIME) { retractDate = null; } } String shidden = attributes.getValue("sakai:hidden"); hidden = shidden != null && !shidden.trim().equals("") && !Boolean.FALSE.toString().equalsIgnoreCase(shidden); } else if ("sakai:authzGroup".equals(qName)) { String groupRef = attributes.getValue("sakai:group_name"); if (groupRef != null) { group.add(groupRef); } } else if ("rightsAssignment".equals(qName)) { } else if ("properties".equals(qName)) { } else { log.warn("Unexpected Element " + qName); } } }); }
From source file:org.sakaiproject.content.impl.serialize.impl.conversion.SAXSerializableResourceAccess.java
/** * @param xml//from w w w.j a v a 2 s. co m * @throws EntityParseException */ public void parse(String xml) throws Exception { Reader r = new StringReader(xml); InputSource ss = new InputSource(r); SAXParser p = null; if (parserFactory == null) { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(false); parserFactory.setValidating(false); } try { p = parserFactory.newSAXParser(); } catch (ParserConfigurationException e) { throw new SAXException("Failed to get a parser ", e); } final Map<String, Object> props = new HashMap<String, Object>(); saxSerializableProperties.setSerializableProperties(props); p.parse(ss, new DefaultHandler() { /* * (non-Javadoc) * * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, * java.lang.String, java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName == null) { // will be ignored } else { qName = qName.trim(); } if ("property".equalsIgnoreCase(qName)) { String name = attributes.getValue("name"); String enc = StringUtils.trimToNull(attributes.getValue("enc")); String value = null; if ("BASE64".equalsIgnoreCase(enc)) { String charset = StringUtils.trimToNull(attributes.getValue("charset")); if (charset == null) charset = "UTF-8"; value = Xml.decode(charset, attributes.getValue("value")); } else { value = attributes.getValue("value"); } // deal with multiple valued lists if ("list".equals(attributes.getValue("list"))) { // accumulate multiple values in a list Object current = props.get(name); // if we don't have a value yet, make a list to // hold // this one if (current == null) { List values = new Vector(); props.put(name, values); values.add(value); } // if we do and it's a list, add this one else if (current instanceof List) { ((List) current).add(value); } // if it's not a list, it's wrong! else { log.warn("construct(el): value set not a list: " + name); } } else { props.put(name, value); } } else if ("resource".equalsIgnoreCase(qName)) { id = attributes.getValue("id"); contentType = StringUtils.trimToNull(attributes.getValue("content-type")); contentLength = 0; try { contentLength = Integer.parseInt(attributes.getValue("content-length")); } catch (Exception ignore) { } resourceType = StringUtils.trimToNull(attributes.getValue("resource-type")); if (resourceType == null) { resourceType = ResourceType.TYPE_UPLOAD; } String enc = StringUtils.trimToNull(attributes.getValue("body")); if (enc != null) { byte[] decoded = null; try { decoded = Base64.decodeBase64(enc.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { log.error(e); } body = new byte[(int) contentLength]; System.arraycopy(decoded, 0, body, 0, (int) contentLength); } filePath = StringUtils.trimToNull(attributes.getValue("filePath")); accessMode = AccessMode.INHERITED; String access_mode = attributes.getValue("sakai:access_mode"); if (access_mode != null && !access_mode.trim().equals("")) { accessMode = AccessMode.fromString(access_mode); } if (accessMode == null || AccessMode.SITE == accessMode) { accessMode = AccessMode.INHERITED; } String shidden = attributes.getValue("sakai:hidden"); hidden = shidden != null && !shidden.trim().equals("") && !Boolean.FALSE.toString().equalsIgnoreCase(shidden); if (hidden) { releaseDate = null; retractDate = null; } else { // extract release date String date0 = attributes.getValue("sakai:release_date"); if (date0 != null && !date0.trim().equals("")) { releaseDate = conversionTimeService.newTimeGmt(date0); if (releaseDate.getTime() <= START_OF_TIME) { releaseDate = null; } } // extract retract date String date1 = attributes.getValue("sakai:retract_date"); if (date1 != null && !date1.trim().equals("")) { retractDate = conversionTimeService.newTimeGmt(date1); if (retractDate.getTime() >= END_OF_TIME) { retractDate = null; } } } } else if ("sakai:authzGroup".equalsIgnoreCase(qName)) { if (group == null) { group = new ArrayList<String>(); } group.add(attributes.getValue("sakai:group_name")); } else if ("properties".equalsIgnoreCase(qName)) { } else if ("members".equalsIgnoreCase(qName)) { // ignore } else if ("member".equalsIgnoreCase(qName)) { // ignore } else { log.warn("Unexpected Element \"" + qName + "\""); } } }); }
From source file:org.sakaiproject.util.StorageUtils.java
/** * SAX Process a Reader using the Default handler * @param in/* w w w . jav a 2 s. co m*/ * @param dh * @throws SAXException * @throws IOException */ public static void processReader(Reader in, DefaultHandler dh) throws SAXException, IOException { InputSource ss = new InputSource(in); SAXParser p = null; if (parserFactory == null) { parserFactory = SAXParserFactory.newInstance(); parserFactory.setNamespaceAware(false); parserFactory.setValidating(false); } try { p = parserFactory.newSAXParser(); } catch (ParserConfigurationException e) { throw new SAXException("Failed to get a parser ", e); } p.parse(ss, dh); }