1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package org.apache.xml.dtm.ref.dom2dtm;
  58. import org.w3c.dom.*;
  59. import org.apache.xml.dtm.ref.dom2dtm.DOM2DTM;
  60. import org.apache.xml.dtm.ref.*;
  61. import org.apache.xml.dtm.*;
  62. /** This is a kluge to let us shove a declaration for xml: into the
  63. * DOM2DTM model. Basically, it creates a proxy node in DOM space to
  64. * carry the additional information. This is _NOT_ a full DOM
  65. * implementation, and shouldn't be one since it sits alongside the
  66. * DOM rather than becoming part of the DOM model.
  67. *
  68. * (This used to be an internal class within DOM2DTM. Moved out because
  69. * I need to perform an instanceof operation on it to support a temporary
  70. * workaround in DTMManagerDefault.)
  71. *
  72. * %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
  73. * there isn't a single root element? I think this fails that case...
  74. *
  75. * %REVIEW% An alternative solution would be to create the node _only_
  76. * in DTM space, but given how DOM2DTM is currently written I think
  77. * this is simplest.
  78. * */
  79. public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr
  80. {
  81. final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
  82. Element pseudoparent;
  83. String prefix,uri,nodename;
  84. int handle;
  85. DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
  86. {
  87. this.pseudoparent=pseudoparent;
  88. this.prefix=prefix;
  89. this.uri=uri;
  90. this.handle=handle;
  91. this.nodename="xmlns:"+prefix;
  92. }
  93. public String getNodeName() {return nodename;}
  94. public String getName() {return nodename;}
  95. public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
  96. public String getPrefix() {return prefix;}
  97. public String getLocalName() {return prefix;}
  98. public String getNodeValue() {return uri;}
  99. public String getValue() {return uri;}
  100. public Element getOwnerElement() {return pseudoparent;}
  101. public boolean isSupported(String feature, String version) {return false;}
  102. public boolean hasChildNodes() {return false;}
  103. public boolean hasAttributes() {return false;}
  104. public Node getParentNode() {return null;}
  105. public Node getFirstChild() {return null;}
  106. public Node getLastChild() {return null;}
  107. public Node getPreviousSibling() {return null;}
  108. public Node getNextSibling() {return null;}
  109. public boolean getSpecified() {return false;}
  110. public void normalize() {return;}
  111. public NodeList getChildNodes() {return null;}
  112. public NamedNodeMap getAttributes() {return null;}
  113. public short getNodeType() {return Node.ATTRIBUTE_NODE;}
  114. public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  115. public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  116. public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
  117. public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
  118. public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
  119. public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
  120. public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
  121. public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
  122. public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
  123. /** Non-DOM method, part of the temporary kluge
  124. * %REVIEW% This would be a pruning problem, but since it will always be
  125. * added to the root element and we prune on elements, we shouldn't have
  126. * to worry.
  127. */
  128. public int getHandleOfNode()
  129. {
  130. return handle;
  131. }
  132. }