Package org.dom4j.io

Examples of org.dom4j.io.SAXReader


     * @throws XMLSchemaFileImportException
     *      if an error occurs when importing the schema
     */
    public static Schema[] getSchemas( InputStream inputStream, String path ) throws XMLSchemaFileImportException
    {
        SAXReader reader = new SAXReader();
        Document document = null;
        try
        {
            document = reader.read( inputStream );
        }
        catch ( DocumentException e )
        {
            throw new XMLSchemaFileImportException( NLS.bind( Messages
                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$
View Full Code Here


     * @throws XMLSchemaFileImportException
     *      if an error occurs when importing the schema
     */
    public static Schema getSchema( InputStream inputStream, String path ) throws XMLSchemaFileImportException
    {
        SAXReader reader = new SAXReader();
        Document document = null;
        try
        {
            document = reader.read( inputStream );
        }
        catch ( DocumentException e )
        {
            throw new XMLSchemaFileImportException( NLS.bind( Messages
                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$
View Full Code Here

     * @throws XMLSchemaFileImportException
     */
    public static SchemaFileType getSchemaFileType( InputStream inputStream, String path )
        throws XMLSchemaFileImportException
    {
        SAXReader reader = new SAXReader();
        Document document = null;
        try
        {
            document = reader.read( inputStream );
        }
        catch ( DocumentException e )
        {
            throw new XMLSchemaFileImportException( NLS.bind( Messages
                .getString( "XMLSchemaFileImporter.NotReadCorrectly" ), new String[] { path } ), e ); //$NON-NLS-1$
View Full Code Here

        }

        @Override
        protected void runTest() throws Exception {
            jct.createContext().compileScript(jelly);
            Document dom = new SAXReader().read(jelly);
            checkLabelFor(dom);
            if (requirePI) {
                ProcessingInstruction pi = dom.processingInstruction("jelly");
                if (pi==null || !pi.getText().contains("escape-by-default"))
                    throw new AssertionError("<?jelly escape-by-default='true'?> is missing");
View Full Code Here

public class UserSchemaValidator {
    private Document doc;
    private String schema;
   
    UserSchemaValidator(FileItem usersFile, String schemaFile) throws DocumentException, IOException {
        SAXReader reader = new SAXReader();
        doc = reader.read(usersFile.getInputStream());
       
        URL schemaURL = this.getClass().getClassLoader().getResource(schemaFile);
        schema = schemaURL.toExternalForm();
    }
View Full Code Here

   * @throws DocumentException
   *             if an error occurs during parsing.
   */
  public List<String> importUserData(FileItem file, String previousDomain)
      throws DocumentException, IOException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(file.getInputStream());
    return importUsers(document, previousDomain);
  }
View Full Code Here

   */
  public Element get(String username, Element data) {
    if (enabled) {
      Connection con = null;
      PreparedStatement pstmt = null;
      SAXReader xmlReader = null;
      try {
        // Get a sax reader from the pool
        xmlReader = xmlReaders.take();
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(LOAD_PRIVATE);
        pstmt.setString(1, username);
        pstmt.setString(2, data.getNamespaceURI());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
          data.clearContent();
          String result = rs.getString(1).trim();
          Document doc = xmlReader.read(new StringReader(result));
          data = doc.getRootElement();
        }
        rs.close();
      } catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
View Full Code Here

    Element data = DocumentHelper.createElement(qName);
   
    if (enabled) {
      Connection con = null;
      PreparedStatement pstmt = null;
      SAXReader xmlReader = null;
      try {
        // Get a sax reader from the pool
        xmlReader = xmlReaders.take();
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(LOAD_ALL_PRIVATE);
        pstmt.setString(1, username);
       
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
          String result = rs.getString(1).trim();
          Document doc = xmlReader.read(new StringReader(result));
          data.add(doc.getRootElement());
        }
        rs.close();
      } catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
View Full Code Here

  public void start() throws IllegalStateException {
    super.start();
    // Initialize the pool of sax readers
    for (int i = 0; i < 10; i++) {
      SAXReader xmlReader = new SAXReader();
      xmlReader.setEncoding("UTF-8");
      xmlReaders.add(xmlReader);
    }
    // Add this module as a user event listener so we can delete
    // all user properties when a user is deleted
    UserEventDispatcher.addListener(this);
View Full Code Here

        // Call parser.parse
        SimpleParser parser = new SimpleParser(new ParserPolicy(), true);
        ParsedDatum parsedDatum = parser.parse(fetchedDatum);
       
        // Now take the resulting HTML, process it using Dom4J
        SAXReader reader = new SAXReader(new Parser());
        reader.setEncoding("UTF-8");
        String htmlWithMarkup = parsedDatum.getParsedText();
        Document doc = reader.read(new StringInputStream(htmlWithMarkup));
       
        // We have to do helicopter stunts since HTML has a global namespace on it, set
        // at the <html> element level.
        XPath xpath = DocumentHelper.createXPath("/xhtml:html/xhtml:body/xhtml:p");
        Map<String, String> namespaceUris = new HashMap<String, String>();
View Full Code Here

TOP

Related Classes of org.dom4j.io.SAXReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.