001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005: *
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common Development
009: * and Distribution License("CDDL") (collectively, the "License"). You
010: * may not use this file except in compliance with the License. You can obtain
011: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
013: * language governing permissions and limitations under the License.
014: *
015: * When distributing the software, include this License Header Notice in each
016: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017: * Sun designates this particular file as subject to the "Classpath" exception
018: * as provided by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the License
020: * Header, with the fields enclosed by brackets [] replaced by your own
021: * identifying information: "Portions Copyrighted [year]
022: * [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * If you wish your version of this file to be governed by only the CDDL or
027: * only the GPL Version 2, indicate your decision by adding "[Contributor]
028: * elects to include this software in this distribution under the [CDDL or GPL
029: * Version 2] license." If you don't indicate a single choice of license, a
030: * recipient has the option to distribute your version of this file under
031: * either the CDDL, the GPL Version 2 or to extend the choice of license to
032: * its licensees as provided above. However, if you add GPL Version 2 code
033: * and therefore, elected the GPL Version 2 license, then the option applies
034: * only if the new code is made subject to such option by the copyright
035: * holder.
036: */
037: package oracle.toplink.essentials.platform.xml;
038:
039: import java.net.URL;
040: import org.w3c.dom.Document;
041: import org.w3c.dom.Node;
042: import org.w3c.dom.NodeList;
043: import org.w3c.dom.Text;
044: import org.xml.sax.ErrorHandler;
045:
046: public interface XMLPlatform {
047:
048: /**
049: * Creates a new document.
050: * @return the new document
051: * @throws XMLPlatformException
052: */
053: public Document createDocument() throws XMLPlatformException;
054:
055: /**
056: * Creates a new document with the specified public and system
057: * identifiers in the DOCTYPE, and adds a root element with the
058: * specified name.
059: * @param name the name of the root element
060: * publicIdentifier the public identifier
061: * systemIdentifier the system identifier
062: * @return the new document
063: * @throws XMLPlatformException
064: */
065: public Document createDocumentWithPublicIdentifier(String name,
066: String publicIdentifier, String systemIdentifier)
067: throws XMLPlatformException;
068:
069: /**
070: * Creates a new document with the specified system identifier in
071: * the DOCTYPE, and adds a root element with the specified name.
072: * @param name the name of the root element
073: * systemIdentifier the system identifier
074: * @return the new document
075: * @throws XMLPlatformException
076: */
077: public Document createDocumentWithSystemIdentifier(String name,
078: String systemIdentifier) throws XMLPlatformException;
079:
080: /**
081: * Check to see if the text node represents a whitespace node.
082: * @param text a potential whitespace node
083: * @return if the text node represents a whitespace node.
084: */
085: public boolean isWhitespaceNode(Text text);
086:
087: /**
088: * Return the namespace URI for the specified namespace prefix
089: * relative to the context node.
090: * @param contextNode the node to be looking for the namespace
091: * URI
092: * namespacePrefix the namespace prefix
093: * @return the namespace URI for the specified prefix
094: * @throws XMLPlatformException
095: */
096: public String resolveNamespacePrefix(Node contextNode,
097: String namespacePrefix) throws XMLPlatformException;
098:
099: /**
100: * Execute advanced XPath statements that are required for TopLink EIS.
101: * @param contextNode the node relative to which the XPath
102: * statement will be executed.
103: * xPath the XPath statement
104: * namespaceResolver used to resolve namespace prefixes
105: * to the corresponding namespace URI
106: * @return the XPath result
107: * @throws XMLPlatformException
108: */
109: public NodeList selectNodesAdvanced(Node contextNode, String xPath,
110: XMLNamespaceResolver xmlNamespaceResolver)
111: throws XMLPlatformException;
112:
113: /**
114: * Execute advanced XPath statements that are required for TopLink EIS.
115: * @param contextNode
116: * @param xPath
117: * @param xmlNamespaceResolver
118: * @return
119: * @throws XMLPlatformException
120: */
121: public Node selectSingleNodeAdvanced(Node contextNode,
122: String xPath, XMLNamespaceResolver xmlNamespaceResolver)
123: throws XMLPlatformException;
124:
125: /**
126: * Return a concrete implementation of the XML parser abstraction that is
127: * compatible with the XML Platform.
128: * @return a platform specific XML parser
129: */
130: public XMLParser newXMLParser();
131:
132: /**
133: * Return a concrete implementation of the XML transformer abstraction that is
134: * compatible with the XML Platform.
135: * @return a platform specific XML transfomer
136: */
137: public XMLTransformer newXMLTransformer();
138:
139: /**
140: * Validate the document against the XML Schema
141: * @param document the document to be validated
142: * xmlSchemaURL the XML Schema
143: * errorHandler a mechanism for selectively ignoring errors
144: * @return true if the document is valid, else false
145: * @throws XMLPlatformException
146: */
147: public boolean validateDocument(Document document,
148: URL xmlSchemaURL, ErrorHandler errorHandler)
149: throws XMLPlatformException;
150: }
|