001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Sam
028: */
029:
030: package com.caucho.quercus.lib.dom;
031:
032: import java.io.IOException;
033:
034: import com.caucho.quercus.QuercusModuleException;
035: import com.caucho.quercus.UnimplementedException;
036: import com.caucho.quercus.env.DefaultValue;
037: import com.caucho.quercus.env.Env;
038: import com.caucho.quercus.env.StringValue;
039: import com.caucho.quercus.lib.simplexml.SimpleXMLElement;
040: import com.caucho.quercus.module.AbstractQuercusModule;
041: import com.caucho.vfs.Path;
042: import com.caucho.vfs.StringPath;
043:
044: public class QuercusDOMModule extends AbstractQuercusModule {
045: public static final int XML_ELEMENT_NODE = 1;
046: public static final int XML_ATTRIBUTE_NODE = 2;
047: public static final int XML_TEXT_NODE = 3;
048: public static final int XML_CDATA_SECTION_NODE = 4;
049: public static final int XML_ENTITY_REF_NODE = 5;
050: public static final int XML_ENTITY_NODE = 6;
051: public static final int XML_PI_NODE = 7;
052: public static final int XML_COMMENT_NODE = 8;
053: public static final int XML_DOCUMENT_NODE = 9;
054: public static final int XML_DOCUMENT_TYPE_NODE = 10;
055: public static final int XML_DOCUMENT_FRAG_NODE = 11;
056: public static final int XML_NOTATION_NODE = 12;
057: public static final int XML_HTML_DOCUMENT_NODE = 13;
058: public static final int XML_DTD_NODE = 14;
059: public static final int XML_ELEMENT_DECL_NODE = 15;
060: public static final int XML_ATTRIBUTE_DECL_NODE = 16;
061: public static final int XML_ENTITY_DECL_NODE = 17;
062: public static final int XML_NAMESPACE_DECL_NODE = 18;
063:
064: public static final int XML_ATTRIBUTE_CDATA = 1;
065: public static final int XML_ATTRIBUTE_ID = 2;
066: public static final int XML_ATTRIBUTE_IDREF = 3;
067: public static final int XML_ATTRIBUTE_IDREFS = 4;
068: public static final int XML_ATTRIBUTE_ENTITY = 5;
069: public static final int XML_ATTRIBUTE_NMTOKEN = 7;
070: public static final int XML_ATTRIBUTE_NMTOKENS = 8;
071: public static final int XML_ATTRIBUTE_ENUMERATION = 9;
072: public static final int XML_ATTRIBUTE_NOTATION = 10;
073:
074: public static final int DOM_INDEX_SIZE_ERR = 1;
075: public static final int DOMSTRING_SIZE_ERR = 2;
076: public static final int DOM_HIERARCHY_REQUEST_ERR = 3;
077: public static final int DOM_WRONG_DOCUMENT_ERR = 4;
078: public static final int DOM_INVALID_CHARACTER_ERR = 5;
079: public static final int DOM_NO_DATA_ALLOWED_ERR = 6;
080: public static final int DOM_NO_MODIFICATION_ALLOWED_ERR = 7;
081: public static final int DOM_NOT_FOUND_ERR = 8;
082: public static final int DOM_NOT_SUPPORTED_ERR = 9;
083: public static final int DOM_INUSE_ATTRIBUTE_ERR = 10;
084: public static final int DOM_INVALID_STATE_ERR = 11;
085: public static final int DOM_SYNTAX_ERR = 12;
086: public static final int DOM_INVALID_MODIFICATION_ERR = 13;
087: public static final int DOM_NAMESPACE_ERR = 14;
088: public static final int DOM_INVALID_ACCESS_ERR = 15;
089: public static final int DOM_VALIDATION_ERR = 16;
090:
091: public static DOMElement dom_import_simplexml(Env env,
092: SimpleXMLElement node) {
093: DOMDocument document = DOMDocument
094: .__construct(env, "1.0", null);
095:
096: StringValue xml = node.asXML(env);
097: document.loadXML(env, xml, DefaultValue.DEFAULT);
098:
099: return document.getDocumentElement();
100: }
101: }
|