/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2002,2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* ElementNSImpl inherits from ElementImpl and adds namespace support.
* <P>
* The qualified name is the node name, and we store localName which is also
* used in all queries. On the other hand we recompute the prefix when
* necessary.
*
* @xerces.internal
*
* @author Elena litani, IBM
* @author Neeraj Bajaj, Sun Microsystems
* @version $Id: ElementNSImpl.java,v 1.7 2010-11-01 04:39:39 joehw Exp $
*/
public class ElementNSImpl
extends ElementImpl {
//
// Constants
//
/** Serialization version. */
//
// Data
//
/** DOM2: Namespace URI. */
/** DOM2: localName. */
/** DOM3: type information */
// REVISIT: we are losing the type information in DOM during serialization
protected ElementNSImpl() {
super();
}
/**
* DOM2: Constructor for Namespace implementation.
*/
throws DOMException
{
super(ownerDocument, qualifiedName);
}
// DOM Level 3: namespace URI is never empty string.
this.namespaceURI = namespaceURI;
if (namespaceURI != null) {
//convert the empty string to 'null'
}
//NAMESPACE_ERR:
//1. if the qualified name is 'null' it is malformed.
//2. or if the qualifiedName is null and the namespaceURI is different from null,
// We dont need to check for namespaceURI != null, if qualified name is null throw DOMException.
"NAMESPACE_ERR",
null);
}
else{
}
if (colon1 < 0) {
// there is no prefix
if (ownerDocument.errorChecking) {
&& (namespaceURI == null
"NAMESPACE_ERR",
null);
}
}
}//there is a prefix
else {
//NAMESPACE_ERR:
//1. if the qualifiedName has a prefix and the namespaceURI is null,
//2. or if the qualifiedName has a prefix that is "xml" and the namespaceURI
//is different from " http://www.w3.org/XML/1998/namespace"
if (ownerDocument.errorChecking) {
if( namespaceURI == null || ( prefix.equals("xml") && !namespaceURI.equals(NamespaceContext.XML_URI) )){
"NAMESPACE_ERR",
null);
}
}
}
}
// when local name is known
throws DOMException
{
super(ownerDocument, qualifiedName);
this.namespaceURI = namespaceURI;
}
// for DeferredElementImpl
super(ownerDocument, value);
}
// Support for DOM Level 3 renameNode method.
// Note: This only deals with part of the pb. CoreDocumentImpl
// does all the work.
{
if (needsSyncData()) {
}
this.name = qualifiedName;
}
/**
* NON-DOM: resets this node and sets specified values for the node
*
* @param ownerDocument
* @param namespaceURI
* @param qualifiedName
* @param localName
*/
// remove children first
firstChild = null;
nextSibling = null;
// set owner document
attributes = null;
super.flags = 0;
// synchronizeData will initialize attributes
needsSyncData(true);
super.name = qualifiedName;
this.namespaceURI = namespaceURI;
}
//
// Node methods
//
//
//DOM2: Namespace methods.
//
/**
* Introduced in DOM Level 2. <p>
*
* The namespace URI of this node, or null if it is unspecified.<p>
*
* This is not a computed value that is the result of a namespace lookup based on
* an examination of the namespace declarations in scope. It is merely the
* namespace URI given at creation time.<p>
*
* For nodes created with a DOM Level 1 method, such as createElement
* from the Document interface, this is null.
* @since WD-DOM-Level-2-19990923
*/
{
if (needsSyncData()) {
}
return namespaceURI;
}
/**
* Introduced in DOM Level 2. <p>
*
* The namespace prefix of this node, or null if it is unspecified. <p>
*
* For nodes created with a DOM Level 1 method, such as createElement
* from the Document interface, this is null. <p>
*
* @since WD-DOM-Level-2-19990923
*/
{
if (needsSyncData()) {
}
}
/**
* Introduced in DOM Level 2. <p>
*
* Note that setting this attribute changes the nodeName attribute, which holds the
* qualified name, as well as the tagName and name attributes of the Element
* and Attr interfaces, when applicable.<p>
*
* @param prefix The namespace prefix of this node, or null(empty string) if it is unspecified.
*
* @exception INVALID_CHARACTER_ERR
* Raised if the specified
* prefix contains an invalid character.
* @exception DOMException
* @since WD-DOM-Level-2-19990923
*/
throws DOMException
{
if (needsSyncData()) {
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
msg);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null);
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null);
}
}
}
}
// update node name with new qualifiedName
}
else {
}
}
/**
* Introduced in DOM Level 2. <p>
*
* Returns the local part of the qualified name of this node.
* @since WD-DOM-Level-2-19990923
*/
{
if (needsSyncData()) {
}
return localName;
}
/**
* DOM Level 3 WD - Experimental.
* Retrieve baseURI
*/
if (needsSyncData()) {
}
// Absolute base URI is computed according to XML Base (http://www.w3.org/TR/xmlbase/#granularity)
// 1. the base URI specified by an xml:base attribute on the element, if one exists
if (attributes != null) {
try {
}
// This may be a relative URI.
// Start from the base URI of the parent, or if this node has no parent, the owner node.
// Make any parentURI into a URI object to use with the URI(URI, String) constructor.
if (parentBaseURI != null) {
try {
}
// This should never happen: parent should have checked the URI and returned null if invalid.
return null;
}
return uri;
}
// REVISIT: what should happen in this case?
return null;
}
return uri;
}
}
}
//2.the base URI of the element's parent element within the document or external entity,
//if one exists
//base URI of parent element is not null
if(parentElementBaseURI != null){
try {
//return valid absolute base URI
}
// REVISIT: what should happen in this case?
return null;
}
}
//3. the base URI of the document entity or external entity containing the element
try {
//return valid absolute base URI
}
// REVISIT: what should happen in this case?
return null;
}
}
return null;
}
/**
* @see org.w3c.dom.TypeInfo#getTypeName()
*/
if (type instanceof XSSimpleTypeDecl) {
} else if (type instanceof XSComplexTypeDecl) {
}
}
return null;
}
/**
* @see org.w3c.dom.TypeInfo#getTypeNamespace()
*/
return type.getNamespace();
}
return null;
}
/**
* Introduced in DOM Level 2. <p>
* Checks if a type is derived from another by restriction. See:
* http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom
*
* @param ancestorNS
* The namspace of the ancestor type declaration
* @param ancestorName
* The name of the ancestor type declaration
* @param type
* The reference type definition
*
* @return boolean True if the type is derived by restriciton for the
* reference type
*/
int derivationMethod) {
if(needsSyncData()) {
}
if (type instanceof XSSimpleTypeDecl) {
} else if (type instanceof XSComplexTypeDecl) {
}
}
return false;
}
/**
* NON-DOM: setting type used by the DOM parser
* @see NodeImpl#setReadOnly
*/
}
}