001: /**
002: * org/ozone-db/xml/XMLDocument.java
003: *
004: * The contents of this file are subject to the OpenXML Public
005: * License Version 1.0; you may not use this file except in compliance
006: * with the License. You may obtain a copy of the License at
007: * http://www.openxml.org/license.html
008: *
009: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
010: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
011: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
012: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
013: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
014: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
015: *
016: * The Initial Developer of this code under the License is Assaf Arkin.
017: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
018: * All Rights Reserved.
019: */
020:
021: /**
022: * Changes for Persistent DOM running with ozone are
023: * Copyright 1999 by SMB GmbH. All rights reserved.
024: */package org.ozoneDB.xml;
025:
026: import org.w3c.dom.*;
027: import org.ozoneDB.xml.dom.*;
028:
029: /**
030: * Base class for user XML document. In addition to several API extensions, user
031: * XML documents can be used to map XML documents directly into application data
032: * structures, with the aid of user elements ({@link XMLElement}).
033: * <P>
034: * {@link XMLDocument} extends the DOM {@link org.w3c.dom.Document} with the
035: * following methods:
036: * <UL>
037: * <LI>{@link #setReadOnly} renders a full document read-only preventing any
038: * changes to it's documet contents
039: * <LI>{@link #registerElement} associates tag names with user element classes
040: * that derive from {@link XMLElement}
041: * <LI>{@link #useElementFactory} invokes an external element factory to create
042: * application elements
043: * </UL>
044: * <P>
045: * Documents of specific type can be created safely by passing the document class
046: * to {@link DOMFactory#createDocument}. They are supported by the built in XML
047: * parser, printer and processor. User documents are also supported by {@link
048: * org.openxml.source.Source} through use of the <TT>docClass</TT> property.
049: * <P>
050: * A user document derived from {@link XMLDocument} must be declared public and
051: * the constructor must be public. User elements should be registered in the
052: * constructor, and read-only status should be obeyed by calling {@link
053: * XMLDocument#isReadOnly}.
054: *
055: *
056: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
057: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
058: * @see org.w3c.dom.Document
059: * @see XMLElement
060: * @see XMLCollection
061: * @see XMLElementFactory
062: * @deprecated Alternative API will be introduced in OpenXML 1.1
063: */
064: public class XMLDocument extends DocumentImpl implements
065: XMLDocumentProxy {
066:
067: /**
068: * Default constructor.
069: */
070: public XMLDocument() {
071: super ();
072: // this.registerElement( "MyTag", MyElement.class );
073: }
074:
075: public Object clone() {
076: XMLDocumentProxy clone = null;
077: try {
078: clone = (XMLDocumentProxy) database().createObject(
079: XMLDocument.class.getName());
080: cloneInto((NodeProxy) clone, true);
081: } catch (Exception except) {
082: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
083: except.getMessage());
084: }
085: return clone;
086: }
087:
088: public Node cloneNode(boolean deep) {
089: XMLDocumentProxy clone = null;
090: try {
091: clone = (XMLDocumentProxy) database().createObject(
092: XMLDocument.class.getName());
093: cloneInto((NodeProxy) clone, deep);
094: } catch (Exception except) {
095: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
096: except.getMessage());
097: }
098: return clone;
099: }
100: }
|