sk.uniba.euromath.document
Class DocumentFactory

java.lang.Object
  extended by sk.uniba.euromath.document.DocumentFactory

public final class DocumentFactory
extends Object

Deserializes the document.

Author:
Martin Vysny

Constructor Summary
DocumentFactory()
          Constructs the factory.
 
Method Summary
 XMLAccess loadDocument(IPath resource)
           Loads an XML from specified location and prepares it for editing.
 XMLAccess loadDocument(String url)
          Loads an XML from specified location and prepares it for editing.
 XMLAccess loadDocument(URL url)
          Loads an XML from specified location and prepares it for editing.
 XMLAccess newDocument(Document doc, URLDir root, String fileName)
          Initializes an XMLAccess instance from given DOM document.
 XMLAccess newDocument(URLDir root, String fileName)
          Creates XMLAccess instance with empty document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentFactory

public DocumentFactory()
Constructs the factory.

Method Detail

loadDocument

public XMLAccess loadDocument(IPath resource)
                       throws SAXException,
                              IOException,
                              DocumentException

Loads an XML from specified location and prepares it for editing. The steps that has to be taken (in this order) to load document properly:

These steps should be taken to load document properly:

  1. Obtain an XMLAccess instance.
  2. Optional step: Load local schemas with the XMLAccess.loadLocalSchema() function.
  3. Call XMLAccess.loadGlobalSchemas() to ensure that for each namespace there is schema loaded.
  4. Call XMLAccess.validate() to validate the document.
  5. Fill Selector to select transformers for all namespaces.
  6. Open view on document via the XMLAccess.openView() function.
  7. Get transformed (presentation) document via the XMLAccess.getTransformedReader() reader and display it.

Parameters:
resource - the eclipse resource representing the xml file.
Returns:
XMLAccess representation of document.
Throws:
SAXException - when error occurs during document deserialization
IOException - when i/o error occurs
DocumentException - when error occurs during document processing

loadDocument

public XMLAccess loadDocument(String url)
                       throws SAXException,
                              IOException,
                              DocumentException
Loads an XML from specified location and prepares it for editing.

Parameters:
url - the URL address representing the location of the XML document.
Returns:
XMLAccess representation of document.
Throws:
SAXException - when error occurs during document deserialization
IOException - when i/o error occurs
DocumentException - when error occurs during document processing

loadDocument

public XMLAccess loadDocument(URL url)
                       throws SAXException,
                              IOException,
                              DocumentException
Loads an XML from specified location and prepares it for editing.

Parameters:
url - the URL address representing the location of the XML document.
Returns:
XMLAccess representation of document.
Throws:
SAXException - when error occurs during document deserialization
IOException - when i/o error occurs
DocumentException - when error occurs during document processing

newDocument

public XMLAccess newDocument(Document doc,
                             URLDir root,
                             String fileName)
                      throws DocumentException
Initializes an XMLAccess instance from given DOM document.

Parameters:
doc - document to initialize.
root - URL pointing to the directory where the document is located.
fileName - the name of the document file, including the extension.
Returns:
initialized instance of XMLAccess.
Throws:
DocumentException - when error occurs during document processing

newDocument

public XMLAccess newDocument(URLDir root,
                             String fileName)
                      throws DocumentException
Creates XMLAccess instance with empty document.

Parameters:
root - URL pointing to the directory where the document is located.
fileName - the name of the document file, including the extension.
Returns:
initialized instance of XMLAccess.
Throws:
DocumentException - when error occurs during document processing


Copyright © 2003-2006 null. All Rights Reserved.