You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/04/11 16:39:34 UTC
cvs commit: xml-xalan/c/src/XercesParserLiaison XercesAttrBridge.cpp XercesAttrBridge.hpp XercesBridgeCommon.hpp XercesBridgeFactory.cpp XercesBridgeFactory.hpp XercesBridgeNavigator.cpp XercesBridgeNavigator.hpp XercesCDATASectionBridge.cpp XercesCDATASectionBridge.hpp XercesCommentBridge.cpp XercesCommentBridge.hpp XercesCommon.hpp XercesDocumentBridge.cpp XercesDocumentBridge.hpp XercesDocumentFragmentBridge.cpp XercesDocumentFragmentBridge.hpp XercesDocumentNamedNodeListCache.cpp XercesDocumentNamedNodeListCache.hpp XercesDocumentTypeBridge.cpp XercesDocumentTypeBridge.hpp XercesDOM_NodeHack.cpp XercesDOM_NodeHack.hpp XercesDOMException.cpp XercesDOMException.hpp XercesDOMImplementationBridge.cpp XercesDOMImplementationBridge.hpp XercesElementBridge.cpp XercesElementBridge.hpp XercesElementNamedNodeListCache.cpp XercesElementNamedNodeListCache.hpp XercesEntityBridge.cpp XercesEntityBridge.hpp XercesEntityReferenceBridge.cpp XercesEntityReferenceBridge.hpp XercesNamedNodeListCache.cpp XercesNamedNodeListCache.hpp XercesNamedNodeMapBridge.cpp XercesNamedNodeMapBridge.hpp XercesNodeListBridge.cpp XercesNodeListBridge.hpp XercesNotationBridge.cpp XercesNotationBridge.hpp XercesProcessingInstructionBridge.cpp XercesProcessingInstructionBridge.hpp XercesTextBridge.cpp XercesTextBridge.hpp XercesToXalanNodeMap.cpp XercesToXalanNodeMap.hpp
dbertoni 00/04/11 07:39:33
Added: c/src/XercesParserLiaison XercesAttrBridge.cpp
XercesAttrBridge.hpp XercesBridgeCommon.hpp
XercesBridgeFactory.cpp XercesBridgeFactory.hpp
XercesBridgeNavigator.cpp XercesBridgeNavigator.hpp
XercesCDATASectionBridge.cpp
XercesCDATASectionBridge.hpp
XercesCommentBridge.cpp XercesCommentBridge.hpp
XercesCommon.hpp XercesDocumentBridge.cpp
XercesDocumentBridge.hpp
XercesDocumentFragmentBridge.cpp
XercesDocumentFragmentBridge.hpp
XercesDocumentNamedNodeListCache.cpp
XercesDocumentNamedNodeListCache.hpp
XercesDocumentTypeBridge.cpp
XercesDocumentTypeBridge.hpp XercesDOM_NodeHack.cpp
XercesDOM_NodeHack.hpp XercesDOMException.cpp
XercesDOMException.hpp
XercesDOMImplementationBridge.cpp
XercesDOMImplementationBridge.hpp
XercesElementBridge.cpp XercesElementBridge.hpp
XercesElementNamedNodeListCache.cpp
XercesElementNamedNodeListCache.hpp
XercesEntityBridge.cpp XercesEntityBridge.hpp
XercesEntityReferenceBridge.cpp
XercesEntityReferenceBridge.hpp
XercesNamedNodeListCache.cpp
XercesNamedNodeListCache.hpp
XercesNamedNodeMapBridge.cpp
XercesNamedNodeMapBridge.hpp
XercesNodeListBridge.cpp XercesNodeListBridge.hpp
XercesNotationBridge.cpp XercesNotationBridge.hpp
XercesProcessingInstructionBridge.cpp
XercesProcessingInstructionBridge.hpp
XercesTextBridge.cpp XercesTextBridge.hpp
XercesToXalanNodeMap.cpp XercesToXalanNodeMap.hpp
Log:
Initial revision.
Revision Changes Path
1.1 xml-xalan/c/src/XercesParserLiaison/XercesAttrBridge.cpp
Index: XercesAttrBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesAttrBridge.hpp"
#include <cassert>
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
#include "XercesElementBridge.hpp"
XercesAttrBridge::XercesAttrBridge(
const DOM_Attr& theXercesAttr,
const XercesBridgeNavigator& theNavigator) :
XalanAttr(),
m_xercesNode(theXercesAttr),
m_children(theXercesAttr.getChildNodes(),
theNavigator),
m_navigator(theNavigator)
{
}
XercesAttrBridge::~XercesAttrBridge()
{
}
XalanDOMString
XercesAttrBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesAttrBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesAttrBridge::NodeType
XercesAttrBridge::getNodeType() const
{
return ATTRIBUTE_NODE;
}
XalanNode*
XercesAttrBridge::getParentNode() const
{
return 0;
}
const XalanNodeList*
XercesAttrBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesAttrBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesAttrBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesAttrBridge::getPreviousSibling() const
{
return 0;
}
XalanNode*
XercesAttrBridge::getNextSibling() const
{
return 0;
}
const XalanNamedNodeMap*
XercesAttrBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesAttrBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesAttrBridge*
#endif
XercesAttrBridge::cloneNode(bool deep) const
{
assert(m_navigator.getOwnerDocument() != 0);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesAttrBridge* const theBridge =
static_cast<XercesAttrBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesAttrBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesAttrBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesAttrBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesAttrBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesAttrBridge::hasChildNodes() const
{
return m_xercesNode.hasChildNodes();
}
void
XercesAttrBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesAttrBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesAttrBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesAttrBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesAttrBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesAttrBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesAttrBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesAttrBridge::getName() const
{
return m_xercesNode.getName();
}
bool
XercesAttrBridge::getSpecified() const
{
return m_xercesNode.getSpecified();
}
XalanDOMString
XercesAttrBridge::getValue() const
{
return m_xercesNode.getValue();
}
void
XercesAttrBridge::setValue(const XalanDOMString& value)
{
try
{
m_xercesNode.setValue(value);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanElement*
XercesAttrBridge::getOwnerElement() const
{
return m_navigator.getOwnerElement(m_xercesNode);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesAttrBridge.hpp
Index: XercesAttrBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESATTRBRIDGE_HEADER_GUARD_1357924680)
#define XERCESATTRBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_Attr.hpp>
#include <XalanDom/XalanAttr.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XercesBridgeNavigator;
class XalanElement;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesAttrBridge : public XalanAttr
{
public:
XercesAttrBridge(
const DOM_Attr& theXercesAttr,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesAttrBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesAttrBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanAttr...
/** @name Getter functions */
//@{
/**
* Returns the name of this attribute.
*/
virtual XalanDOMString
getName() const;
/**
*
* Returns true if the attribute received its value explicitly in the
* XML document, or if a value was assigned programatically with
* the setValue function. Returns false if the attribute value
* came from the default value declared in the document's DTD.
*/
virtual bool
getSpecified() const;
/**
* Returns the value of the attribute.
*
* The value of the attribute is returned as a string.
* Character and general entity references are replaced with their values.
*/
virtual XalanDOMString
getValue() const;
//@}
/** @name Setter functions */
//@{
/**
* Sets the value of the attribute. A text node with the unparsed contents
* of the string will be created.
*
* @param value The value of the DOM attribute to be set
*/
virtual void
setValue(const XalanDOMString& value);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* The <code>Element</code> node this attribute is attached to or
* <code>null</code> if this attribute is not in use.
*/
virtual XalanElement*
getOwnerElement() const;
//@}
private:
// Not implemented...
XercesAttrBridge(const XercesAttrBridge& theSource);
XercesAttrBridge&
operator=(const XercesAttrBridge& theSource);
bool
operator==(const XercesAttrBridge& theRHS) const;
// Data members...
DOM_Attr m_xercesNode;
XercesNodeListBridge m_children;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESATTRBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesBridgeCommon.hpp
Index: XercesBridgeCommon.hpp
===================================================================
#if !defined(XERCESBRIDGECOMMON_HEADER_GUARD_1357924680)
#define XERCESBRIDGECOMMON_HEADER_GUARD_1357924680
#endif // !defined(XERCESBRIDGECOMMON_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesBridgeFactory.cpp
Index: XercesBridgeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesBridgeFactory.hpp"
#include <cassert>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_Entity.hpp>
#include "XercesAttrBridge.hpp"
#include "XercesCDATASectionBridge.hpp"
#include "XercesCommentBridge.hpp"
#include "XercesDocumentBridge.hpp"
#include "XercesElementBridge.hpp"
#include "XercesEntityBridge.hpp"
#include "XercesEntityReferenceBridge.hpp"
#include "XercesNotationBridge.hpp"
#include "XercesProcessingInstructionBridge.hpp"
#include "XercesTextBridge.hpp"
#include "XercesToXalanNodeMap.hpp"
XercesBridgeFactory::XercesBridgeFactory(
const DOM_Document& theXercesDocument,
XercesDocumentBridge* theOwnerDocument,
XercesToXalanNodeMap* theNodeMap) :
m_xercesDocument(theXercesDocument),
m_ownerDocument(theOwnerDocument),
m_nodeMap(theNodeMap)
{
assert(theXercesDocument.isNull() == false);
assert(m_ownerDocument != 0);
}
XercesBridgeFactory::~XercesBridgeFactory()
{
}
XercesElementBridge*
XercesBridgeFactory::buildBridgeStructure() const
{
XalanNode* const theRootElement =
buildBridgeStructure(m_xercesDocument.getDocumentElement());
assert(theRootElement == 0 || theRootElement->getNodeType() == XalanNode::ELEMENT_NODE);
return static_cast<XercesElementBridge*>(theRootElement);
}
XalanNode*
XercesBridgeFactory::createBridgeNode(const DOM_Node& theXercesNode) const
{
XalanNode* theNewNode = 0;
switch(theXercesNode.getNodeType())
{
case DOM_Node::ATTRIBUTE_NODE:
{
const DOM_Attr& theAttrNode =
static_cast<const DOM_Attr&>(theXercesNode);
XercesAttrBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theAttrNode,
0,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
assert(false);
break;
case DOM_Node::CDATA_SECTION_NODE:
{
const DOM_CDATASection& theCDATASectionNode =
static_cast<const DOM_CDATASection&>(theXercesNode);
XercesCDATASectionBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theCDATASectionNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::COMMENT_NODE:
{
const DOM_Comment& theCommentNode =
static_cast<const DOM_Comment&>(theXercesNode);
XercesCommentBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theCommentNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::ELEMENT_NODE:
{
const DOM_Element& theElementNode =
static_cast<const DOM_Element&>(theXercesNode);
XercesElementBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theElementNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
// Now, let's create a bridge node for each attribute...
const DOM_NamedNodeMap theXercesNamedNodeMap = theXercesNode.getAttributes();
const unsigned int theLength = theXercesNamedNodeMap.getLength();
for (unsigned int i = 0; i < theLength; i++)
{
createBridgeNode(const_cast<DOM_NamedNodeMap&>(theXercesNamedNodeMap).item(i),
0,
0);
}
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::ENTITY_NODE:
{
const DOM_Entity& theEntityNode =
static_cast<const DOM_Entity&>(theXercesNode);
XercesEntityBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theEntityNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::ENTITY_REFERENCE_NODE:
{
const DOM_EntityReference& theEntityReferenceNode =
static_cast<const DOM_EntityReference&>(theXercesNode);
XercesEntityReferenceBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theEntityReferenceNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::NOTATION_NODE:
{
const DOM_Notation& theNotationNode =
static_cast<const DOM_Notation&>(theXercesNode);
XercesNotationBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theNotationNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
{
const DOM_ProcessingInstruction& thePINode =
static_cast<const DOM_ProcessingInstruction&>(theXercesNode);
XercesProcessingInstructionBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(thePINode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
case DOM_Node::TEXT_NODE:
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(theXercesNode);
XercesTextBridge* const theBridgeNode =
m_ownerDocument->createBridgeNode(theTextNode,
theParentNode,
thePreviousSibling);
assert(theBridgeNode != 0);
theNavigator = theBridgeNode->getNavigator();
assert(theNavigator != 0);
theNewNode = theBridgeNode;
}
break;
default:
assert(false);
break;
}
if (theNavigator != 0)
{
assert(theNewNode != 0);
XalanNode* const theFirstChild =
buildChildStructure(theXercesNode,
theNewNode);
theNavigator->setFirstChild(theFirstChild);
theNavigator->setLastChild(findLastSibling(theFirstChild));
XalanNode* const theNextSibling =
buildSiblingStructure(theXercesNode,
theParentNode,
theNewNode);
theNavigator->setNextSibling(theNextSibling);
if (m_nodeMap != 0)
{
m_nodeMap->addAssociation(theXercesNode, theNewNode, true);
}
}
return theNewNode;
}
XalanNode*
XercesBridgeFactory::buildBridgeStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode,
XalanNode* thePreviousSibling) const
{
XalanNode* theResult = 0;
if (theXercesNode.isNull() == false)
{
theResult = createBridgeNode(theXercesNode,
theParentNode,
thePreviousSibling);
}
return theResult;
}
XalanNode*
XercesBridgeFactory::findLastSibling(XalanNode* theNode)
{
XalanNode* theCurrentNode = theNode;
XalanNode* thePreviousNode = theNode;
while(theCurrentNode != 0)
{
thePreviousNode = theCurrentNode;
theCurrentNode = theCurrentNode->getNextSibling();
}
return thePreviousNode;
}
XalanNode*
XercesBridgeFactory::buildChildStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode) const
{
return buildBridgeStructure(theXercesNode.getFirstChild(),
theParentNode,
0);
}
XalanNode*
XercesBridgeFactory::buildSiblingStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode,
XalanNode* thePreviousSibling) const
{
return buildBridgeStructure(theXercesNode.getNextSibling(),
theParentNode,
thePreviousSibling);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesBridgeFactory.hpp
Index: XercesBridgeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESBRIDGEFACTORY_HEADER_GUARD_1357924680)
#define XERCESBRIDGEFACTORY_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
class DOM_Document;
class DOM_Node;
class XercesBridgeNavigator;
class XercesDocumentBridge;
class XercesToXalanNodeMap;
class XercesElementBridge;
class XalanNode;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesBridgeFactory
{
public:
XercesBridgeFactory(
const DOM_Document& theXercesDocument,
XercesDocumentBridge* theOwnerDocument,
XercesToXalanNodeMap* theNodeMap = 0);
~XercesBridgeFactory();
// Create an entire bridge structure for a document.
// Returns a pointer to the root element of the document.
XercesElementBridge*
buildBridgeStructure() const;
XalanNode*
buildBridgeStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode,
XalanNode* thePreviousSibling) const;
private:
// Creates a piece of a bridge structure for a given node.
// Returns a pointer to the node.
XalanNode*
createBridgeNode(
const DOM_Node& theXercesNode,
XalanNode* theParentNode,
XalanNode* thePreviousSibling) const;
XalanNode*
buildChildStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode) const;
XalanNode*
buildSiblingStructure(
const DOM_Node& theXercesNode,
XalanNode* theParentNode,
XalanNode* thePreviousSibling) const;
static XalanNode*
findLastSibling(XalanNode* theNode);
// Data members...
const DOM_Document& m_xercesDocument;
XercesDocumentBridge* const m_ownerDocument;
XercesToXalanNodeMap* const m_nodeMap;
};
#endif // !defined(XERCESBRIDGEFACTORY_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesBridgeNavigator.cpp
Index: XercesBridgeNavigator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesBridgeNavigator.hpp"
#include <XalanDOM/XalanNode.hpp>
#include "XercesAttrBridge.hpp"
#include "XercesDocumentBridge.hpp"
#include "XercesTextBridge.hpp"
#include "XercesDOMException.hpp"
XercesBridgeNavigator::XercesBridgeNavigator(XercesDocumentBridge* theOwnerDocument) :
m_ownerDocument(theOwnerDocument)
{
}
XercesBridgeNavigator::XercesBridgeNavigator(const XercesBridgeNavigator& theSource) :
m_ownerDocument(theSource.m_ownerDocument)
{
}
XercesBridgeNavigator::~XercesBridgeNavigator()
{
}
XercesDocumentBridge*
XercesBridgeNavigator::getOwnerDocument() const
{
return m_ownerDocument;
}
XalanNode*
XercesBridgeNavigator::mapNode(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode);
}
XalanAttr*
XercesBridgeNavigator::mapNode(const DOM_Attr& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode);
}
DOM_Node
XercesBridgeNavigator::mapNode(const XalanNode* theXalanNode) const
{
return m_ownerDocument->mapNode(theXalanNode);
}
DOM_Attr
XercesBridgeNavigator::mapNode(const XalanAttr* theXalanNode) const
{
return m_ownerDocument->mapNode(theXalanNode);
}
XalanNode*
XercesBridgeNavigator::getParentNode(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode.getParentNode());
}
XalanNode*
XercesBridgeNavigator::getPreviousSibling(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode.getPreviousSibling());
}
XalanNode*
XercesBridgeNavigator::getNextSibling(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode.getNextSibling());
}
XalanNode*
XercesBridgeNavigator::getFirstChild(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode.getFirstChild());
}
XalanNode*
XercesBridgeNavigator::getLastChild(const DOM_Node& theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode.getLastChild());
}
XalanNode*
XercesBridgeNavigator::insertBefore(
DOM_Node& theXercesParent,
XalanNode* newChild,
XalanNode* refChild) const
{
assert(newChild != 0);
// Get the corresponding Xerces nodes...
const DOM_Node theNewChild = m_ownerDocument->mapNode(newChild);
const DOM_Node theRefChild = m_ownerDocument->mapNode(refChild);
try
{
const DOM_Node theXercesResult =
theXercesParent.insertBefore(theNewChild, theRefChild);
assert(m_ownerDocument->mapNode(theXercesResult) == newChild);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return newChild;
}
XalanNode*
XercesBridgeNavigator:: replaceChild(
DOM_Node& theXercesParent,
XalanNode* newChild,
XalanNode* oldChild) const
{
assert(newChild != 0);
assert(oldChild != 0);
// Get the corresponding Xerces nodes...
const DOM_Node theNewChild = m_ownerDocument->mapNode(newChild);
const DOM_Node theOldChild = m_ownerDocument->mapNode(oldChild);
try
{
const DOM_Node theXercesResult =
theXercesParent.replaceChild(theNewChild, theOldChild);
assert(m_ownerDocument->mapNode(theXercesResult) == oldChild);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return oldChild;
}
XalanNode*
XercesBridgeNavigator::removeChild(
DOM_Node& theXercesParent,
XalanNode* oldChild) const
{
assert(oldChild != 0);
// Get the corresponding Xerces nodes...
const DOM_Node theOldChild = m_ownerDocument->mapNode(oldChild);
try
{
const DOM_Node theXercesResult =
theXercesParent.removeChild(theOldChild);
assert(m_ownerDocument->mapNode(theXercesResult) == oldChild);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return oldChild;
}
XalanNode*
XercesBridgeNavigator::appendChild(
DOM_Node& theXercesParent,
XalanNode* newChild) const
{
return insertBefore(theXercesParent, newChild, 0);
}
XalanElement*
XercesBridgeNavigator::getOwnerElement(const DOM_Attr& theXercesAttr) const
{
return m_ownerDocument->mapNode(theXercesAttr.getOwnerElement());
}
XalanNode*
XercesBridgeNavigator::cloneNode(
const XalanNode* theXalanNode,
const DOM_Node& theXercesNode,
bool deep) const
{
return m_ownerDocument->internalCloneNode(theXalanNode, theXercesNode, deep);
}
XalanText*
XercesBridgeNavigator::splitText(
DOM_Text& theXercesText,
unsigned int offset) const
{
XalanText* theXalanText = 0;
try
{
DOM_Text theNewXercesText = theXercesText.splitText(offset);
assert(theXercesText.isNull() == false);
theXalanText = m_ownerDocument->createBridgeNode(theNewXercesText);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanText;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesBridgeNavigator.hpp
Index: XercesBridgeNavigator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESBRIDGENAVIGATOR_HEADER_GUARD_1357924680)
#define XERCESBRIDGENAVIGATOR_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
class DOM_Attr;
class DOM_Node;
class XercesDocumentBridge;
class XalanAttr;
class XalanElement;
class XalanNode;
class XalanText;
class DOM_Text;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesBridgeNavigator
{
public:
XercesBridgeNavigator(XercesDocumentBridge* theOwnerDocument);
XercesBridgeNavigator(const XercesBridgeNavigator& theSource);
virtual
~XercesBridgeNavigator();
XercesBridgeNavigator&
operator=(const XercesBridgeNavigator& theRHS);
virtual XercesDocumentBridge*
getOwnerDocument() const;
virtual XalanNode*
mapNode(const DOM_Node& theXercesNode) const;
virtual XalanAttr*
mapNode(const DOM_Attr& theXercesNode) const;
virtual DOM_Node
mapNode(const XalanNode* theXalanNode) const;
virtual DOM_Attr
mapNode(const XalanAttr* theXercesNode) const;
virtual XalanNode*
getParentNode(const DOM_Node& theXercesNode) const;
virtual XalanNode*
getPreviousSibling(const DOM_Node& theXercesNode) const;
virtual XalanNode*
getNextSibling(const DOM_Node& theXercesNode) const;
virtual XalanNode*
getFirstChild(const DOM_Node& theXercesNode) const;
virtual XalanNode*
getLastChild(const DOM_Node& theXercesNode) const;
virtual XalanNode*
insertBefore(
DOM_Node& theXercesParent,
XalanNode* newChild,
XalanNode* refChild) const;
virtual XalanNode*
replaceChild(
DOM_Node& theXercesParent,
XalanNode* newChild,
XalanNode* oldChild) const;
virtual XalanNode*
removeChild(
DOM_Node& theXercesParent,
XalanNode* oldChild) const;
virtual XalanNode*
appendChild(
DOM_Node& theXercesParent,
XalanNode* newChild) const;
virtual XalanElement*
getOwnerElement(const DOM_Attr& theXercesAttr) const;
virtual XalanNode*
cloneNode(
const XalanNode* theXalanNode,
const DOM_Node& theXercesNode,
bool deep) const;
virtual XalanText*
splitText(
DOM_Text& theXercesText,
unsigned int offset) const;
private:
// Not implemented...
bool
operator==(const XercesBridgeNavigator& theRHS) const;
// Data members...
XercesDocumentBridge* const m_ownerDocument;
};
#endif // !defined(XERCESBRIDGENAVIGATOR_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesCDATASectionBridge.cpp
Index: XercesCDATASectionBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesCDATASectionBridge.hpp"
#include <cassert>
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesCDATASectionBridge::XercesCDATASectionBridge(
const DOM_CDATASection& theXercesCDATASection,
const XercesBridgeNavigator& theNavigator) :
XalanCDATASection(),
m_xercesNode(theXercesCDATASection),
m_navigator(theNavigator)
{
}
XercesCDATASectionBridge::~XercesCDATASectionBridge()
{
}
XalanDOMString
XercesCDATASectionBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesCDATASectionBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesCDATASectionBridge::NodeType
XercesCDATASectionBridge::getNodeType() const
{
return CDATA_SECTION_NODE;
}
XalanNode*
XercesCDATASectionBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesCDATASectionBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesCDATASectionBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesCDATASectionBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesCDATASectionBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesCDATASectionBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesCDATASectionBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesCDATASectionBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesCDATASectionBridge*
#endif
XercesCDATASectionBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesCDATASectionBridge* const theBridge =
static_cast<XercesCDATASectionBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesCDATASectionBridge::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionBridge::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionBridge::removeChild(XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionBridge::appendChild(XalanNode* /* newChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesCDATASectionBridge::hasChildNodes() const
{
return false;
}
void
XercesCDATASectionBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCDATASectionBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesCDATASectionBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesCDATASectionBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesCDATASectionBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesCDATASectionBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesCDATASectionBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesCDATASectionBridge::getData() const
{
return m_xercesNode.getData();
}
unsigned int
XercesCDATASectionBridge::getLength() const
{
return m_xercesNode.getLength();
}
XalanDOMString
XercesCDATASectionBridge::substringData(
unsigned int offset,
unsigned int count) const
{
try
{
return m_xercesNode.substringData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCDATASectionBridge::appendData(const XalanDOMString& arg)
{
try
{
m_xercesNode.appendData(arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCDATASectionBridge::insertData(
unsigned int offset,
const XalanDOMString& arg)
{
try
{
m_xercesNode.insertData(offset, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCDATASectionBridge::deleteData(
unsigned int offset,
unsigned int count)
{
try
{
m_xercesNode.deleteData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCDATASectionBridge::replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg)
{
try
{
m_xercesNode.replaceData(offset, count, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanText*
XercesCDATASectionBridge::splitText(unsigned int offset)
{
return m_navigator.splitText(m_xercesNode, offset);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesCDATASectionBridge.hpp
Index: XercesCDATASectionBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESCDATASECTIONBRIDGE_HEADER_GUARD_1357924680)
#define XERCESCDATASECTIONBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_CDATASection.hpp>
#include <XalanDOM/XalanCDATASection.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesCDATASectionBridge : public XalanCDATASection
{
public:
XercesCDATASectionBridge(
const DOM_CDATASection& theXercesCDATASection,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesCDATASectionBridge();
/**
* Gets the name of this node.
*/
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesCDATASectionBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanCDATASection...
/** @name Getter functions. */
//@{
/**
* Returns the character data of the node that implements this interface.
*
* The DOM implementation may not put arbitrary limits on the amount of data that
* may be stored in a <code>CharacterData</code> node. However,
* implementation limits may mean that the entirety of a node's data may
* not fit into a single <code>DOMString</code>. In such cases, the user
* may call <code>substringData</code> to retrieve the data in
* appropriately sized pieces.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
*/
virtual XalanDOMString
getData() const;
/**
* Returns the number of characters that are available through <code>data</code> and
* the <code>substringData</code> method below.
*
* This may have the value
* zero, i.e., <code>CharacterData</code> nodes may be empty.
*/
virtual unsigned int
getLength() const;
/**
* Extracts a range of data from the node.
*
* @param offset Start offset of substring to extract.
* @param count The number of characters to extract.
* @return The specified substring. If the sum of <code>offset</code> and
* <code>count</code> exceeds the <code>length</code>, then all
* characters to the end of the data are returned.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not
* fit into a <code>DOMString</code>.
*/
virtual XalanDOMString
substringData(
unsigned int offset,
unsigned int count) const;
//@}
/** @name Functions that set or change data. */
//@{
/**
* Append the string to the end of the character data of the node.
*
* Upon success, <code>data</code> provides access to the concatenation of
* <code>data</code> and the <code>DOMString</code> specified.
* @param arg The <code>DOMString</code> to append.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
appendData(const XalanDOMString& arg);
/**
* Insert a string at the specified character offset.
*
* @param offset The character offset at which to insert.
* @param arg The <code>DOMString</code> to insert.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
insertData(
unsigned int offset,
const XalanDOMString& arg);
/**
* Remove a range of characters from the node.
*
* Upon success,
* <code>data</code> and <code>length</code> reflect the change.
* @param offset The offset from which to remove characters.
* @param count The number of characters to delete. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* then all characters from <code>offset</code> to the end of the data
* are deleted.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
deleteData(
unsigned int offset,
unsigned int count);
/**
* Replace the characters starting at the specified character offset with
* the specified string.
*
* @param offset The offset from which to start replacing.
* @param count The number of characters to replace. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* , then all characters to the end of the data are replaced (i.e., the
* effect is the same as a <code>remove</code> method call with the same
* range, followed by an <code>append</code> method invocation).
* @param arg The <code>DOMString</code> with which the range must be
* replaced.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg);
//@}
//@}
/** @name Functions to modify the Text node. */
//@{
/**
* Breaks this node into two nodes at the specified
* offset, keeping both in the tree as siblings.
*
* This node then only
* contains all the content up to the <code>offset</code> point. And a new
* node of the same nodeType, which is inserted as the next sibling of this
* node, contains all the content at and after the <code>offset</code>
* point. When the <code>offset</code> is equal to the lenght of this node,
* the new node has no data.
* @param offset The offset at which to split, starting from 0.
* @return The new <code>Text</code> node.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual XalanText*
splitText(unsigned int offset);
//@}
private:
// Not implemented...
XercesCDATASectionBridge(const XercesCDATASectionBridge& theSource);
XercesCDATASectionBridge&
operator=(const XercesCDATASectionBridge& theSource);
bool
operator==(const XercesCDATASectionBridge& theRHS) const;
// Data members...
DOM_CDATASection m_xercesNode;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESCDATASECTIONBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesCommentBridge.cpp
Index: XercesCommentBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesCommentBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesCommentBridge::XercesCommentBridge(
const DOM_Comment& theXercesComment,
const XercesBridgeNavigator& theNavigator) :
XalanComment(),
m_xercesNode(theXercesComment),
m_navigator(theNavigator)
{
}
XercesCommentBridge::~XercesCommentBridge()
{
}
XalanDOMString
XercesCommentBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesCommentBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesCommentBridge::NodeType
XercesCommentBridge::getNodeType() const
{
return COMMENT_NODE;
}
XalanNode*
XercesCommentBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesCommentBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesCommentBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesCommentBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesCommentBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesCommentBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesCommentBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesCommentBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesCommentBridge*
#endif
XercesCommentBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesCommentBridge* const theBridge =
static_cast<XercesCommentBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesCommentBridge::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentBridge::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentBridge::removeChild(XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentBridge::appendChild(XalanNode* /* newChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesCommentBridge::hasChildNodes() const
{
return false;
}
void
XercesCommentBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCommentBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesCommentBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesCommentBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesCommentBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesCommentBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesCommentBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesCommentBridge::getData() const
{
return m_xercesNode.getData();
}
unsigned int
XercesCommentBridge::getLength() const
{
return m_xercesNode.getLength();
}
XalanDOMString
XercesCommentBridge::substringData(
unsigned int offset,
unsigned int count) const
{
try
{
return m_xercesNode.substringData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCommentBridge::appendData(const XalanDOMString& arg)
{
try
{
m_xercesNode.appendData(arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCommentBridge::insertData(
unsigned int offset,
const XalanDOMString& arg)
{
try
{
m_xercesNode.insertData(offset, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCommentBridge::deleteData(
unsigned int offset,
unsigned int count)
{
try
{
m_xercesNode.deleteData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesCommentBridge::replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg)
{
try
{
m_xercesNode.replaceData(offset, count, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesCommentBridge.hpp
Index: XercesCommentBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESCOMMENTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESCOMMENTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_Comment.hpp>
#include <XalanDOM/XalanComment.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesCommentBridge : public XalanComment
{
public:
XercesCommentBridge(
const DOM_Comment& theXercesComment,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesCommentBridge();
/**
* Gets the name of this node.
*/
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesCommentBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanCDATASection...
/** @name Getter functions. */
//@{
/**
* Returns the character data of the node that implements this interface.
*
* The DOM implementation may not put arbitrary limits on the amount of data that
* may be stored in a <code>CharacterData</code> node. However,
* implementation limits may mean that the entirety of a node's data may
* not fit into a single <code>DOMString</code>. In such cases, the user
* may call <code>substringData</code> to retrieve the data in
* appropriately sized pieces.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
*/
virtual XalanDOMString
getData() const;
/**
* Returns the number of characters that are available through <code>data</code> and
* the <code>substringData</code> method below.
*
* This may have the value
* zero, i.e., <code>CharacterData</code> nodes may be empty.
*/
virtual unsigned int
getLength() const;
/**
* Extracts a range of data from the node.
*
* @param offset Start offset of substring to extract.
* @param count The number of characters to extract.
* @return The specified substring. If the sum of <code>offset</code> and
* <code>count</code> exceeds the <code>length</code>, then all
* characters to the end of the data are returned.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not
* fit into a <code>DOMString</code>.
*/
virtual XalanDOMString
substringData(
unsigned int offset,
unsigned int count) const;
//@}
/** @name Functions that set or change data. */
//@{
/**
* Append the string to the end of the character data of the node.
*
* Upon success, <code>data</code> provides access to the concatenation of
* <code>data</code> and the <code>DOMString</code> specified.
* @param arg The <code>DOMString</code> to append.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
appendData(const XalanDOMString& arg);
/**
* Insert a string at the specified character offset.
*
* @param offset The character offset at which to insert.
* @param arg The <code>DOMString</code> to insert.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
insertData(
unsigned int offset,
const XalanDOMString& arg);
/**
* Remove a range of characters from the node.
*
* Upon success,
* <code>data</code> and <code>length</code> reflect the change.
* @param offset The offset from which to remove characters.
* @param count The number of characters to delete. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* then all characters from <code>offset</code> to the end of the data
* are deleted.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
deleteData(
unsigned int offset,
unsigned int count);
/**
* Replace the characters starting at the specified character offset with
* the specified string.
*
* @param offset The offset from which to start replacing.
* @param count The number of characters to replace. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* , then all characters to the end of the data are replaced (i.e., the
* effect is the same as a <code>remove</code> method call with the same
* range, followed by an <code>append</code> method invocation).
* @param arg The <code>DOMString</code> with which the range must be
* replaced.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg);
//@}
private:
// Not implemented...
XercesCommentBridge(const XercesCommentBridge& theSource);
XercesCommentBridge&
operator=(const XercesCommentBridge& theSource);
bool
operator==(const XercesCommentBridge& theRHS) const;
// Data members...
DOM_Comment m_xercesNode;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESCOMMENTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesCommon.hpp
<<Binary file>>
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.cpp
Index: XercesDocumentBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDocumentBridge.hpp"
#include <algorithm>
#include <cassert>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_DOMException.hpp>
#include <dom/DocumentImpl.hpp>
#include <dom/NodeImpl.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <XalanDOM/XalanDocumentType.hpp>
#include <XalanDOM/XalanElement.hpp>
#include "XercesAttrBridge.hpp"
#include "XercesCommentBridge.hpp"
#include "XercesCDATASectionBridge.hpp"
#include "XercesDOM_NodeHack.hpp"
#include "XercesDOMException.hpp"
#include "XercesDOMImplementationBridge.hpp"
#include "XercesDocumentFragmentBridge.hpp"
#include "XercesDocumentTypeBridge.hpp"
#include "XercesElementBridge.hpp"
#include "XercesEntityBridge.hpp"
#include "XercesEntityReferenceBridge.hpp"
#include "XercesNodeListBridge.hpp"
#include "XercesNotationBridge.hpp"
#include "XercesProcessingInstructionBridge.hpp"
#include "XercesTextBridge.hpp"
XercesDocumentBridge::XercesDocumentBridge(const DOM_Document& theXercesDocument) :
XalanDocument(),
m_xercesDocument(theXercesDocument),
m_navigator(this),
m_children(theXercesDocument.getChildNodes(),
m_navigator),
m_cachedNodeLists(theXercesDocument,
m_navigator),
m_nodeMap(),
m_domImplementation(new XercesDOMImplementationBridge(theXercesDocument.getImplementation())),
m_nodes(),
m_doctype(0)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
#endif
// Put ourself into the node map, and don't assign an index...
m_nodeMap.addAssociation(m_xercesDocument, this, false);
// Try to build the doctype...
DOM_DocumentType theDoctype = theXercesDocument.getDoctype();
if (theDoctype.isNull() == false)
{
m_doctype = new XercesDocumentTypeBridge(theDoctype, this);
// Add it to the node map...
m_nodeMap.addAssociation(theDoctype, m_doctype, false);
m_nodes.insert(m_doctype);
}
}
XercesDocumentBridge::~XercesDocumentBridge()
{
#if !defined(XALAN_NO_NAMESPACES)
using std::for_each;
#endif
// m_bridgeMap contains all of the nodes that
// are still alive...
for_each(m_nodes.begin(),
m_nodes.end(),
DeleteFunctor<XalanNode>());
}
XalanNode*
XercesDocumentBridge::mapNode(const DOM_Node& theXercesNode) const
{
return mapNode(XercesDOM_NodeHack::getImpl(theXercesNode));
}
XalanNode*
XercesDocumentBridge::mapNode(NodeImpl* theXercesNodeImpl) const
{
XalanNode* theXalanNode = 0;
if (theXercesNodeImpl != 0)
{
theXalanNode = m_nodeMap.getNode(theXercesNodeImpl);
if (theXalanNode == 0)
{
// Make sure the node belongs to our document...
NodeImpl* const theOwnerDocument =
XercesDOM_NodeHack::getImpl(m_xercesDocument);
assert(theOwnerDocument != 0);
if (theXercesNodeImpl != theOwnerDocument &&
theXercesNodeImpl->getOwnerDocument() != theOwnerDocument)
{
throw XalanDOMException(XalanDOMException::WRONG_DOCUMENT_ERR);
}
else
{
// OK, we haven't yet created a bridge not, so go ahead and
// create one.
theXalanNode = createBridgeNode(XercesDOM_NodeHack(theXercesNodeImpl));
assert(theXalanNode != 0);
}
}
}
return theXalanNode;
}
DOM_Node
XercesDocumentBridge::mapNode(const XalanNode* theXalanNode) const
{
DOM_Node theXercesNode;
if (theXalanNode != 0)
{
theXercesNode = m_nodeMap.getNode(theXalanNode);
if (theXercesNode.isNull() == true)
{
throw XalanDOMException(XalanDOMException::WRONG_DOCUMENT_ERR);
}
}
return theXercesNode;
}
DOM_Attr
XercesDocumentBridge::mapNode(const XalanAttr* theXalanNode) const
{
NodeImpl* const theXercesNodeImpl =
mapNodeToImpl(theXalanNode);
return XercesDOM_AttrHack(reinterpret_cast<AttrImpl*>(theXercesNodeImpl));
}
NodeImpl*
XercesDocumentBridge::mapNodeToImpl(const XalanNode* theXalanNode) const
{
NodeImpl* theXercesNodeImpl = 0;
if (theXalanNode != 0)
{
theXercesNodeImpl = m_nodeMap.getNodeImpl(theXalanNode);
if (theXercesNodeImpl == 0)
{
throw XalanDOMException(XalanDOMException::WRONG_DOCUMENT_ERR);
}
}
return theXercesNodeImpl;
}
XalanAttr*
XercesDocumentBridge::mapNode(const DOM_Attr& theXercesNode) const
{
return static_cast<XercesAttrBridge*>(mapNode(XercesDOM_NodeHack::getImpl(theXercesNode)));
}
XalanElement*
XercesDocumentBridge::mapNode(const DOM_Element& theXercesNode) const
{
return static_cast<XercesElementBridge*>(mapNode(XercesDOM_NodeHack::getImpl(theXercesNode)));
}
XercesElementBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Element& theXercesNode) const
{
XercesElementBridge* const theBridge =
new XercesElementBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesDocumentFragmentBridge*
XercesDocumentBridge::createBridgeNode(const DOM_DocumentFragment& theXercesNode) const
{
XercesDocumentFragmentBridge* const theBridge =
new XercesDocumentFragmentBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesTextBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Text& theXercesNode) const
{
XercesTextBridge* const theBridge =
new XercesTextBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesCommentBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Comment& theXercesNode) const
{
XercesCommentBridge* const theBridge =
new XercesCommentBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesCDATASectionBridge*
XercesDocumentBridge::createBridgeNode(const DOM_CDATASection& theXercesNode) const
{
XercesCDATASectionBridge* const theBridge =
new XercesCDATASectionBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesProcessingInstructionBridge*
XercesDocumentBridge::createBridgeNode(const DOM_ProcessingInstruction& theXercesNode) const
{
XercesProcessingInstructionBridge* const theBridge =
new XercesProcessingInstructionBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesAttrBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Attr& theXercesNode) const
{
XercesAttrBridge* const theBridge =
new XercesAttrBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesEntityBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Entity& theXercesNode) const
{
XercesEntityBridge* const theBridge =
new XercesEntityBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesEntityReferenceBridge*
XercesDocumentBridge::createBridgeNode(const DOM_EntityReference& theXercesNode) const
{
XercesEntityReferenceBridge* const theBridge =
new XercesEntityReferenceBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
XercesNotationBridge*
XercesDocumentBridge::createBridgeNode(const DOM_Notation& theXercesNode) const
{
XercesNotationBridge* const theBridge =
new XercesNotationBridge(theXercesNode,
m_navigator);
m_nodes.insert(theBridge);
// Add it to the node map...
m_nodeMap.addAssociation(theXercesNode, theBridge, false);
return theBridge;
}
void
XercesDocumentBridge::destroyNode(XalanNode* theNode)
{
const NodeSetType::iterator i =
m_nodes.find(theNode);
if (i == m_nodes.end())
{
// Doesn't belong to this doc, so throw...
throw XercesDOMException(XercesDOMException::WRONG_DOCUMENT_ERR);
}
else
{
// Delete the node...
delete *i;
// Erase it from the map...
m_nodes.erase(i);
}
}
XalanNode*
XercesDocumentBridge::internalCloneNode(
const XalanNode* theXalanNode,
const DOM_Node& theXercesNode,
bool deep)
{
XalanNode* theNewNode = 0;
if (theXalanNode->getOwnerDocument() != this)
{
throw XercesDOMException(XercesDOMException::WRONG_DOCUMENT_ERR);
}
try
{
const DOM_Node theNewXercesNode =
theXercesNode.cloneNode(deep);
theNewNode = createBridgeNode(theNewXercesNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theNewNode;
}
// The rest of these are the standard DOM interfaces...
XalanDOMString
XercesDocumentBridge::getNodeName() const
{
return m_xercesDocument.getNodeName();
}
XalanDOMString
XercesDocumentBridge::getNodeValue() const
{
return m_xercesDocument.getNodeValue();
}
XercesDocumentBridge::NodeType
XercesDocumentBridge::getNodeType() const
{
return DOCUMENT_NODE;
}
XalanNode*
XercesDocumentBridge::getParentNode() const
{
return 0;
}
const XalanNodeList*
XercesDocumentBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesDocumentBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesDocument);
}
XalanNode*
XercesDocumentBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesDocument);
}
XalanNode*
XercesDocumentBridge::getPreviousSibling() const
{
return 0;
}
XalanNode*
XercesDocumentBridge::getNextSibling() const
{
return 0;
}
const XalanNamedNodeMap*
XercesDocumentBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesDocumentBridge::getOwnerDocument() const
{
return 0;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesDocumentBridge*
#endif
XercesDocumentBridge::cloneNode(bool deep) const
{
XercesDocumentBridge* theBridge = 0;
try
{
const DOM_Node theNewDocument = m_xercesDocument.cloneNode(deep);
theBridge =
new XercesDocumentBridge(static_cast<const DOM_Document&>(theNewDocument));
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridge;
}
XalanNode*
XercesDocumentBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesDocument, newChild, refChild);
}
XalanNode*
XercesDocumentBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesDocument, newChild, oldChild);
}
XalanNode*
XercesDocumentBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesDocument, oldChild);
}
XalanNode*
XercesDocumentBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesDocument, newChild);
}
bool
XercesDocumentBridge::hasChildNodes() const
{
return m_xercesDocument.hasChildNodes();
}
void
XercesDocumentBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesDocument.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesDocumentBridge::normalize()
{
try
{
m_xercesDocument.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesDocumentBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesDocument.supports(feature, version);
}
XalanDOMString
XercesDocumentBridge::getNamespaceURI() const
{
return m_xercesDocument.getNamespaceURI();
}
XalanDOMString
XercesDocumentBridge::getPrefix() const
{
return m_xercesDocument.getPrefix();
}
XalanDOMString
XercesDocumentBridge::getLocalName() const
{
return m_xercesDocument.getLocalName();
}
void
XercesDocumentBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesDocument.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanElement*
XercesDocumentBridge::createElement(const XalanDOMString& tagName)
{
XalanElement* theBridgeNode = 0;
try
{
const DOM_Element theXercesNode =
m_xercesDocument.createElement(tagName);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanDocumentFragment*
XercesDocumentBridge::createDocumentFragment()
{
XalanDocumentFragment* theBridgeNode = 0;
try
{
const DOM_DocumentFragment theXercesNode =
m_xercesDocument.createDocumentFragment();
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanText*
XercesDocumentBridge::createTextNode(const XalanDOMString& data)
{
XalanText* theBridgeNode = 0;
try
{
const DOM_Text theXercesNode =
m_xercesDocument.createTextNode(data);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanComment*
XercesDocumentBridge::createComment(const XalanDOMString& data)
{
XalanComment* theBridgeNode = 0;
try
{
const DOM_Comment theXercesNode =
m_xercesDocument.createComment(data);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanCDATASection*
XercesDocumentBridge::createCDATASection(const XalanDOMString& data)
{
XalanCDATASection* theBridgeNode = 0;
try
{
const DOM_CDATASection theXercesNode =
m_xercesDocument.createCDATASection(data);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanProcessingInstruction*
XercesDocumentBridge::createProcessingInstruction(
const XalanDOMString& target,
const XalanDOMString& data)
{
XalanProcessingInstruction* theBridgeNode = 0;
try
{
const DOM_ProcessingInstruction theXercesNode =
m_xercesDocument.createProcessingInstruction(target, data);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanAttr*
XercesDocumentBridge::createAttribute(const XalanDOMString& name)
{
XalanAttr* theBridgeNode = 0;
try
{
const DOM_Attr theXercesNode =
m_xercesDocument.createAttribute(name);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanEntityReference*
XercesDocumentBridge::createEntityReference(const XalanDOMString& name)
{
XalanEntityReference* theBridgeNode = 0;
try
{
const DOM_EntityReference theXercesNode =
m_xercesDocument.createEntityReference(name);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanDocumentType*
XercesDocumentBridge::getDoctype() const
{
return m_doctype;
}
XalanDOMImplementation*
XercesDocumentBridge::getImplementation() const
{
return m_domImplementation.get();
}
XalanElement*
XercesDocumentBridge::getDocumentElement() const
{
return mapNode(m_xercesDocument.getDocumentElement());
}
XalanNodeList*
XercesDocumentBridge::getElementsByTagName(const XalanDOMString& tagname) const
{
return m_cachedNodeLists.getElementsByTagName(tagname);
}
XalanNode*
XercesDocumentBridge::importNode(
XalanNode* importedNode,
bool deep)
{
// $$$ToDo: Fix this....
throw XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanElement*
XercesDocumentBridge::createElementNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName)
{
XalanElement* theBridgeNode = 0;
try
{
const DOM_Element theXercesNode =
m_xercesDocument.createElementNS(namespaceURI, qualifiedName);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanAttr*
XercesDocumentBridge::createAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName)
{
XalanAttr* theBridgeNode = 0;
try
{
const DOM_Attr theXercesNode =
m_xercesDocument.createAttributeNS(namespaceURI, qualifiedName);
assert(theXercesNode.isNull() == false);
theBridgeNode = createBridgeNode(theXercesNode);
assert(mapNode(theXercesNode) == theBridgeNode);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theBridgeNode;
}
XalanNodeList*
XercesDocumentBridge::getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_cachedNodeLists.getElementsByTagNameNS(namespaceURI, localName);
}
XalanElement*
XercesDocumentBridge::getElementById(const XalanDOMString& elementId) const
{
// $$$ ToDo: This is because DOM_Document::getElementById() is not
// const...
#if defined(XERCES_NO_MUTABLE)
const DOM_Node theXercesNode((DOM_Document&)m_xercesDocument).getElementById(elementId));
#else
const DOM_Node theXercesNode(m_xercesDocument.getElementById(elementId));
#endif
assert(mapNode(theXercesNode) != 0 &&
mapNode(theXercesNode)->getNodeType() == XalanNode::ELEMENT_NODE);
return static_cast<XalanElement*>(mapNode(theXercesNode));
}
XalanNode*
XercesDocumentBridge::createBridgeNode(const DOM_Node& theXercesNode) const
{
XalanNode* theNewNode = 0;
switch(theXercesNode.getNodeType())
{
case DOM_Node::ATTRIBUTE_NODE:
{
const DOM_Attr& theAttrNode =
static_cast<const DOM_Attr&>(theXercesNode);
theNewNode = createBridgeNode(theAttrNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::CDATA_SECTION_NODE:
{
const DOM_CDATASection& theCDATASectionNode =
static_cast<const DOM_CDATASection&>(theXercesNode);
theNewNode = createBridgeNode(theCDATASectionNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::COMMENT_NODE:
{
const DOM_Comment& theCommentNode =
static_cast<const DOM_Comment&>(theXercesNode);
theNewNode = createBridgeNode(theCommentNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::DOCUMENT_FRAGMENT_NODE:
{
const DOM_DocumentFragment& theDocumentFragmentNode =
static_cast<const DOM_DocumentFragment&>(theXercesNode);
theNewNode = createBridgeNode(theDocumentFragmentNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::ELEMENT_NODE:
{
const DOM_Element& theElementNode =
static_cast<const DOM_Element&>(theXercesNode);
theNewNode = createBridgeNode(theElementNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::ENTITY_NODE:
{
const DOM_Entity& theEntityNode =
static_cast<const DOM_Entity&>(theXercesNode);
theNewNode = createBridgeNode(theEntityNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::ENTITY_REFERENCE_NODE:
{
const DOM_EntityReference& theEntityReferenceNode =
static_cast<const DOM_EntityReference&>(theXercesNode);
theNewNode = createBridgeNode(theEntityReferenceNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::NOTATION_NODE:
{
const DOM_Notation& theNotationNode =
static_cast<const DOM_Notation&>(theXercesNode);
theNewNode = createBridgeNode(theNotationNode);
assert(theNewNode != 0);
}
break;
case DOM_Node::PROCESSING_INSTRUCTION_NODE:
{
const DOM_ProcessingInstruction& thePINode =
static_cast<const DOM_ProcessingInstruction&>(theXercesNode);
theNewNode = createBridgeNode(thePINode);
assert(theNewNode != 0);
}
break;
case DOM_Node::TEXT_NODE:
{
const DOM_Text& theTextNode =
static_cast<const DOM_Text&>(theXercesNode);
theNewNode = createBridgeNode(theTextNode);
assert(theNewNode != 0);
}
break;
default:
assert(false);
break;
}
return theNewNode;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.hpp
Index: XercesDocumentBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <memory>
#include <set>
#include <dom/DOM_Document.hpp>
#include <XalanDOM/XalanDocument.hpp>
#include <XercesParserLiaison/XercesToXalanNodeMap.hpp>
#include <XercesParserLiaison/XercesBridgeNavigator.hpp>
#include <XercesParserLiaison/XercesDocumentNamedNodeListCache.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XalanDOMImplementation;
class XercesAttrBridge;
class XercesCommentBridge;
class XercesCDATASectionBridge;
class XercesDocumentFragmentBridge;
class XercesDocumentTypeBridge;
class XercesElementBridge;
class XercesEntityBridge;
class XercesEntityReferenceBridge;
class XercesProcessingInstructionBridge;
class XercesNotationBridge;
class XercesTextBridge;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentBridge : public XalanDocument
{
public:
friend class XercesBridgeNavigator;
XercesDocumentBridge(const DOM_Document& theXercesDocument);
virtual
~XercesDocumentBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
virtual XalanDOMString
getNodeValue() const;
virtual NodeType
getNodeType() const;
virtual XalanNode*
getParentNode() const;
virtual const XalanNodeList*
getChildNodes() const;
virtual XalanNode*
getFirstChild() const;
virtual XalanNode*
getLastChild() const;
virtual XalanNode*
getPreviousSibling() const;
virtual XalanNode*
getNextSibling() const;
virtual const XalanNamedNodeMap*
getAttributes() const;
virtual XalanDocument*
getOwnerDocument() const;
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesDocumentBridge*
#endif
cloneNode(bool deep) const;
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
virtual XalanNode*
removeChild(XalanNode* oldChild);
virtual XalanNode*
appendChild(XalanNode* newChild);
virtual bool
hasChildNodes() const;
virtual void
setNodeValue(const XalanDOMString& nodeValue);
virtual void
normalize();
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
virtual XalanDOMString
getNamespaceURI() const;
virtual XalanDOMString
getPrefix() const;
virtual XalanDOMString
getLocalName() const;
virtual void
setPrefix(const XalanDOMString& prefix);
virtual XalanElement*
createElement(const XalanDOMString& tagName);
virtual XalanDocumentFragment*
createDocumentFragment();
virtual XalanText*
createTextNode(const XalanDOMString& data);
virtual XalanComment*
createComment(const XalanDOMString& data);
virtual XalanCDATASection*
createCDATASection(const XalanDOMString& data);
virtual XalanProcessingInstruction*
createProcessingInstruction(
const XalanDOMString& target,
const XalanDOMString& data);
virtual XalanAttr*
createAttribute(const XalanDOMString& name);
virtual XalanEntityReference*
createEntityReference(const XalanDOMString& name);
virtual XalanDocumentType*
getDoctype() const;
virtual XalanDOMImplementation*
getImplementation() const;
virtual XalanElement*
getDocumentElement() const;
virtual XalanNodeList*
getElementsByTagName(const XalanDOMString& tagname) const;
virtual XalanNode*
importNode(
XalanNode* importedNode,
bool deep);
virtual XalanElement*
createElementNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName);
virtual XalanAttr*
createAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName);
virtual XalanNodeList*
getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
virtual XalanElement*
getElementById(const XalanDOMString& elementId) const;
// These are some special interfaces to manage relationships between
// our nodes and Xerces nodes.
XalanNode*
mapNode(const DOM_Node& theXercesNode) const;
DOM_Node
mapNode(const XalanNode* theXalanNode) const;
XalanNode*
mapNode(NodeImpl* theXercesNodeImpl) const;
DOM_Attr
mapNode(const XalanAttr* theXalanNode) const;
NodeImpl*
mapNodeToImpl(const XalanNode* theXalanNode) const;
XalanAttr*
mapNode(const DOM_Attr& theXercesNode) const;
XalanElement*
mapNode(const DOM_Element& theXercesNode) const;
DOM_Document
getXercesDocument() const
{
return m_xercesDocument;
}
private:
// Destruction API...
void
destroyBridgeNode(XalanNode* theNode);
// Not implemented...
XercesDocumentBridge(const XercesDocumentBridge& theSource);
XercesDocumentBridge&
operator=(const XercesDocumentBridge& theRHS);
bool
operator==(const XercesDocumentBridge& theRHS) const;
// Private delete function...
void
destroyNode(XalanNode* theNode);
// More internal implementation stuff...
XalanNode*
internalCloneNode(
const XalanNode* theXalanNode,
const DOM_Node& theXercesNode,
bool deep);
// Factory methods for our implementation nodes...
XalanNode*
createBridgeNode(const DOM_Node& theXercesNode) const;
XercesElementBridge*
createBridgeNode(const DOM_Element& theXercesNode) const;
XercesDocumentFragmentBridge*
createBridgeNode(const DOM_DocumentFragment& theXercesNode) const;
XercesTextBridge*
createBridgeNode(const DOM_Text& theXercesNode) const;
XercesCommentBridge*
createBridgeNode(const DOM_Comment& theXercesNode) const;
XercesCDATASectionBridge*
createBridgeNode(const DOM_CDATASection& theXercesNode) const;
XercesProcessingInstructionBridge*
createBridgeNode(const DOM_ProcessingInstruction& theXercesNode) const;
XercesAttrBridge*
createBridgeNode(const DOM_Attr& theXercesNode) const;
XercesEntityBridge*
createBridgeNode(const DOM_Entity& theXercesNode) const;
XercesEntityReferenceBridge*
createBridgeNode(const DOM_EntityReference& theXercesNode) const;
XercesNotationBridge*
createBridgeNode(const DOM_Notation& theXercesNode) const;
// $$$ ToDo: This is because DOM_Document::getElementById() is not
// const...
mutable DOM_Document m_xercesDocument;
XercesBridgeNavigator m_navigator;
XercesNodeListBridge m_children;
XercesDocumentNamedNodeListCache m_cachedNodeLists;
mutable XercesToXalanNodeMap m_nodeMap;
#if defined(XALAN_NO_NAMESPACES)
auto_ptr<XalanDOMImplementation> m_domImplementation;
typedef set<XalanNode*> NodeSetType;
#else
std::auto_ptr<XalanDOMImplementation> m_domImplementation;
typedef std::set<XalanNode*> NodeSetType;
#endif
mutable NodeSetType m_nodes;
XercesDocumentTypeBridge* m_doctype;
};
#endif // !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentFragmentBridge.cpp
Index: XercesDocumentFragmentBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDocumentFragmentBridge.hpp"
#include <cassert>
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesDocumentFragmentBridge::XercesDocumentFragmentBridge(
const DOM_DocumentFragment& theXercesDOMDocumentFragment,
const XercesBridgeNavigator& theNavigator) :
XalanDocumentFragment(),
m_xercesNode(theXercesDOMDocumentFragment),
m_children(theXercesDOMDocumentFragment.getChildNodes(),
theNavigator.getOwnerDocument()),
m_navigator(theNavigator)
{
}
XercesDocumentFragmentBridge::~XercesDocumentFragmentBridge()
{
}
XalanDOMString
XercesDocumentFragmentBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesDocumentFragmentBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesDocumentFragmentBridge::NodeType
XercesDocumentFragmentBridge::getNodeType() const
{
return DOCUMENT_FRAGMENT_NODE;
}
XalanNode*
XercesDocumentFragmentBridge::getParentNode() const
{
return 0;
}
const XalanNodeList*
XercesDocumentFragmentBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesDocumentFragmentBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesDocumentFragmentBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesDocumentFragmentBridge::getPreviousSibling() const
{
return 0;
}
XalanNode*
XercesDocumentFragmentBridge::getNextSibling() const
{
return 0;
}
const XalanNamedNodeMap*
XercesDocumentFragmentBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesDocumentFragmentBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesDocumentFragmentBridge*
#endif
XercesDocumentFragmentBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesDocumentFragmentBridge* const theBridge =
static_cast<XercesDocumentFragmentBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesDocumentFragmentBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesDocumentFragmentBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesDocumentFragmentBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesDocumentFragmentBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesDocumentFragmentBridge::hasChildNodes() const
{
return m_xercesNode.hasChildNodes();
}
void
XercesDocumentFragmentBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesDocumentFragmentBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesDocumentFragmentBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesDocumentFragmentBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesDocumentFragmentBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesDocumentFragmentBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesDocumentFragmentBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentFragmentBridge.hpp
Index: XercesDocumentFragmentBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOCUMENTFRAGMENTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTFRAGMENTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_DocumentFragment.hpp>
#include <XalanDOM/XalanDocumentFragment.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentFragmentBridge : public XalanDocumentFragment
{
public:
XercesDocumentFragmentBridge(
const DOM_DocumentFragment& theXercesDOMDocumentFragment,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesDocumentFragmentBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesDocumentFragmentBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
private:
// Not implemented...
XercesDocumentFragmentBridge(const XercesDocumentFragmentBridge& theSource);
XercesDocumentFragmentBridge&
operator=(const XercesDocumentFragmentBridge& theSource);
bool
operator==(const XercesDocumentFragmentBridge& theRHS) const;
// Data members...
DOM_DocumentFragment m_xercesNode;
XercesNodeListBridge m_children;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESDOCUMENTFRAGMENTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentNamedNodeListCache.cpp
Index: XercesDocumentNamedNodeListCache.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDocumentNamedNodeListCache.hpp"
#include <cassert>
#include <dom/DOM_Document.hpp>
#include <dom/DOM_NodeList.hpp>
XercesDocumentNamedNodeListCache::XercesDocumentNamedNodeListCache(
const DOM_Document& theXercesDocument,
const XercesBridgeNavigator& theNavigator) :
XercesNamedNodeListCache(theNavigator),
m_xercesDocument(theXercesDocument)
{
}
XercesDocumentNamedNodeListCache::~XercesDocumentNamedNodeListCache()
{
}
DOM_NodeList
XercesDocumentNamedNodeListCache::getXercesNodeList(const XalanDOMString& tagname) const
{
return m_xercesDocument.getElementsByTagName(tagname);
}
DOM_NodeList
XercesDocumentNamedNodeListCache::getXercesNodeList(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_xercesDocument.getElementsByTagNameNS(namespaceURI, localName);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentNamedNodeListCache.hpp
Index: XercesDocumentNamedNodeListCache.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOCUMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_Document.hpp>
#include <XercesParserLiaison/XercesNamedNodeListCache.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentNamedNodeListCache : public XercesNamedNodeListCache
{
public:
XercesDocumentNamedNodeListCache(
const DOM_Document& theXercesDocument,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesDocumentNamedNodeListCache();
protected:
virtual DOM_NodeList
getXercesNodeList(const XalanDOMString& tagname) const;
virtual DOM_NodeList
getXercesNodeList(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
private:
const DOM_Document m_xercesDocument;
};
#endif // !defined(XERCESDOCUMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentTypeBridge.cpp
Index: XercesDocumentTypeBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDocumentTypeBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesDocumentTypeBridge::XercesDocumentTypeBridge(
const DOM_DocumentType& theXercesDOMDocumentType,
const XercesBridgeNavigator& theNavigator) :
XalanDocumentType(),
m_xercesNode(theXercesDOMDocumentType),
m_entities(m_xercesNode.getEntities(),
theNavigator.getOwnerDocument()),
m_notations(m_xercesNode.getNotations(),
theNavigator.getOwnerDocument()),
m_navigator(theNavigator)
{
}
XercesDocumentTypeBridge::~XercesDocumentTypeBridge()
{
}
XalanDOMString
XercesDocumentTypeBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesDocumentTypeBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesDocumentTypeBridge::NodeType
XercesDocumentTypeBridge::getNodeType() const
{
return DOCUMENT_TYPE_NODE;
}
XalanNode*
XercesDocumentTypeBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesDocumentTypeBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesDocumentTypeBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesDocumentTypeBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesDocumentTypeBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesDocumentTypeBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesDocumentTypeBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesDocumentTypeBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesDocumentTypeBridge*
#endif
XercesDocumentTypeBridge::cloneNode(bool deep) const
{
// $$$ ToDo: Fix this!! XercesDocumentType nodes can't be cloned yet...
assert(false);
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesDocumentTypeBridge* const theBridge =
static_cast<XercesDocumentTypeBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesDocumentTypeBridge::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeBridge::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeBridge::removeChild(XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeBridge::appendChild(XalanNode* /* newChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesDocumentTypeBridge::hasChildNodes() const
{
return false;
}
void
XercesDocumentTypeBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesDocumentTypeBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesDocumentTypeBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesDocumentTypeBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesDocumentTypeBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesDocumentTypeBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesDocumentTypeBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesDocumentTypeBridge::getName() const
{
return m_xercesNode.getName();
}
const XalanNamedNodeMap*
XercesDocumentTypeBridge::getEntities() const
{
return &m_entities;
}
const XalanNamedNodeMap*
XercesDocumentTypeBridge::getNotations() const
{
return &m_notations;
}
XalanDOMString
XercesDocumentTypeBridge::getPublicId() const
{
return m_xercesNode.getPublicId();
}
XalanDOMString
XercesDocumentTypeBridge::getSystemId() const
{
return m_xercesNode.getSystemId();
}
XalanDOMString
XercesDocumentTypeBridge::getInternalSubset() const
{
return m_xercesNode.getInternalSubset();
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDocumentTypeBridge.hpp
Index: XercesDocumentTypeBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOCUMENTTYPEBRIDGE_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTTYPEBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_DocumentType.hpp>
#include <XalanDOM/XalanDocumentType.hpp>
#include <XercesParserLiaison/XercesNamedNodeMapBridge.hpp>
class XercesBridgeNavigator;
class XercesDocumentBridge;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentTypeBridge : public XalanDocumentType
{
public:
XercesDocumentTypeBridge(
const DOM_DocumentType& theXercesDOMDocumentType,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesDocumentTypeBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesDocumentTypeBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanDocumentType...
/** @name Getter functions. */
//@{
/**
* The name of DTD; i.e., the name immediately following the
* <code>DOCTYPE</code> keyword in an XML source document.
*/
virtual XalanDOMString
getName() const;
/**
* This function returns a <code>NamedNodeMap</code> containing the general entities, both
* external and internal, declared in the DTD. Parameter entities are not contained.
* Duplicates are discarded.
*/
virtual const XalanNamedNodeMap*
getEntities() const;
/**
* This function returns a named node map containing an entry for
* each notation declared in a document's DTD. Duplicates are discarded.
*/
virtual const XalanNamedNodeMap*
getNotations() const;
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Get the public identifier of the external subset.
* @return The public identifier of the external subset.
*/
virtual XalanDOMString
getPublicId() const;
/**
* Get the system identifier of the external subset.
* @return The system identifier of the external subset.
*/
virtual XalanDOMString
getSystemId() const;
/**
* Get the internal subset as a string.
* @return The internal subset as a string.
*/
virtual XalanDOMString
getInternalSubset() const;
//@}
private:
// Not implemented...
XercesDocumentTypeBridge(const XercesDocumentTypeBridge& theSource);
XercesDocumentTypeBridge&
operator=(const XercesDocumentTypeBridge& theSource);
bool
operator==(const XercesDocumentTypeBridge& theRHS) const;
// Data members...
DOM_DocumentType m_xercesNode;
XercesNamedNodeMapBridge m_entities;
XercesNamedNodeMapBridge m_notations;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESDOCUMENTTYPEBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOM_NodeHack.cpp
Index: XercesDOM_NodeHack.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDOM_NodeHack.hpp"
XercesDOM_NodeHack::XercesDOM_NodeHack(NodeImpl* theImpl) :
DOM_Node(theImpl)
{
}
XercesDOM_NodeHack::~XercesDOM_NodeHack()
{
}
XercesDOM_AttrHack::XercesDOM_AttrHack(AttrImpl* theImpl) :
DOM_Attr(theImpl)
{
}
XercesDOM_AttrHack::~XercesDOM_AttrHack()
{
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOM_NodeHack.hpp
Index: XercesDOM_NodeHack.hpp
===================================================================
#if !defined(XERCESDOM_NODEHACK_HEADER_GUARD_1357924680)
#define XERCESDOM_NODEHACK_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_Node.hpp>
#include <dom/DOM_Attr.hpp>
// An evil class to hack the Xerces smart-pointer class. I'm
// only doing this because I have to...
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOM_NodeHack : public DOM_Node
{
public:
XercesDOM_NodeHack(NodeImpl* theImpl = 0);
~XercesDOM_NodeHack();
NodeImpl*
getImpl() const
{
return fImpl;
}
static NodeImpl*
getImpl(const DOM_Node& theNode)
{
#if defined(XALAN_OLD_STYLE_CASTS)
return ((const XercesDOM_NodeHack&)theNode).getImpl();
#else
return static_cast<const XercesDOM_NodeHack&>(theNode).getImpl();
#endif
}
};
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOM_AttrHack : public DOM_Attr
{
public:
XercesDOM_AttrHack(AttrImpl* theImpl = 0);
~XercesDOM_AttrHack();
};
#endif // !defined(XERCESDOM_NODEHACK_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMException.cpp
Index: XercesDOMException.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDOMException.hpp"
#include <cassert>
XercesDOMException::XercesDOMException(ExceptionCode code) :
XalanDOMException(code)
{
}
XercesDOMException::XercesDOMException(const DOM_DOMException& theException) :
XalanDOMException(translateErrorCode(theException.code))
{
}
XercesDOMException::XercesDOMException(const XercesDOMException& theSource) :
XalanDOMException(theSource)
{
}
XercesDOMException::~XercesDOMException()
{
}
XercesDOMException::ExceptionCode
XercesDOMException::translateErrorCode(DOM_DOMException::ExceptionCode theCode)
{
ExceptionCode theXalanCode = UNKNOWN;
switch(theCode)
{
case DOM_DOMException::INDEX_SIZE_ERR:
theXalanCode = INDEX_SIZE_ERR;
break;
case DOM_DOMException::DOMSTRING_SIZE_ERR:
theXalanCode = DOMSTRING_SIZE_ERR;
break;
case DOM_DOMException::HIERARCHY_REQUEST_ERR:
theXalanCode = HIERARCHY_REQUEST_ERR;
break;
case DOM_DOMException::WRONG_DOCUMENT_ERR:
theXalanCode = WRONG_DOCUMENT_ERR;
break;
case DOM_DOMException::INVALID_CHARACTER_ERR:
theXalanCode = INVALID_CHARACTER_ERR;
break;
case DOM_DOMException::NO_DATA_ALLOWED_ERR:
theXalanCode = NO_DATA_ALLOWED_ERR;
break;
case DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR:
theXalanCode = NO_MODIFICATION_ALLOWED_ERR;
break;
case DOM_DOMException::NOT_FOUND_ERR:
theXalanCode = NOT_FOUND_ERR;
break;
case DOM_DOMException::NOT_SUPPORTED_ERR:
theXalanCode = INDEX_SIZE_ERR;
break;
case DOM_DOMException::INUSE_ATTRIBUTE_ERR:
theXalanCode = INUSE_ATTRIBUTE_ERR;
break;
case DOM_DOMException::INVALID_STATE_ERR:
theXalanCode = INVALID_STATE_ERR;
break;
case DOM_DOMException::SYNTAX_ERR:
theXalanCode = SYNTAX_ERR;
break;
case DOM_DOMException::INVALID_MODIFICATION_ERR:
theXalanCode = INVALID_MODIFICATION_ERR;
break;
case DOM_DOMException::NAMESPACE_ERR:
theXalanCode = NAMESPACE_ERR;
break;
case DOM_DOMException::INVALID_ACCESS_ERR:
theXalanCode = INVALID_ACCESS_ERR;
break;
default:
assert(false);
break;
};
return theXalanCode;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMException.hpp
Index: XercesDOMException.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOMEXCEPTION_HEADER_GUARD_1357924680)
#define XERCESDOMEXCEPTION_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_DOMException.hpp>
#include <XalanDOM/XalanDOMException.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMException : public XalanDOMException
{
public:
/** @name Constructors and assignment operator */
//@{
/**
* Constructor which takes an error code.
*
* @param code The error code which indicates the exception
*/
explicit
XercesDOMException(ExceptionCode code = UNKNOWN);
/**
* Constructor which takes a Xerces exception and
* translates it into a XercesDOMException.
*
* @param code The Xerces DOM_DOMException instance.
*/
XercesDOMException(const DOM_DOMException& theException);
/**
* Copy constructor.
*
* @param other The object to be copied.
*/
XercesDOMException(const XercesDOMException& theSource);
//@}
/** @name Destructor. */
//@{
/**
* Destructor for XercesDOMException.
*/
virtual
~XercesDOMException();
//@}
private:
static ExceptionCode
translateErrorCode(DOM_DOMException::ExceptionCode theCode);
};
#endif // !defined(XERCESDOMEXCEPTION_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMImplementationBridge.cpp
Index: XercesDOMImplementationBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesDOMImplementationBridge.hpp"
#include <dom/DOM_DOMImplementation.hpp>
#include "XercesDOMException.hpp"
XercesDOMImplementationBridge::XercesDOMImplementationBridge(DOM_DOMImplementation& theXercesDOMImplementation) :
XalanDOMImplementation(),
m_xercesNode(theXercesDOMImplementation)
{
}
XercesDOMImplementationBridge::~XercesDOMImplementationBridge()
{
}
XercesDOMImplementationBridge::XercesDOMImplementationBridge(const XercesDOMImplementationBridge& theSource) :
XalanDOMImplementation(theSource),
m_xercesNode(theSource.m_xercesNode)
{
}
bool
XercesDOMImplementationBridge::hasFeature(
const XalanDOMString& feature,
const XalanDOMString& version)
{
return m_xercesNode.hasFeature(feature, version);
}
XalanDocumentType*
XercesDOMImplementationBridge::createDocumentType(
const DOMString& qualifiedName,
const DOMString& publicId,
const DOMString& systemId)
{
// $$$ ToDo: Fix this!!!
throw XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanDocument*
XercesDOMImplementationBridge::createDocument(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName,
const XalanDocumentType& doctype)
{
// $$$ ToDo: Fix this!!!
throw XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMImplementationBridge.hpp
Index: XercesDOMImplementationBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESDOMIMPLEMENTATIONBRIDGE_HEADER_GUARD_1357924680)
#define XERCESDOMIMPLEMENTATIONBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanDOMImplementation.hpp>
class DOM_DOMImplementation;
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMImplementationBridge : public XalanDOMImplementation
{
public:
XercesDOMImplementationBridge(DOM_DOMImplementation& theXercesDOMImplementation);
virtual
~XercesDOMImplementationBridge();
/** @name Getter functions */
//@{
/**
* Test if the DOM implementation implements a specific feature.
*
* @param feature The string of the feature to test (case-insensitive). The legal
* values are defined throughout this specification. The string must be
* an <EM>XML name</EM> (see also Compliance).
* @param version This is the version number of the package name to test.
* In Level 1, this is the string "1.0". If the version is not specified,
* supporting any version of the feature will cause the method to return
* <code>true</code>.
* @return <code>true</code> if the feature is implemented in the specified
* version, <code>false</code> otherwise.
*/
virtual bool
hasFeature(
const XalanDOMString& feature,
const XalanDOMString& version);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Creates an empty <code>DOM_DocumentType</code> node.
* Entity declarations and notations are not made available.
* Entity reference expansions and default attribute additions
* do not occur. It is expected that a future version of the DOM
* will provide a way for populating a <code>DOM_DocumentType</code>.
* @param qualifiedName The <em>qualified name</em>
* of the document type to be created.
* @param publicId The external subset public identifier.
* @param systemId The external subset system identifier.
* @return A new <code>DocumentType</code> node with
* <code>Node.ownerDocument</code> set to <code>null</code>.
*/
virtual XalanDocumentType*
createDocumentType(
const DOMString& qualifiedName,
const DOMString& publicId,
const DOMString& systemId);
/**
* Creates an XML <code>DOM_Document</code> object of the specified type
* with its document element.
* @param namespaceURI The <em>namespace URI</em> of
* the document element to create, or <code>null</code>.
* @param qualifiedName The <em>qualified name</em>
* of the document element to be created.
* @param doctype The type of document to be created or <code>null</code>.
* <p>When <code>doctype</code> is not <code>null</code>, its
* <code>Node.ownerDocument</code> attribute is set to the document
* being created.
* @return A new <code>Document</code> object.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
* been used with a different document.
*/
virtual XalanDocument*
createDocument(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName,
const XalanDocumentType& doctype);
//@}
private:
// These are not defined...
XercesDOMImplementationBridge(const XercesDOMImplementationBridge& theSource);
XercesDOMImplementationBridge&
operator=(const XercesDOMImplementationBridge& theSource);
bool
operator==(const XercesDOMImplementationBridge& theRHS) const;
// Data members...
DOM_DOMImplementation& m_xercesNode;
};
#endif // !defined (XERCESDOMIMPLEMENTATIONBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesElementBridge.cpp
Index: XercesElementBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesElementBridge.hpp"
#include <XalanDOM/XalanAttr.hpp>
#include "XercesDOMException.hpp"
#include "XercesBridgeNavigator.hpp"
#include "XercesDocumentBridge.hpp"
XercesElementBridge::XercesElementBridge(
const DOM_Element& theXercesElement,
const XercesBridgeNavigator& theNavigator) :
XalanElement(),
m_xercesNode(theXercesElement),
m_navigator(theNavigator),
m_children(theXercesElement.getChildNodes(),
theNavigator),
m_attributes(theXercesElement.getAttributes(),
theNavigator),
m_cachedNodeLists(theXercesElement,
theNavigator)
{
}
XercesElementBridge::~XercesElementBridge()
{
}
XalanDOMString
XercesElementBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesElementBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesElementBridge::NodeType
XercesElementBridge::getNodeType() const
{
return ELEMENT_NODE;
}
XalanNode*
XercesElementBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesElementBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesElementBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesElementBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesElementBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesElementBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesElementBridge::getAttributes() const
{
return &m_attributes;
}
XalanDocument*
XercesElementBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XalanElementBridge*
#endif
XercesElementBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XalanElementBridge* const theBridge =
static_cast<XalanElementBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesElementBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesElementBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesElementBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesElementBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesElementBridge::hasChildNodes() const
{
return m_xercesNode.hasChildNodes();
}
void
XercesElementBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesElementBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesElementBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesElementBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesElementBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesElementBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesElementBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesElementBridge::getTagName() const
{
return m_xercesNode.getTagName();
}
XalanDOMString
XercesElementBridge::getAttribute(const XalanDOMString& name) const
{
return m_xercesNode.getAttribute(name);
}
XalanAttr*
XercesElementBridge::getAttributeNode(const XalanDOMString& name) const
{
return static_cast<XalanAttr*>(m_attributes.getNamedItem(name));
}
XalanNodeList*
XercesElementBridge::getElementsByTagName(const XalanDOMString& name) const
{
return m_cachedNodeLists.getElementsByTagName(name);
}
void
XercesElementBridge::setAttribute(
const XalanDOMString& name,
const XalanDOMString& value)
{
try
{
m_xercesNode.setAttribute(name, value);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanAttr*
XercesElementBridge::setAttributeNode(XalanAttr* newAttr)
{
assert(newAttr != 0);
const DOM_Attr theXercesAttrNode =
m_navigator.mapNode(newAttr);
assert(theXercesAttrNode.isNull() == false);
XalanAttr* theXalanAttrResult = 0;
try
{
const DOM_Attr theXercesAttrResult =
m_xercesNode.setAttributeNode(theXercesAttrNode);
theXalanAttrResult = m_navigator.mapNode(theXercesAttrResult);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanAttrResult;
}
XalanAttr*
XercesElementBridge::removeAttributeNode(XalanAttr* oldAttr)
{
assert(oldAttr != 0);
const DOM_Attr theXercesAttrNode =
m_navigator.mapNode(oldAttr);
assert(theXercesAttrNode.isNull() == false);
XalanAttr* theXalanAttrResult = 0;
try
{
const DOM_Attr theXercesAttrResult =
m_xercesNode.removeAttributeNode(theXercesAttrNode);
theXalanAttrResult = m_navigator.mapNode(theXercesAttrResult);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanAttrResult;
}
void
XercesElementBridge::removeAttribute(const XalanDOMString& name)
{
try
{
m_xercesNode.removeAttribute(name);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesElementBridge::getAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_xercesNode.getAttributeNS(namespaceURI, localName);
}
void
XercesElementBridge::setAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName,
const XalanDOMString& value)
{
try
{
m_xercesNode.setAttributeNS(namespaceURI, qualifiedName, value);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesElementBridge::removeAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName)
{
try
{
m_xercesNode.removeAttributeNS(namespaceURI, localName);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanAttr*
XercesElementBridge::getAttributeNodeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
const DOM_Attr theAttrNode =
m_xercesNode.getAttributeNodeNS(namespaceURI, localName);
return m_navigator.mapNode(theAttrNode);
}
XalanAttr*
XercesElementBridge::setAttributeNodeNS(XalanAttr* newAttr)
{
assert(newAttr != 0);
const DOM_Attr theXercesAttrNode =
m_navigator.mapNode(newAttr);
assert(theXercesAttrNode.isNull() == false);
XalanAttr* theXalanAttrResult = 0;
try
{
const DOM_Attr theXercesAttrResult =
m_xercesNode.setAttributeNodeNS(theXercesAttrNode);
theXalanAttrResult = m_navigator.mapNode(theXercesAttrResult);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanAttrResult;
}
XalanNodeList*
XercesElementBridge::getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_cachedNodeLists.getElementsByTagNameNS(namespaceURI, localName);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesElementBridge.hpp
Index: XercesElementBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESELEMENTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESELEMENTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <map>
#include <dom/DOM_Element.hpp>
#include <XalanDOM/XalanElement.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XercesParserLiaison/XercesElementNamedNodeListCache.hpp>
#include <XercesParserLiaison/XercesNamedNodeMapBridge.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesElementBridge : public XalanElement
{
public:
XercesElementBridge(
const DOM_Element& theXercesElement,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesElementBridge();
/**
* Gets the name of this node.
*/
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XalanElementBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanElement...
/**
* The name of the element.
*
* For example, in: <elementExample
* id="demo"> ... </elementExample> , <code>tagName</code> has
* the value <code>"elementExample"</code>. Note that this is
* case-preserving in XML, as are all of the operations of the DOM.
*/
virtual XalanDOMString
getTagName() const;
/**
* Retrieves an attribute value by name.
*
* @param name The name of the attribute to retrieve.
* @return The <code>DOM_Attr</code> value as a string, or the empty string if
* that attribute does not have a specified or default value.
*/
virtual XalanDOMString
getAttribute(const XalanDOMString& name) const;
/**
* Retrieves an <code>DOM_Attr</code> node by name.
*
* @param name The name (<CODE>nodeName</CODE>) of the attribute to retrieve.
* @return The <code>DOM_Attr</code> node with the specified name (<CODE>nodeName</CODE>) or
* <code>null</code> if there is no such attribute.
*/
virtual XalanAttr*
getAttributeNode(const XalanDOMString& name) const;
/**
* Returns a <code>NodeList</code> of all descendant elements with a given
* tag name, in the order in which they would be encountered in a preorder
* traversal of the <code>DOM_Element</code> tree. Caller is
* responsible for deleting the XalanNodeList instance.
*
* @param name The name of the tag to match on. The special value "*"
* matches all tags.
* @return A list of matching <code>DOM_Element</code> nodes.
*/
virtual XalanNodeList*
getElementsByTagName(const XalanDOMString& name) const;
//@}
/** @name Set functions. */
//@{
/**
* Adds a new attribute.
*
* If an attribute with that name is already present
* in the element, its value is changed to be that of the value parameter.
* This value is a simple string, it is not parsed as it is being set. So
* any markup (such as syntax to be recognized as an entity reference) is
* treated as literal text, and needs to be appropriately escaped by the
* implementation when it is written out. In order to assign an attribute
* value that contains entity references, the user must create an
* <code>DOM_Attr</code> node plus any <code>Text</code> and
* <code>EntityReference</code> nodes, build the appropriate subtree, and
* use <code>setAttributeNode</code> to assign it as the value of an
* attribute.
* @param name The name of the attribute to create or alter.
* @param value Value to set in string form.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified name contains an
* illegal character.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
setAttribute(
const XalanDOMString& name,
const XalanDOMString& value);
/**
* Adds a new attribute.
*
* If an attribute with that name (<CODE>nodeName</CODE>) is already present
* in the element, it is replaced by the new one.
* @param newAttr The <code>DOM_Attr</code> node to add to the attribute list.
* @return If the <code>newAttr</code> attribute replaces an existing
* attribute, the replaced
* <code>DOM_Attr</code> node is returned, otherwise <code>null</code> is
* returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a
* different document than the one that created the element.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an
* attribute of another <code>DOM_Element</code> object. The DOM user must
* explicitly clone <code>DOM_Attr</code> nodes to re-use them in other
* elements.
*/
virtual XalanAttr*
setAttributeNode(XalanAttr* newAttr);
//@}
/** @name Functions which modify the Element. */
//@{
/**
* Removes the specified attribute node.
* If the removed <CODE>DOM_Attr</CODE>
* has a default value it is immediately replaced. The replacing attribute
* has the same namespace URI and local name, as well as the original prefix,
* when applicable.
*
* @param oldAttr The <code>DOM_Attr</code> node to remove from the attribute
* list.
* @return The <code>DOM_Attr</code> node that was removed.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an attribute
* of the element.
*/
virtual XalanAttr*
removeAttributeNode(XalanAttr* oldAttr);
/**
* Removes an attribute by name.
*
* If the removed attribute
* is known to have a default value, an attribute immediately appears
* containing the default value as well as the corresponding namespace URI,
* local name, and prefix when applicable.<BR>To remove an attribute by local
* name and namespace URI, use the <CODE>removeAttributeNS</CODE> method.
* @param name The name of the attribute to remove.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
removeAttribute(const XalanDOMString& name);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Retrieves an attribute value by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
* the attribute to retrieve.
* @param localName The <em>local name</em> of the
* attribute to retrieve.
* @return The <code>DOM_Attr</code> value as a string, or an empty string if
* that attribute does not have a specified or default value.
*/
virtual XalanDOMString
getAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
/**
* Adds a new attribute. If the given
* <CODE>namespaceURI</CODE> is <CODE>null</CODE> or an empty string and the
* <CODE>qualifiedName</CODE> has a prefix that is "xml", the new attribute
* is bound to the predefined namespace
* "http://www.w3.org/XML/1998/namespace".
* If an attribute with the same local name and namespace URI is already
* present on the element, its prefix is changed to be the prefix part of the
* <CODE>qualifiedName</CODE>, and its value is changed to be the
* <CODE>value</CODE> parameter.
* This value is a simple string, it is
* not parsed as it is being set. So any markup (such as syntax to be
* recognized as an entity reference) is treated as literal text, and
* needs to be appropriately escaped by the implementation when it is
* written out. In order to assign an attribute value that contains entity
* references, the user must create a <code>DOM_Attr</code> node plus any
* <code>DOM_Text</code> and <code>DOM_EntityReference</code> nodes, build the
* appropriate subtree, and use <code>setAttributeNodeNS</code> or
* <code>setAttributeNode</code> to assign it as the value of an
* attribute.
* @param namespaceURI The <em>namespace URI</em> of
* the attribute to create or alter.
* @param localName The <em>local name</em> of the
* attribute to create or alter.
* @param value The value to set in string form.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an
* illegal character.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the <CODE>qualifiedName</CODE> is
* malformed, if the <CODE>qualifiedName</CODE> has a prefix that is
* "xml" and the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE>
* nor an empty string nor "http://www.w3.org/XML/1998/namespace", or
* if the <CODE>qualifiedName</CODE> has a prefix that is "xmlns" but
* the <CODE>namespaceURI</CODE> is neither <CODE>null</CODE> nor an
* empty string, or if if the <CODE>qualifiedName</CODE> has a prefix
* different from "xml" and "xmlns" and the <CODE>namespaceURI</CODE>
* is <CODE>null</CODE> or an empty string.
*/
virtual void
setAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName,
const XalanDOMString& value);
/**
* Removes an attribute by local name and namespace URI. If the
* removed attribute has a default value it is immediately replaced.
* The replacing attribute has the same namespace URI and local name, as well as
* the original prefix.<BR>HTML-only DOM implementations do not need to
* implement this method.
*
* @param namespaceURI The <em>namespace URI</em> of
* the attribute to remove.
* @param localName The <em>local name</em> of the
* attribute to remove.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
removeAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName);
/**
* Retrieves an <code>DOM_Attr</code> node by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
* the attribute to retrieve.
* @param localName The <em>local name</em> of the
* attribute to retrieve.
* @return The <code>DOM_Attr</code> node with the specified attribute local
* name and namespace URI or <code>null</code> if there is no such attribute.
*/
virtual XalanAttr*
getAttributeNodeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
/**
* Adds a new attribute.
*
* If an attribute with that local name and namespace URI is already present
* in the element, it is replaced by the new one.
* @param newAttr The <code>DOM_Attr</code> node to add to the attribute list.
* @return If the <code>newAttr</code> attribute replaces an existing
* attribute with the same <em>local name</em> and <em>namespace URI</em>,
* the replaced <code>DOM_Attr</code> node is
* returned, otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a
* different document than the one that created the element.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an
* attribute of another <code>DOM_Element</code> object. The DOM user must
* explicitly clone <code>DOM_Attr</code> nodes to re-use them in other
* elements.
*/
virtual XalanAttr*
setAttributeNodeNS(XalanAttr* newAttr);
/**
* Returns a <code>DOM_NodeList</code> of all the <code>DOM_Element</code>s
* with a given local name and namespace URI in the order in which they
* would be encountered in a preorder traversal of the
* <code>DOM_Document</code> tree, starting from this node. Caller is
* responsible for deleting the XalanNodeList instance.
*
* @param namespaceURI The <em>namespace URI</em> of
* the elements to match on. The special value "*" matches all
* namespaces.
* @param localName The <em>local name</em> of the
* elements to match on. The special value "*" matches all local names.
* @return A new <code>DOM_NodeList</code> object containing all the matched
* <code>Element</code>s.
*/
virtual XalanNodeList*
getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
//@}
private:
// Not implemented...
XercesElementBridge(const XercesElementBridge& theSource);
XalanNode&
operator=(const XalanNode& theSource);
bool
operator==(const XercesElementBridge& theRHS) const;
// Data members...
DOM_Element m_xercesNode;
const XercesBridgeNavigator& m_navigator;
XercesNodeListBridge m_children;
XercesNamedNodeMapBridge m_attributes;
XercesElementNamedNodeListCache m_cachedNodeLists;
};
#endif // !defined(XERCESELEMENTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesElementNamedNodeListCache.cpp
Index: XercesElementNamedNodeListCache.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesElementNamedNodeListCache.hpp"
#include <cassert>
#include <dom/DOM_Element.hpp>
#include <dom/DOM_NodeList.hpp>
XercesElementNamedNodeListCache::XercesElementNamedNodeListCache(
const DOM_Element& theXercesElement,
const XercesBridgeNavigator& theNavigator) :
XercesNamedNodeListCache(theNavigator),
m_xercesElement(theXercesElement)
{
}
XercesElementNamedNodeListCache::~XercesElementNamedNodeListCache()
{
}
DOM_NodeList
XercesElementNamedNodeListCache::getXercesNodeList(const XalanDOMString& tagname) const
{
return m_xercesElement.getElementsByTagName(tagname);
}
DOM_NodeList
XercesElementNamedNodeListCache::getXercesNodeList(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_xercesElement.getElementsByTagNameNS(namespaceURI, localName);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesElementNamedNodeListCache.hpp
Index: XercesElementNamedNodeListCache.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESELEMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
#define XERCESELEMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_Element.hpp>
#include <XercesParserLiaison/XercesNamedNodeListCache.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesElementNamedNodeListCache : public XercesNamedNodeListCache
{
public:
XercesElementNamedNodeListCache(
const DOM_Element& theXercesElement,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesElementNamedNodeListCache();
protected:
virtual DOM_NodeList
getXercesNodeList(const XalanDOMString& tagname) const;
virtual DOM_NodeList
getXercesNodeList(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
private:
const DOM_Element m_xercesElement;
};
#endif // !defined(XERCESELEMENTNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesEntityBridge.cpp
Index: XercesEntityBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesEntityBridge.hpp"
#include "XercesBridgeNavigator.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesEntityBridge::XercesEntityBridge(
const DOM_Entity& theXercesDOMEntity,
const XercesBridgeNavigator& theNavigator) :
XalanEntity(),
m_xercesNode(theXercesDOMEntity),
m_navigator(theNavigator),
m_children(theXercesDOMEntity.getChildNodes(),
theNavigator)
{
}
XercesEntityBridge::~XercesEntityBridge()
{
}
XalanDOMString
XercesEntityBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesEntityBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesEntityBridge::NodeType
XercesEntityBridge::getNodeType() const
{
return ENTITY_NODE;
}
XalanNode*
XercesEntityBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesEntityBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesEntityBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesEntityBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesEntityBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesEntityBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesEntityBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesEntityBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesEntityBridge*
#endif
XercesEntityBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesEntityBridge* const theBridge =
static_cast<XercesEntityBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesEntityBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesEntityBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesEntityBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesEntityBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesEntityBridge::hasChildNodes() const
{
return m_xercesNode.hasChildNodes();
}
void
XercesEntityBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesEntityBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesEntityBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesEntityBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesEntityBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesEntityBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesEntityBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesEntityBridge::getPublicId() const
{
return m_xercesNode.getPublicId();
}
XalanDOMString
XercesEntityBridge::getSystemId() const
{
return m_xercesNode.getSystemId();
}
XalanDOMString
XercesEntityBridge::getNotationName() const
{
return m_xercesNode.getNotationName();
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesEntityBridge.hpp
Index: XercesEntityBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESENTITYBRIDGE_HEADER_GUARD_1357924680)
#define XERCESENTITYBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_Entity.hpp>
#include <XalanDOM/XalanEntity.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesEntityBridge : public XalanEntity
{
public:
XercesEntityBridge(
const DOM_Entity& theXercesDOMEntity,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesEntityBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesEntityBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanEntity...
/**
* Get the public identifier of this notation.
*
* If the public identifier was not
* specified, this is <code>null</code>.
* @return Returns the public identifier of the notation
*/
virtual XalanDOMString
getPublicId() const;
/**
* Get the system identifier of this notation.
*
* If the system identifier was not
* specified, this is <code>null</code>.
* @return Returns the system identifier of the notation
*/
virtual XalanDOMString
getSystemId() const;
/**
* For unparsed entities, the name of the notation for the entity.
*
* For parsed entities, this is <code>null</code>.
*/
virtual XalanDOMString
getNotationName() const;
private:
// Not implemented...
XercesEntityBridge(const XercesEntityBridge& theSource);
XercesEntityBridge&
operator=(const XercesEntityBridge& theSource);
bool
operator==(const XercesEntityBridge& theRHS) const;
// Data members...
DOM_Entity m_xercesNode;
const XercesBridgeNavigator& m_navigator;
XercesNodeListBridge m_children;
};
#endif // !defined(XERCESENTITYBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesEntityReferenceBridge.cpp
Index: XercesEntityReferenceBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesEntityReferenceBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesEntityReferenceBridge::XercesEntityReferenceBridge(
const DOM_EntityReference& theXercesDOMEntityReference,
const XercesBridgeNavigator& theNavigator) :
XalanEntityReference(),
m_xercesNode(theXercesDOMEntityReference),
m_navigator(theNavigator),
m_children(theXercesDOMEntityReference.getChildNodes(),
theNavigator)
{
}
XercesEntityReferenceBridge::~XercesEntityReferenceBridge()
{
}
XalanDOMString
XercesEntityReferenceBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesEntityReferenceBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesEntityReferenceBridge::NodeType
XercesEntityReferenceBridge::getNodeType() const
{
return ENTITY_REFERENCE_NODE;
}
XalanNode*
XercesEntityReferenceBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesEntityReferenceBridge::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesEntityReferenceBridge::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesEntityReferenceBridge::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesEntityReferenceBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesEntityReferenceBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesEntityReferenceBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesEntityReferenceBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesEntityReferenceBridge*
#endif
XercesEntityReferenceBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesEntityReferenceBridge* const theBridge =
static_cast<XercesEntityReferenceBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesEntityReferenceBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesEntityReferenceBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesEntityReferenceBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesEntityReferenceBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesEntityReferenceBridge::hasChildNodes() const
{
return m_xercesNode.hasChildNodes();
}
void
XercesEntityReferenceBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesEntityReferenceBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesEntityReferenceBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesEntityReferenceBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesEntityReferenceBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesEntityReferenceBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesEntityReferenceBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesEntityReferenceBridge.hpp
Index: XercesEntityReferenceBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESENTITYREFERENCEBRIDGE_HEADER_GUARD_1357924680)
#define XERCESENTITYREFERENCEBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_EntityReference.hpp>
#include <XalanDOM/XalanEntityReference.hpp>
#include <XercesParserLiaison/XercesNodeListBridge.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesEntityReferenceBridge : public XalanEntityReference
{
public:
XercesEntityReferenceBridge(
const DOM_EntityReference& theXercesDOMEntityReference,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesEntityReferenceBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesEntityReferenceBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
private:
// Not implemented...
XercesEntityReferenceBridge(const XercesEntityReferenceBridge& theSource);
XercesEntityReferenceBridge&
operator=(const XercesEntityReferenceBridge& theSource);
bool
operator==(const XercesEntityReferenceBridge& theRHS) const;
// Data members...
DOM_EntityReference m_xercesNode;
const XercesBridgeNavigator& m_navigator;
XercesNodeListBridge m_children;
};
#endif // !defined(XERCESENTITYREFERENCEBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeListCache.cpp
Index: XercesNamedNodeListCache.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesNamedNodeListCache.hpp"
#include <algorithm>
#include <cassert>
#include <PlatformSupport/STLHelper.hpp>
#include <dom/DOM_Node.hpp>
#include "XercesNodeListBridge.hpp"
XercesNamedNodeListCache::XercesNamedNodeListCache(const XercesBridgeNavigator& theNavigator) :
m_navigator(theNavigator),
m_cachedNodeLists(),
m_cachedNodeListsNS()
{
}
XercesNamedNodeListCache::~XercesNamedNodeListCache()
{
#if !defined(XALAN_NO_NAMESPACES)
using std::for_each;
#endif
for_each(m_cachedNodeLists.begin(),
m_cachedNodeLists.end(),
makeMapValueDeleteFunctor(m_cachedNodeLists));
for_each(m_cachedNodeListsNS.begin(),
m_cachedNodeListsNS.end(),
makeMapValueDeleteFunctor(m_cachedNodeListsNS));
}
XercesNodeListBridge*
XercesNamedNodeListCache::getElementsByTagName(const XalanDOMString& tagname) const
{
const NodeListCacheType::const_iterator i =
m_cachedNodeLists.find(tagname);
if (i != m_cachedNodeLists.end())
{
return i->second;
}
else
{
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
#endif
XercesNodeListBridge* const theNewBridge =
new XercesNodeListBridge(getXercesNodeList(tagname),
m_navigator);
#if defined(XALAN_NO_MUTABLE)
return ((NodeListCacheType&)m_cachedNodeLists).insert(make_pair(tagname,
theNewBridge)).first->second;
#else
return m_cachedNodeLists.insert(make_pair(tagname,
theNewBridge)).first->second;
#endif
}
}
XercesNodeListBridge*
XercesNamedNodeListCache::getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
XalanDOMString theSearchString(namespaceURI + localName);
const NodeListCacheType::const_iterator i =
m_cachedNodeListsNS.find(theSearchString);
if (i != m_cachedNodeLists.end())
{
return i->second;
}
else
{
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
#endif
XercesNodeListBridge* const theNewBridge =
new XercesNodeListBridge(getXercesNodeList(namespaceURI, localName),
m_navigator);
#if defined(XALAN_NO_MUTABLE)
return ((NodeListCacheType&)m_cachedNodeLists).insert(make_pair(theSearchString,
theNewBridge)).first->second;
#else
return m_cachedNodeLists.insert(make_pair(theSearchString,
theNewBridge)).first->second;
#endif
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeListCache.hpp
Index: XercesNamedNodeListCache.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
#define XERCESNAMEDNODELISTCACHE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <map>
#include <XalanDOM/XalanDOMString.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
class DOM_NodeList;
class XercesBridgeNavigator;
class XercesNodeListBridge;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNamedNodeListCache
{
public:
XercesNamedNodeListCache(const XercesBridgeNavigator& theNavigator);
virtual
~XercesNamedNodeListCache();
virtual XercesNodeListBridge*
getElementsByTagName(const XalanDOMString& tagname) const;
virtual XercesNodeListBridge*
getElementsByTagNameNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
protected:
virtual DOM_NodeList
getXercesNodeList(const XalanDOMString& tagname) const = 0;
virtual DOM_NodeList
getXercesNodeList(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const = 0;
private:
const XercesBridgeNavigator& m_navigator;
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanDOMString, XercesNodeListBridge*> NodeListCacheType;
#else
typedef std::map<XalanDOMString, XercesNodeListBridge*> NodeListCacheType;
#endif
#if defined(XALAN_NO_MUTABLE)
NodeListCacheType m_cachedNodeLists;
NodeListCacheType m_cachedNodeListsNS;
#else
mutable NodeListCacheType m_cachedNodeLists;
mutable NodeListCacheType m_cachedNodeListsNS;
#endif
};
#endif // !defined(XERCESNAMEDNODELISTCACHE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapBridge.cpp
Index: XercesNamedNodeMapBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesNamedNodeMapBridge.hpp"
#include <algorithm>
#include <cassert>
#include <dom/DOM_Node.hpp>
#include "XercesDocumentBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesElementBridge.hpp"
XercesNamedNodeMapBridge::XercesNamedNodeMapBridge(
const DOM_NamedNodeMap& theXercesNamedNodeMap,
const XercesBridgeNavigator& theNavigator) :
m_xercesNamedNodeMap(theXercesNamedNodeMap),
m_navigator(theNavigator)
{
assert(m_xercesNamedNodeMap != reinterpret_cast<const DOM_NullPtr*>(0));
}
XercesNamedNodeMapBridge::~XercesNamedNodeMapBridge()
{
}
XalanNode*
XercesNamedNodeMapBridge::setNamedItem(XalanNode* arg)
{
assert(arg != 0);
XalanNode* theXalanNode = 0;
// Find the DOM_Node that corresponds to the bridge node...
const DOM_Node theNode = m_navigator.mapNode(arg);
if (theNode.isNull() == true)
{
// Doesn't belong to this doc, so throw...
throw XercesDOMException(XercesDOMException::WRONG_DOCUMENT_ERR);
}
try
{
const DOM_Node theOldXercesNode =
m_xercesNamedNodeMap.setNamedItem(theNode);
if (theNode.isNull() == false)
{
// A node was replaced, so map the replacement...
theXalanNode = m_navigator.mapNode(theOldXercesNode);
assert(theXalanNode != 0);
}
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanNode;
}
XalanNode*
XercesNamedNodeMapBridge::item(unsigned int index) const
{
return m_navigator.mapNode(m_xercesNamedNodeMap.item(index));
}
XalanNode*
XercesNamedNodeMapBridge::getNamedItem(const XalanDOMString& name) const
{
return m_navigator.mapNode(m_xercesNamedNodeMap.getNamedItem(name));
}
unsigned int
XercesNamedNodeMapBridge::getLength() const
{
return m_xercesNamedNodeMap.getLength();
}
XalanNode*
XercesNamedNodeMapBridge::removeNamedItem(const XalanDOMString& name)
{
XalanNode* theXalanNode = 0;
try
{
const DOM_Node theXercesNode =
m_xercesNamedNodeMap.removeNamedItem(name);
// A node was removed, so get it corresponding XalanNode...
theXalanNode = m_navigator.mapNode(theXercesNode);
assert(theXalanNode != 0);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanNode;
}
XalanNode*
XercesNamedNodeMapBridge::getNamedItemNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_navigator.mapNode(m_xercesNamedNodeMap.getNamedItemNS(namespaceURI, localName));
}
XalanNode*
XercesNamedNodeMapBridge::setNamedItemNS(XalanNode* arg)
{
assert(arg != 0);
XalanNode* theXalanNode = 0;
// Find the DOM_Node that corresponds to the bridge node...
const DOM_Node theNode = m_navigator.mapNode(arg);
if (theNode.isNull() == true)
{
// Doesn't belong to this doc, so throw...
throw XercesDOMException(XercesDOMException::WRONG_DOCUMENT_ERR);
}
try
{
const DOM_Node theOldXercesNode =
m_xercesNamedNodeMap.setNamedItemNS(theNode);
if (theNode.isNull() == false)
{
// A node was replaced, so map the replacement...
theXalanNode = m_navigator.mapNode(theOldXercesNode);
assert(theXalanNode != 0);
}
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanNode;
}
XalanNode*
XercesNamedNodeMapBridge::removeNamedItemNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName)
{
XalanNode* theXalanNode = 0;
try
{
const DOM_Node theXercesNode =
m_xercesNamedNodeMap.removeNamedItemNS(namespaceURI, localName);
// A node was removed, so get it corresponding XalanNode...
theXalanNode = m_navigator.mapNode(theXercesNode);
assert(theXalanNode != 0);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
return theXalanNode;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapBridge.hpp
Index: XercesNamedNodeMapBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESNAMEDNODEMAPBRIDGE_HEADER_GUARD_1357924680)
#define XERCESNAMEDNODEMAPBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_NamedNodeMap.hpp>
#include <XalanDOM/XalanNamedNodeMap.hpp>
class XercesBridgeNavigator;
class XercesNodeBridge;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNamedNodeMapBridge : public XalanNamedNodeMap
{
public:
XercesNamedNodeMapBridge(
const DOM_NamedNodeMap& theXercesNamedNodeMap,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesNamedNodeMapBridge();
/** @name Set functions. */
//@{
/**
* Adds a node using its <code>nodeName</code> attribute.
*
* <br>As the <code>nodeName</code> attribute is used to derive the name
* which the node must be stored under, multiple nodes of certain types
* (those that have a "special" string value) cannot be stored as the names
* would clash. This is seen as preferable to allowing nodes to be aliased.
* @param arg A node to store in a named node map. The node will later be
* accessible using the value of the <code>nodeName</code> attribute of
* the node. If a node with that name is already present in the map, it
* is replaced by the new one.
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned,
* otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created the
* <code>NamedNodeMap</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
* <code>NamedNodeMap</code> is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
*/
virtual XalanNode*
setNamedItem(XalanNode* arg);
/**
* Returns the <code>index</code>th item in the map.
*
* If <code>index</code>
* is greater than or equal to the number of nodes in the map, this returns
* <code>null</code>.
* @param index Index into the map.
* @return The node at the <code>index</code>th position in the
* <code>NamedNodeMap</code>, or <code>null</code> if that is not a valid
* index.
*/
virtual XalanNode*
item(unsigned int index) const;
//@}
/** @name Get functions. */
//@{
/**
* Retrieves a node specified by name.
*
* @param name The <code>nodeName</code> of a node to retrieve.
* @return A <code>DOM_Node</code> (of any type) with the specified <code>nodeName</code>, or
* <code>null</code> if it does not identify any node in
* the map.
*/
virtual XalanNode*
getNamedItem(const XalanDOMString& name) const;
/**
* The number of nodes in the map.
*
* The range of valid child node indices is
* 0 to <code>length-1</code> inclusive.
*/
virtual unsigned int
getLength() const;
//@}
/** @name Functions to change the node collection. */
//@{
/**
* Removes a node specified by name.
*
* If the removed node is an
* <code>Attr</code> with a default value it is immediately replaced.
* @param name The <code>nodeName</code> of a node to remove.
* @return The node removed from the map or <code>null</code> if no node
* with such a name exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
* the map.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>NamedNodeMap</code>
* is readonly.
*/
virtual XalanNode*
removeNamedItem(const XalanDOMString& name);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Retrieves a node specified by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
* the node to retrieve.
* @param localName The <em>local name</em> of the node to retrieve.
* @return A <code>DOM_Node</code> (of any type) with the specified
* local name and namespace URI, or <code>null</code> if they do not
* identify any node in the map.
*/
virtual XalanNode*
getNamedItemNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const;
/**
* Adds a node using its <CODE>namespaceURI</CODE> and <CODE>localName</CODE>.
* @param arg A node to store in a named node map. The node will later be
* accessible using the value of the <CODE>namespaceURI</CODE> and
* <CODE>localName</CODE> attribute of the node. If a node with those
* namespace URI and local name is already present in the map, it is
* replaced by the new one.
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned,
* otherwise <code>null</code> is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created the
* <code>NamedNodeMap</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this
* <code>NamedNodeMap</code> is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
*/
virtual XalanNode*
setNamedItemNS(XalanNode* arg);
/**
* Removes a node specified by local name and namespace URI.
*
* @param namespaceURI The <em>namespace URI</em> of
* the node to remove.
* @param localName The <em>local name</em> of the
* node to remove. When this <code>DOM_NamedNodeMap</code> contains the
* attributes attached to an element, as returned by the attributes
* attribute of the <code>DOM_Node</code> interface, if the removed
* attribute is known to have a default value, an attribute
* immediately appears containing the default value
* as well as the corresponding namespace URI, local name, and prefix.
* @return The node removed from the map if a node with such a local name
* and namespace URI exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
* the map.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this <code>NamedNodeMap</code>
* is readonly.
*/
virtual XalanNode*
removeNamedItemNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName);
//@}
private:
// Not implemented...
XercesNamedNodeMapBridge(const XercesNamedNodeMapBridge& theSource);
XercesNamedNodeMapBridge&
operator=(const XercesNamedNodeMapBridge& theRHS);
bool
operator==(const XercesNamedNodeMapBridge& theRHS) const;
// $$$ ToDo: Eventually, this will not need to be mutable.
mutable DOM_NamedNodeMap m_xercesNamedNodeMap;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESNAMEDNODEMAPBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNodeListBridge.cpp
Index: XercesNodeListBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesNodeListBridge.hpp"
#include <cassert>
#include "XercesBridgeNavigator.hpp"
XercesNodeListBridge::XercesNodeListBridge(
const DOM_NodeList& theXercesNodeList,
const XercesBridgeNavigator& theNavigator) :
XalanNodeList(),
m_xercesNodeList(theXercesNodeList),
m_navigator(theNavigator)
{
}
XercesNodeListBridge::~XercesNodeListBridge()
{
}
XercesNodeListBridge::XercesNodeListBridge(const XercesNodeListBridge& theSource) :
XalanNodeList(theSource),
m_xercesNodeList(theSource.m_xercesNodeList),
m_navigator(theSource.m_navigator)
{
}
XalanNode*
XercesNodeListBridge::item(unsigned int index) const
{
return m_navigator.mapNode(m_xercesNodeList.item(index));
}
unsigned int
XercesNodeListBridge::getLength() const
{
return m_xercesNodeList.getLength();
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNodeListBridge.hpp
Index: XercesNodeListBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESNODELISTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESNODELISTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_NodeList.hpp>
#include <XalanDOM/XalanNodeList.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNodeListBridge : public XalanNodeList
{
public:
XercesNodeListBridge(
const DOM_NodeList& theXercesNodeList,
const XercesBridgeNavigator& theNavigator);
XercesNodeListBridge(const XercesNodeListBridge& theSource);
virtual
~XercesNodeListBridge();
bool
operator==(const XercesNodeListBridge& theRHS) const
{
return m_xercesNodeList == theRHS.m_xercesNodeList ? true : false;
}
/** @name Get functions. */
//@{
/**
* Returns the <code>index</code>th item in the collection.
*
* If <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
*
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
virtual XalanNode*
item(unsigned int index) const;
/**
* Returns the number of nodes in the list.
*
* The range of valid child node indices is 0 to <code>length-1</code> inclusive.
*/
virtual unsigned int
getLength() const;
private:
// Not implemented...
XercesNodeListBridge&
operator=(const XercesNodeListBridge& theRHS);
// Data members...
DOM_NodeList m_xercesNodeList;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESNODELISTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNotationBridge.cpp
Index: XercesNotationBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesNotationBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesNotationBridge::XercesNotationBridge(
const DOM_Notation& theXercesDOMNotation,
const XercesBridgeNavigator& theNavigator) :
XalanNotation(),
m_xercesNode(theXercesDOMNotation),
m_navigator(theNavigator)
{
}
XercesNotationBridge::~XercesNotationBridge()
{
}
XalanDOMString
XercesNotationBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesNotationBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesNotationBridge::NodeType
XercesNotationBridge::getNodeType() const
{
return NOTATION_NODE;
}
XalanNode*
XercesNotationBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesNotationBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesNotationBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesNotationBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesNotationBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesNotationBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesNotationBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesNotationBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesNotationBridge*
#endif
XercesNotationBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesNotationBridge* const theBridge =
static_cast<XercesNotationBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesNotationBridge::insertBefore(
XalanNode* newChild,
XalanNode* refChild)
{
return m_navigator.insertBefore(m_xercesNode, newChild, refChild);
}
XalanNode*
XercesNotationBridge::replaceChild(
XalanNode* newChild,
XalanNode* oldChild)
{
return m_navigator.replaceChild(m_xercesNode, newChild, oldChild);
}
XalanNode*
XercesNotationBridge::removeChild(XalanNode* oldChild)
{
return m_navigator.removeChild(m_xercesNode, oldChild);
}
XalanNode*
XercesNotationBridge::appendChild(XalanNode* newChild)
{
return m_navigator.appendChild(m_xercesNode, newChild);
}
bool
XercesNotationBridge::hasChildNodes() const
{
return false;
}
void
XercesNotationBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesNotationBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesNotationBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesNotationBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesNotationBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesNotationBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesNotationBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesNotationBridge::getPublicId() const
{
return m_xercesNode.getPublicId();
}
XalanDOMString
XercesNotationBridge::getSystemId() const
{
return m_xercesNode.getSystemId();
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesNotationBridge.hpp
Index: XercesNotationBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESNOTATIONBRIDGE_HEADER_GUARD_1357924680)
#define XERCESNOTATIONBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_Notation.hpp>
#include <XalanDOM/XalanNotation.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNotationBridge : public XalanNotation
{
public:
XercesNotationBridge(
const DOM_Notation& theXercesDOMNotation,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesNotationBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesNotationBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanNotation...
/**
* Get the public identifier of this notation.
*
* If the public identifier was not
* specified, this is <code>null</code>.
* @return Returns the public identifier of the notation
*/
virtual XalanDOMString
getPublicId() const;
/**
* Get the system identifier of this notation.
*
* If the system identifier was not
* specified, this is <code>null</code>.
* @return Returns the system identifier of the notation
*/
virtual XalanDOMString
getSystemId() const;
private:
// Not implemented...
XercesNotationBridge(const XercesNotationBridge& theSource);
XercesNotationBridge&
operator=(const XercesNotationBridge& theSource);
bool
operator==(const XercesNotationBridge& theRHS) const;
// Data members...
DOM_Notation m_xercesNode;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESNOTATIONBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesProcessingInstructionBridge.cpp
Index: XercesProcessingInstructionBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesProcessingInstructionBridge.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesProcessingInstructionBridge::XercesProcessingInstructionBridge(
const DOM_ProcessingInstruction& theXercesDOMProcessingInstruction,
const XercesBridgeNavigator& theNavigator) :
XalanProcessingInstruction(),
m_xercesNode(theXercesDOMProcessingInstruction),
m_navigator(theNavigator)
{
}
XercesProcessingInstructionBridge::~XercesProcessingInstructionBridge()
{
}
XalanDOMString
XercesProcessingInstructionBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesProcessingInstructionBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesProcessingInstructionBridge::NodeType
XercesProcessingInstructionBridge::getNodeType() const
{
return PROCESSING_INSTRUCTION_NODE;
}
XalanNode*
XercesProcessingInstructionBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesProcessingInstructionBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesProcessingInstructionBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesProcessingInstructionBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesProcessingInstructionBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesProcessingInstructionBridge*
#endif
XercesProcessingInstructionBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesProcessingInstructionBridge* const theBridge =
static_cast<XercesProcessingInstructionBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesProcessingInstructionBridge::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::removeChild(XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionBridge::appendChild(XalanNode* /* newChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesProcessingInstructionBridge::hasChildNodes() const
{
return false;
}
void
XercesProcessingInstructionBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesProcessingInstructionBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesProcessingInstructionBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesProcessingInstructionBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesProcessingInstructionBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesProcessingInstructionBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesProcessingInstructionBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesProcessingInstructionBridge::getTarget() const
{
return m_xercesNode.getTarget();
}
XalanDOMString
XercesProcessingInstructionBridge::getData() const
{
return m_xercesNode.getData();
}
void
XercesProcessingInstructionBridge::setData(const XalanDOMString& data)
{
try
{
m_xercesNode.setData(data);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesProcessingInstructionBridge.hpp
Index: XercesProcessingInstructionBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESPROCESSINGINSTRUCTIONBRIDGE_HEADER_GUARD_1357924680)
#define XERCESPROCESSINGINSTRUCTIONBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <dom/DOM_ProcessingInstruction.hpp>
#include <XalanDOM/XalanProcessingInstruction.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesProcessingInstructionBridge : public XalanProcessingInstruction
{
public:
XercesProcessingInstructionBridge(
const DOM_ProcessingInstruction& theXercesDOMProcessingInstruction,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesProcessingInstructionBridge();
// These interfaces are inherited from XalanNode...
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesProcessingInstructionBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanProcessingInstruction...
//@}
/** @name Get functions. */
//@{
/**
* The target of this processing instruction.
*
* XML defines this as being the
* first token following the markup that begins the processing instruction.
*/
virtual XalanDOMString
getTarget() const;
/**
* The content of this processing instruction.
*
* This is from the first non
* white space character after the target to the character immediately
* preceding the <code>?></code>.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
*/
virtual XalanDOMString
getData() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the content of this processing instruction.
*
* This is from the first non
* white space character after the target to the character immediately
* preceding the <code>?></code>.
* @param data The string containing the processing instruction
*/
virtual void
setData(const XalanDOMString& data);
//@}
private:
// Not implemented...
XercesProcessingInstructionBridge(const XercesProcessingInstructionBridge& theSource);
XercesProcessingInstructionBridge&
operator=(const XercesProcessingInstructionBridge& theSource);
bool
operator==(const XercesProcessingInstructionBridge& theRHS) const;
// Data members...
DOM_ProcessingInstruction m_xercesNode;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESPROCESSINGINSTRUCTIONBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesTextBridge.cpp
Index: XercesTextBridge.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesTextBridge.hpp"
#include <cassert>
#include "XercesBridgeNavigator.hpp"
#include "XercesDOMException.hpp"
#include "XercesDocumentBridge.hpp"
XercesTextBridge::XercesTextBridge(
const DOM_Text& theXercesText,
const XercesBridgeNavigator& theNavigator) :
XalanText(),
m_xercesNode(theXercesText),
m_navigator(theNavigator)
{
assert(m_xercesNode.isNull() == false);
}
XercesTextBridge::~XercesTextBridge()
{
}
XalanDOMString
XercesTextBridge::getNodeName() const
{
return m_xercesNode.getNodeName();
}
XalanDOMString
XercesTextBridge::getNodeValue() const
{
return m_xercesNode.getNodeValue();
}
XercesTextBridge::NodeType
XercesTextBridge::getNodeType() const
{
return TEXT_NODE;
}
XalanNode*
XercesTextBridge::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesTextBridge::getChildNodes() const
{
return 0;
}
XalanNode*
XercesTextBridge::getFirstChild() const
{
return 0;
}
XalanNode*
XercesTextBridge::getLastChild() const
{
return 0;
}
XalanNode*
XercesTextBridge::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesTextBridge::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesTextBridge::getAttributes() const
{
return 0;
}
XalanDocument*
XercesTextBridge::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesTextBridge*
#endif
XercesTextBridge::cloneNode(bool deep) const
{
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
return m_navigator.cloneNode(this, m_xercesNode, deep);
#else
XercesTextBridge* const theBridge =
static_cast<XercesTextBridge*>(m_navigator.cloneNode(this, m_xercesNode, deep));
return theBridge;
#endif
}
XalanNode*
XercesTextBridge::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextBridge::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextBridge::removeChild(XalanNode* /* oldChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextBridge::appendChild(XalanNode* /* newChild */)
{
throw XercesDOMException(XercesDOMException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesTextBridge::hasChildNodes() const
{
return false;
}
void
XercesTextBridge::setNodeValue(const XalanDOMString& nodeValue)
{
try
{
m_xercesNode.setNodeValue(nodeValue);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesTextBridge::normalize()
{
try
{
m_xercesNode.normalize();
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
bool
XercesTextBridge::supports(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return m_xercesNode.supports(feature, version);
}
XalanDOMString
XercesTextBridge::getNamespaceURI() const
{
return m_xercesNode.getNamespaceURI();
}
XalanDOMString
XercesTextBridge::getPrefix() const
{
return m_xercesNode.getPrefix();
}
XalanDOMString
XercesTextBridge::getLocalName() const
{
return m_xercesNode.getLocalName();
}
void
XercesTextBridge::setPrefix(const XalanDOMString& prefix)
{
try
{
m_xercesNode.setPrefix(prefix);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanDOMString
XercesTextBridge::getData() const
{
return m_xercesNode.getData();
}
unsigned int
XercesTextBridge::getLength() const
{
return m_xercesNode.getLength();
}
XalanDOMString
XercesTextBridge::substringData(
unsigned int offset,
unsigned int count) const
{
try
{
return m_xercesNode.substringData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesTextBridge::appendData(const XalanDOMString& arg)
{
try
{
m_xercesNode.appendData(arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesTextBridge::insertData(
unsigned int offset,
const XalanDOMString& arg)
{
try
{
m_xercesNode.insertData(offset, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesTextBridge::deleteData(
unsigned int offset,
unsigned int count)
{
try
{
m_xercesNode.deleteData(offset, count);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
void
XercesTextBridge::replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg)
{
try
{
m_xercesNode.replaceData(offset, count, arg);
}
catch(const DOM_DOMException& theException)
{
throw XercesDOMException(theException);
}
}
XalanText*
XercesTextBridge::splitText(unsigned int offset)
{
return m_navigator.splitText(m_xercesNode, offset);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesTextBridge.hpp
Index: XercesTextBridge.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESTEXTBRIDGE_HEADER_GUARD_1357924680)
#define XERCESTEXTBRIDGE_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <dom/DOM_Text.hpp>
#include <XalanDOM/XalanText.hpp>
class XercesBridgeNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesTextBridge : public XalanText
{
public:
XercesTextBridge(
const DOM_Text& theXercesText,
const XercesBridgeNavigator& theNavigator);
virtual
~XercesTextBridge();
/**
* Gets the name of this node.
*/
virtual XalanDOMString
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual XalanDOMString
getNodeValue() const;
/**
* An enum value representing the type of the underlying object.
*/
virtual NodeType
getNodeType() const;
/**
* Gets the parent of this node.
*
* All nodes, except <code>Document</code>,
* <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
* However, if a node has just been created and not yet added to the tree,
* or if it has been removed from the tree, a <code>null</code> DOM_Node
* is returned.
*/
virtual XalanNode*
getParentNode() const;
/**
* Gets a <code>NodeList</code> that contains all children of this node.
*
* If there
* are no children, this is a <code>NodeList</code> containing no nodes.
* The content of the returned <code>NodeList</code> is "live" in the sense
* that, for instance, changes to the children of the node object that
* it was created from are immediately reflected in the nodes returned by
* the <code>NodeList</code> accessors; it is not a static snapshot of the
* content of the node. This is true for every <code>NodeList</code>,
* including the ones returned by the <code>getElementsByTagName</code>
* method.
*/
virtual const XalanNodeList*
getChildNodes() const;
/**
* Gets the first child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getFirstChild() const;
/**
* Gets the last child of this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getLastChild() const;
/**
* Gets the node immediately preceding this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getPreviousSibling() const;
/**
* Gets the node immediately following this node.
*
* If there is no such node, this returns <code>null</code>.
*/
virtual XalanNode*
getNextSibling() const;
/**
* Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
* is an <code>Element</code>) or <code>null</code> otherwise.
*/
virtual const XalanNamedNodeMap*
getAttributes() const;
/**
* Gets the <code>DOM_Document</code> object associated with this node.
*
* This is also
* the <code>DOM_Document</code> object used to create new nodes. When this
* node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
* which is not used with any <code>DOM_Document</code> yet, this is
* <code>null</code>.
*/
virtual XalanDocument*
getOwnerDocument() const;
//@}
/** @name Cloning function. */
//@{
/**
* Returns a duplicate of this node.
*
* This function serves as a generic copy constructor for nodes.
*
* The duplicate node has no parent (
* <code>parentNode</code> returns <code>null</code>.).
* <br>Cloning an <code>Element</code> copies all attributes and their
* values, including those generated by the XML processor to represent
* defaulted attributes, but this method does not copy any text it contains
* unless it is a deep clone, since the text is contained in a child
* <code>Text</code> node. Cloning any other type of node simply returns a
* copy of this node.
* @param deep If <code>true</code>, recursively clone the subtree under the
* specified node; if <code>false</code>, clone only the node itself (and
* its attributes, if it is an <code>Element</code>).
* @return The duplicate node.
*/
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XalanNode*
#else
virtual XercesTextBridge*
#endif
cloneNode(bool deep) const;
//@}
/** @name Functions to modify the DOM Node. */
//@{
/**
* Inserts the node <code>newChild</code> before the existing child node
* <code>refChild</code>.
*
* If <code>refChild</code> is <code>null</code>,
* insert <code>newChild</code> at the end of the list of children.
* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
* all of its children are inserted, in the same order, before
* <code>refChild</code>. If the <code>newChild</code> is already in the
* tree, it is first removed. Note that a <code>DOM_Node</code> that
* has never been assigned to refer to an actual node is == null.
* @param newChild The node to insert.
* @param refChild The reference node, i.e., the node before which the new
* node must be inserted.
* @return The node being inserted.
*/
virtual XalanNode*
insertBefore(
XalanNode* newChild,
XalanNode* refChild);
/**
* Replaces the child node <code>oldChild</code> with <code>newChild</code>
* in the list of children, and returns the <code>oldChild</code> node.
*
* If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
* <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
* children, which are inserted in the same order.
*
* If the <code>newChild</code> is already in the tree, it is first removed.
* @param newChild The new node to put in the child list.
* @param oldChild The node being replaced in the list.
* @return The node replaced.
*/
virtual XalanNode*
replaceChild(
XalanNode* newChild,
XalanNode* oldChild);
/**
* Removes the child node indicated by <code>oldChild</code> from the list
* of children, and returns it.
*
* @param oldChild The node being removed.
* @return The node removed.
*/
virtual XalanNode*
removeChild(XalanNode* oldChild);
/**
* Adds the node <code>newChild</code> to the end of the list of children of
* this node.
*
* If the <code>newChild</code> is already in the tree, it is
* first removed.
* @param newChild The node to add.If it is a <code>DocumentFragment</code>
* object, the entire contents of the document fragment are moved into
* the child list of this node
* @return The node added.
*/
virtual XalanNode*
appendChild(XalanNode* newChild);
//@}
/** @name Query functions. */
//@{
/**
* This is a convenience method to allow easy determination of whether a
* node has any children.
*
* @return <code>true</code> if the node has any children,
* <code>false</code> if the node has no children.
*/
virtual bool
hasChildNodes() const;
//@}
/** @name Set functions. */
//@{
/**
* Sets the value of the node.
*
* Any node which can have a nodeValue (@see getNodeValue) will
* also accept requests to set it to a string. The exact response to
* this varies from node to node -- Attribute, for example, stores
* its values in its children and has to replace them with a new Text
* holding the replacement value.
*
* For most types of Node, value is null and attempting to set it
* will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
* also be thrown if the node is read-only.
*/
virtual void
setNodeValue(const XalanDOMString& nodeValue);
//@}
/** @name Functions introduced in DOM Level 2. */
//@{
/**
* Puts all <CODE>DOM_Text</CODE>
* nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
* including attribute nodes, into a "normal" form where only markup (e.g.,
* tags, comments, processing instructions, CDATA sections, and entity
* references) separates <CODE>DOM_Text</CODE>
* nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
* nodes. This can be used to ensure that the DOM view of a document is the
* same as if it were saved and re-loaded, and is useful when operations
* (such as XPointer lookups) that depend on a particular document tree
* structure are to be used.
* <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
* the normalize operation alone may not be sufficient, since XPointers do
* not differentiate between <CODE>DOM_Text</CODE>
* nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
*/
virtual void
normalize();
/**
* Tests whether the DOM implementation implements a specific
* feature and that feature is supported by this node.
* @param feature The string of the feature to test. This is the same
* name as what can be passed to the method <code>hasFeature</code> on
* <code>DOMImplementation</code>.
* @param version This is the version number of the feature to test. In
* Level 2, version 1, this is the string "2.0". If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is supported
* on this node, <code>false</code> otherwise.
*/
virtual bool
supports(
const XalanDOMString& feature,
const XalanDOMString& version) const;
/**
* Get the <em>namespace URI</em> of
* this node, or <code>null</code> 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 of any type other than <CODE>ELEMENT_NODE</CODE> and
* <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
* such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
* interface, this is always <CODE>null</CODE>.
*/
virtual XalanDOMString
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual XalanDOMString
getPrefix() const;
/**
* Returns the local part of the <em>qualified name</em> of this node.
* <p>
* For nodes created with a DOM Level 1 method, such as
* <code>createElement</code> from the <code>DOM_Document</code> interface,
* it is null.
*/
virtual XalanDOMString
getLocalName() const;
/**
* Set the <em>namespace prefix</em> of this node.
* <p>
* Note that setting this attribute, when permitted, changes
* the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
* name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
* attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
* interfaces, when applicable.
* <p>
* Note also that changing the prefix of an
* attribute, that is known to have a default value, does not make a new
* attribute with the default value and the original prefix appear, since the
* <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
*
* @param prefix The prefix of this node.
* @exception DOMException
* INVALID_CHARACTER_ERR: Raised if the specified prefix contains
* an illegal character.
* <br>
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
* <br>
* NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
* malformed, if the specified prefix is "xml" and the
* <CODE>namespaceURI</CODE> of this node is different from
* "http://www.w3.org/XML/1998/namespace", if specified prefix is
* "xmlns" and the <CODE>namespaceURI</CODE> is neither
* <CODE>null</CODE> nor an empty string, or if the
* <CODE>localName</CODE> is <CODE>null</CODE>.
*/
virtual void
setPrefix(const XalanDOMString& prefix);
//@}
// These interfaces are inherited from XalanCDATASection...
/** @name Getter functions. */
//@{
/**
* Returns the character data of the node that implements this interface.
*
* The DOM implementation may not put arbitrary limits on the amount of data that
* may be stored in a <code>CharacterData</code> node. However,
* implementation limits may mean that the entirety of a node's data may
* not fit into a single <code>DOMString</code>. In such cases, the user
* may call <code>substringData</code> to retrieve the data in
* appropriately sized pieces.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
*/
virtual XalanDOMString
getData() const;
/**
* Returns the number of characters that are available through <code>data</code> and
* the <code>substringData</code> method below.
*
* This may have the value
* zero, i.e., <code>CharacterData</code> nodes may be empty.
*/
virtual unsigned int
getLength() const;
/**
* Extracts a range of data from the node.
*
* @param offset Start offset of substring to extract.
* @param count The number of characters to extract.
* @return The specified substring. If the sum of <code>offset</code> and
* <code>count</code> exceeds the <code>length</code>, then all
* characters to the end of the data are returned.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not
* fit into a <code>DOMString</code>.
*/
virtual XalanDOMString
substringData(
unsigned int offset,
unsigned int count) const;
//@}
/** @name Functions that set or change data. */
//@{
/**
* Append the string to the end of the character data of the node.
*
* Upon success, <code>data</code> provides access to the concatenation of
* <code>data</code> and the <code>DOMString</code> specified.
* @param arg The <code>DOMString</code> to append.
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
appendData(const XalanDOMString& arg);
/**
* Insert a string at the specified character offset.
*
* @param offset The character offset at which to insert.
* @param arg The <code>DOMString</code> to insert.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
insertData(
unsigned int offset,
const XalanDOMString& arg);
/**
* Remove a range of characters from the node.
*
* Upon success,
* <code>data</code> and <code>length</code> reflect the change.
* @param offset The offset from which to remove characters.
* @param count The number of characters to delete. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* then all characters from <code>offset</code> to the end of the data
* are deleted.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
deleteData(
unsigned int offset,
unsigned int count);
/**
* Replace the characters starting at the specified character offset with
* the specified string.
*
* @param offset The offset from which to start replacing.
* @param count The number of characters to replace. If the sum of
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
* , then all characters to the end of the data are replaced (i.e., the
* effect is the same as a <code>remove</code> method call with the same
* range, followed by an <code>append</code> method invocation).
* @param arg The <code>DOMString</code> with which the range must be
* replaced.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>, or if the
* specified <code>count</code> is negative.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual void
replaceData(
unsigned int offset,
unsigned int count,
const XalanDOMString& arg);
//@}
//@}
/** @name Functions to modify the Text node. */
//@{
/**
* Breaks this node into two nodes at the specified
* offset, keeping both in the tree as siblings.
*
* This node then only
* contains all the content up to the <code>offset</code> point. And a new
* node of the same nodeType, which is inserted as the next sibling of this
* node, contains all the content at and after the <code>offset</code>
* point. When the <code>offset</code> is equal to the lenght of this node,
* the new node has no data.
* @param offset The offset at which to split, starting from 0.
* @return The new <code>Text</code> node.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
* than the number of characters in <code>data</code>.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
*/
virtual XalanText*
splitText(unsigned int offset);
//@}
private:
// Not implemented...
XercesTextBridge(const XercesTextBridge& theSource);
XercesTextBridge&
operator=(const XercesTextBridge& theSource);
bool
operator==(const XercesTextBridge& theRHS) const;
// Data members...
DOM_Text m_xercesNode;
const XercesBridgeNavigator& m_navigator;
};
#endif // !defined(XERCESTEXTBRIDGE_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesToXalanNodeMap.cpp
Index: XercesToXalanNodeMap.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "XercesToXalanNodeMap.hpp"
#include <algorithm>
#include <cassert>
#include <dom/DOM_Document.hpp>
#include <XalanDOM/XalanDOMException.hpp>
#include <XalanDOM/XalanNode.hpp>
XercesToXalanNodeMap::XercesToXalanNodeMap() :
m_xalanMap(),
m_xercesMap(),
m_counter(0)
{
}
XercesToXalanNodeMap::~XercesToXalanNodeMap()
{
}
XercesToXalanNodeMap::addAssociation(
const DOM_Node& theXercesNode,
XalanNode* theXalanNode,
bool fAssignIndex)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
#endif
// Space the indices, just in case nodes are
// added. With any luck, we may not need to
// reindex the nodes.
const unsigned long theIncrement = 5;
NodeImpl* const theImpl = XercesDOM_NodeHack::getImpl(theXercesNode);
m_xercesMap.insert(make_pair(theImpl, theXalanNode));
try
{
// Unindexed nodes are assigned an index of 0.
unsigned long theIndex = 0;
// Have we been told to assign an index?
if (fAssignIndex == true)
{
// Never index attribute nodes or their childern...
if (theXalanNode->getNodeType() != XalanNode::ATTRIBUTE_NODE)
{
const XalanNode* const theParent =
theXalanNode->getParentNode();
if (theParent == 0 || theParent->getNodeType() != XalanNode::ATTRIBUTE_NODE)
{
theIndex = m_counter += theIncrement;
}
}
}
m_xalanMap.insert(make_pair(theXalanNode, XalanNodeMapEntryType(theImpl, theIndex)));
}
catch(...)
{
m_xercesMap.erase(m_xercesMap.find(theImpl));
throw;
}
}
XercesToXalanNodeMap::clear()
{
m_xalanMap.clear();
m_xercesMap.clear();
}
bool
XercesToXalanNodeMap::isNodeAfter(
const XalanNode* theFirstXalanNode,
const XalanNode* theSecondXalanNode) const
{
assert(theFirstXalanNode != 0);
assert(theSecondXalanNode != 0);
assert(theFirstXalanNode->getOwnerDocument() == theSecondXalanNode->getOwnerDocument());
bool fResult = false;
const XalanNodeMapType::const_iterator i =
m_xalanMap.find(theFirstXalanNode);
if (i == m_xalanMap.end())
{
throw XalanDOMException(XalanDOMException::HIERARCHY_REQUEST_ERR);
}
else
{
const XalanNodeMapType::const_iterator j =
m_xalanMap.find(theSecondXalanNode);
if (i == m_xalanMap.end())
{
throw XalanDOMException(XalanDOMException::HIERARCHY_REQUEST_ERR);
}
else
{
if (i->second.m_index > j->second.m_index)
{
fResult = true;
}
}
}
return fResult;
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesToXalanNodeMap.hpp
Index: XercesToXalanNodeMap.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 "Xalan" 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.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XERCESTOXALANNODEMAP_HEADER_GUARD_1357924680)
#define XERCESTOXALANNODEMAP_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <map>
#include <dom/DOM_Node.hpp>
#include <XercesParserLiaison/XercesDOM_NodeHack.hpp>
class NodeImpl;
class XalanNode;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesToXalanNodeMap
{
public:
XercesToXalanNodeMap();
~XercesToXalanNodeMap();
addAssociation(
const DOM_Node& theXercesNode,
XalanNode* theXalanNode,
bool fAssignIndex);
clear();
XalanNode*
getNode(const DOM_Node& theXercesNode) const
{
return getNode(XercesDOM_NodeHack::getImpl(theXercesNode));
}
XalanNode*
getNode(const NodeImpl* theXercesNodeImpl) const
{
const XercesNodeMapType::const_iterator i =
m_xercesMap.find(theXercesNodeImpl);
if (i == m_xercesMap.end())
{
return 0;
}
else
{
return i->second;
}
}
DOM_Node
getNode(const XalanNode* theXalanNode) const
{
return XercesDOM_NodeHack(getNodeImpl(theXalanNode));
}
NodeImpl*
getNodeImpl(const XalanNode* theXalanNode) const
{
const XalanNodeMapType::const_iterator i =
m_xalanMap.find(theXalanNode);
if (i == m_xalanMap.end())
{
return 0;
}
else
{
return i->second.m_xercesNode;
}
}
NodeImpl*
getNodeImpl(const DOM_Node& theXercesNode) const
{
return XercesDOM_NodeHack::getImpl(theXercesNode);
}
bool
isNodeAfter(
const XalanNode* theFirstXercesNode,
const XalanNode* theSecondXercesNode) const;
private:
struct XalanNodeMapEntryType
{
XalanNodeMapEntryType(
NodeImpl* theXercesNode = 0,
unsigned long theIndex = 0) :
m_xercesNode(theXercesNode),
m_index(theIndex)
{
}
NodeImpl* m_xercesNode;
unsigned long m_index;
};
typedef std::map<const XalanNode*, XalanNodeMapEntryType> XalanNodeMapType;
typedef std::map<const NodeImpl*, XalanNode*> XercesNodeMapType;
XalanNodeMapType m_xalanMap;
XercesNodeMapType m_xercesMap;
unsigned long m_counter;
};
#endif // !defined(XERCESTOXALANNODEMAP_HEADER_GUARD_1357924680)