You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jk...@apache.org on 2001/11/29 16:45:52 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm DOM2DTMdefaultNamespaceDeclarationNode.java DOM2DTM.java
jkesselm 01/11/29 07:45:52
Modified: java/src/org/apache/xml/dtm/ref/dom2dtm DOM2DTM.java
Added: java/src/org/apache/xml/dtm/ref/dom2dtm
DOM2DTMdefaultNamespaceDeclarationNode.java
Log:
Moved default namespace declaration node object out of its "inner
class" status, since I think I want to perform an instanceof test on it.
Revision Changes Path
1.24 +6 -57 xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
Index: DOM2DTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DOM2DTM.java 2001/11/26 22:08:28 1.23
+++ DOM2DTM.java 2001/11/29 15:45:52 1.24
@@ -597,7 +597,10 @@
// have to synthesize one. You can think of this as
// being a default attribute defined by the XML
// Namespaces spec rather than by the DTD.
- attrIndex=addNode(new defaultNamespaceDeclarationNode((Element)next,"xml",NAMESPACE_DECL_NS),
+ attrIndex=addNode(new DOM2DTMdefaultNamespaceDeclarationNode(
+ (Element)next,"xml",NAMESPACE_DECL_NS,
+ makeNodeHandle(((attrIndex==NULL)?nextindex:attrIndex)+1)
+ ),
nextindex,attrIndex,NULL);
m_firstch.setElementAt(DTM.NULL,attrIndex);
m_processedFirstElement=true;
@@ -1713,60 +1716,6 @@
{
return null;
}
-
- //---------------------------------------------------------------------
- /** This is a kluge to let us shove a declaration for xml: into the model.
- * Basically, it creates a proxy node in DOM space to carry the
- * additional information. This is _NOT_ a full DOM implementation,
- * and shouldn't be one since it sits alongside the DOM rather than
- * becoming part of the DOM model.
- *
- * %REVIEW% An alternative solution would be to create the node _only_
- * in DTM space, but given how DOM2DTM is currently written I think
- * this is simplest.
- */
- class defaultNamespaceDeclarationNode implements Attr
- {
- final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
-
- Element pseudoparent;
- String prefix,uri;
- defaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri)
- {
- this.pseudoparent=pseudoparent;
- this.prefix=prefix;
- this.uri=uri;
- }
- public String getNodeName() {return "xmlns:"+prefix;}
- public String getName() {return getNodeName();}
- public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
- public String getPrefix() {return prefix;}
- public String getLocalName() {return prefix;}
- public String getNodeValue() {return uri;}
- public String getValue() {return uri;}
- public Element getOwnerElement() {return pseudoparent;}
-
- public boolean isSupported(String feature, String version) {return false;}
- public boolean hasChildNodes() {return false;}
- public boolean hasAttributes() {return false;}
- public Node getParentNode() {return null;}
- public Node getFirstChild() {return null;}
- public Node getLastChild() {return null;}
- public Node getPreviousSibling() {return null;}
- public Node getNextSibling() {return null;}
- public boolean getSpecified() {return false;}
- public void normalize() {return;}
- public NodeList getChildNodes() {return null;}
- public NamedNodeMap getAttributes() {return null;}
- public short getNodeType() {return Node.ATTRIBUTE_NODE;}
- public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
- public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
- public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
- }
}
+
+
1.1 xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java
Index: DOM2DTMdefaultNamespaceDeclarationNode.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999,2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xml.dtm.ref.dom2dtm;
import org.w3c.dom.*;
import org.apache.xml.dtm.ref.dom2dtm.DOM2DTM;
import org.apache.xml.dtm.ref.*;
import org.apache.xml.dtm.*;
/** This is a kluge to let us shove a declaration for xml: into the
* DOM2DTM model. Basically, it creates a proxy node in DOM space to
* carry the additional information. This is _NOT_ a full DOM
* implementation, and shouldn't be one since it sits alongside the
* DOM rather than becoming part of the DOM model.
*
* (This used to be an internal class within DOM2DTM. Moved out because
* I need to perform an instanceof operation on it to support a temporary
* workaround in DTMManagerDefault.)
*
* %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
* there isn't a single root element? I think this fails that case...
*
* %REVIEW% An alternative solution would be to create the node _only_
* in DTM space, but given how DOM2DTM is currently written I think
* this is simplest.
* */
public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr
{
final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
Element pseudoparent;
String prefix,uri;
int handle;
DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
{
this.pseudoparent=pseudoparent;
this.prefix=prefix;
this.uri=uri;
this.handle=handle;
}
public String getNodeName() {return "xmlns:"+prefix;}
public String getName() {return getNodeName();}
public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
public String getPrefix() {return prefix;}
public String getLocalName() {return prefix;}
public String getNodeValue() {return uri;}
public String getValue() {return uri;}
public Element getOwnerElement() {return pseudoparent;}
public boolean isSupported(String feature, String version) {return false;}
public boolean hasChildNodes() {return false;}
public boolean hasAttributes() {return false;}
public Node getParentNode() {return null;}
public Node getFirstChild() {return null;}
public Node getLastChild() {return null;}
public Node getPreviousSibling() {return null;}
public Node getNextSibling() {return null;}
public boolean getSpecified() {return false;}
public void normalize() {return;}
public NodeList getChildNodes() {return null;}
public NamedNodeMap getAttributes() {return null;}
public short getNodeType() {return Node.ATTRIBUTE_NODE;}
public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
/** Non-DOM method, part of the temporary kluge
* %REVIEW% This would be a pruning problem, but since it will always be
* added to the root element and we prune on elements, we shouldn't have
* to worry.
*/
public int getHandleOfNode()
{
return handle;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org