dbertoni 2002/10/02 18:32:44
Added: c/src/XercesParserLiaison XercesAttrWrapper.cpp
XercesAttrWrapper.hpp
XercesAttrWrapperAllocator.cpp
XercesAttrWrapperAllocator.hpp
XercesCDATASectionWrapper.cpp
XercesCDATASectionWrapper.hpp
XercesCommentWrapper.cpp XercesCommentWrapper.hpp
XercesDocumentTypeWrapper.cpp
XercesDocumentTypeWrapper.hpp
XercesDocumentWrapper.cpp XercesDocumentWrapper.hpp
XercesDOMImplementationWrapper.cpp
XercesDOMImplementationWrapper.hpp
XercesDOMWalker.cpp XercesDOMWalker.hpp
XercesDOMWrapperException.cpp
XercesDOMWrapperException.hpp
XercesElementWrapper.cpp XercesElementWrapper.hpp
XercesElementWrapperAllocator.cpp
XercesElementWrapperAllocator.hpp
XercesEntityReferenceWrapper.cpp
XercesEntityReferenceWrapper.hpp
XercesEntityWrapper.cpp XercesEntityWrapper.hpp
XercesNamedNodeMapWrapper.cpp
XercesNamedNodeMapWrapper.hpp
XercesNodeListWrapper.cpp XercesNodeListWrapper.hpp
XercesNotationWrapper.cpp XercesNotationWrapper.hpp
XercesProcessingInstructionWrapper.cpp
XercesProcessingInstructionWrapper.hpp
XercesTextWrapper.cpp XercesTextWrapper.hpp
XercesTextWrapperAllocator.cpp
XercesTextWrapperAllocator.hpp
XercesWrapperHelper.cpp XercesWrapperHelper.hpp
XercesWrapperNavigator.cpp
XercesWrapperNavigator.hpp
XercesWrapperToXalanNodeMap.cpp
XercesWrapperToXalanNodeMap.hpp
Log:
Initial revision of new Xerces DOM wrapper.
Revision Changes Path
1.1 xml-xalan/c/src/XercesParserLiaison/XercesAttrWrapper.cpp
Index: XercesAttrWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesAttrWrapper.hpp"
#include <cassert>
#include <xercesc/dom/DOMAttr.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesAttrWrapper::XercesAttrWrapper(
const DOMAttr*
theXercesAttr,
const XercesWrapperNavigator& theNavigator) :
XalanAttr(),
m_xercesNode(theXercesAttr),
m_children(theXercesAttr->getChildNodes(),
theNavigator),
m_navigator(theNavigator)
{
assert(theXercesAttr != 0);
}
XercesAttrWrapper::~XercesAttrWrapper()
{
}
const XalanDOMString&
XercesAttrWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesAttrWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesAttrWrapper::NodeType
XercesAttrWrapper::getNodeType() const
{
return ATTRIBUTE_NODE;
}
XalanNode*
XercesAttrWrapper::getParentNode() const
{
return 0;
}
const XalanNodeList*
XercesAttrWrapper::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesAttrWrapper::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesAttrWrapper::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesAttrWrapper::getPreviousSibling() const
{
return 0;
}
XalanNode*
XercesAttrWrapper::getNextSibling() const
{
return 0;
}
const XalanNamedNodeMap*
XercesAttrWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesAttrWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesAttrWrapper*
#endif
XercesAttrWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesAttrWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
// Dummy return value...
return 0;
}
XalanNode*
XercesAttrWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
// Dummy return value...
return 0;
}
XalanNode*
XercesAttrWrapper::removeChild(XalanNode* /* oldChild */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
// Dummy return value...
return 0;
}
XalanNode*
XercesAttrWrapper::appendChild(XalanNode* /* newChild */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
// Dummy return value...
return 0;
}
bool
XercesAttrWrapper::hasChildNodes() const
{
return m_xercesNode->hasChildNodes();
}
void
XercesAttrWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesAttrWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesAttrWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesAttrWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesAttrWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesAttrWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesAttrWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesAttrWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesAttrWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesAttrWrapper::getName() const
{
return m_navigator.getPooledString(m_xercesNode->getName());
}
bool
XercesAttrWrapper::getSpecified() const
{
return m_xercesNode->getSpecified();
}
const XalanDOMString&
XercesAttrWrapper::getValue() const
{
return m_navigator.getPooledString(m_xercesNode->getValue());
}
void
XercesAttrWrapper::setValue(const XalanDOMString& /* value */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanElement*
XercesAttrWrapper::getOwnerElement() const
{
return m_navigator.getOwnerElement(m_xercesNode);
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesAttrWrapper.hpp
Index: XercesAttrWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESATTRWRAPPER_HEADER_GUARD_1357924680)
#define XERCESATTRWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <xercesc/dom/DOMAttr.hpp>
#include <XalanDOM/XalanAttr.hpp>
#include <XercesParserLiaison/XercesNodeListWrapper.hpp>
class XercesWrapperNavigator;
class XalanElement;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesAttrWrapper : public XalanAttr
{
public:
XercesAttrWrapper(
const DOMAttr*
theXercesAttr,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesAttrWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesAttrWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// These interfaces are inherited from XalanAttr...
/** @name Getter functions */
//@{
/**
* Returns the name of this attribute.
*/
virtual const 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 const 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;
//@}
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMAttr*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesAttrWrapper(const XercesAttrWrapper& theSource);
XercesAttrWrapper&
operator=(const XercesAttrWrapper& theSource);
bool
operator==(const XercesAttrWrapper& theRHS) const;
// Data members...
const DOMAttr* const m_xercesNode;
XercesNodeListWrapper m_children;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESATTRBRIDGE_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesAttrWrapperAllocator.cpp
Index: XercesAttrWrapperAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Class header file.
#include "XercesAttrWrapperAllocator.hpp"
XercesAttrWrapperAllocator::XercesAttrWrapperAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XercesAttrWrapperAllocator::~XercesAttrWrapperAllocator()
{
}
XercesAttrWrapperAllocator::ObjectType*
XercesAttrWrapperAllocator::create(
const DOMAttr*
theXercesAttr,
const XercesWrapperNavigator& theNavigator)
{
ObjectType* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
new(theBlock) ObjectType(theXercesAttr, theNavigator);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
void
XercesAttrWrapperAllocator::reset()
{
m_allocator.reset();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesAttrWrapperAllocator.hpp
Index: XercesAttrWrapperAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESATTRWRAPPERALLOCATOR_INCLUDE_GUARD_12455133)
#define XERCESATTRWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
#include <XercesParserLiaison/XercesAttrWrapper.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesAttrWrapperAllocator
{
public:
typedef XercesAttrWrapper
ObjectType;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<ObjectType>
ArenaBlockType;
typedef ArenaAllocator<ObjectType,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<ObjectType>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XercesAttrWrapperAllocator(size_type theBlockCount);
~XercesAttrWrapperAllocator();
/**
* Create a XercesAttrWrapper instance.
*
* @param theXercesAttr The Xerces attribute node
* @param theNavigator The navigator for this instance.
*
* @return pointer to the instance
*/
ObjectType*
create(
const DOMAttr*
theXercesAttr,
const XercesWrapperNavigator& theNavigator);
/**
* Delete all objects from allocator.
*/
void
reset();
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XercesAttrWrapperAllocator(const XercesAttrWrapperAllocator&);
XercesAttrWrapperAllocator&
operator=(const XercesAttrWrapperAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XERCESATTRWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
1.1
xml-xalan/c/src/XercesParserLiaison/XercesCDATASectionWrapper.cpp
Index: XercesCDATASectionWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesCDATASectionWrapper.hpp"
#include <cassert>
#include <xercesc/dom/DOMCDATASection.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesCDATASectionWrapper::XercesCDATASectionWrapper(
const DOMCDATASection*
theXercesCDATASection,
const XercesWrapperNavigator& theNavigator) :
XalanCDATASection(),
m_xercesNode(theXercesCDATASection),
m_navigator(theNavigator)
{
assert(theXercesCDATASection != 0);
}
XercesCDATASectionWrapper::~XercesCDATASectionWrapper()
{
}
const XalanDOMString&
XercesCDATASectionWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesCDATASectionWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesCDATASectionWrapper::NodeType
XercesCDATASectionWrapper::getNodeType() const
{
return CDATA_SECTION_NODE;
}
XalanNode*
XercesCDATASectionWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesCDATASectionWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesCDATASectionWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesCDATASectionWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesCDATASectionWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesCDATASectionWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesCDATASectionWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesCDATASectionWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesCDATASectionWrapper*
#endif
XercesCDATASectionWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesCDATASectionWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCDATASectionWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesCDATASectionWrapper::hasChildNodes() const
{
return false;
}
void
XercesCDATASectionWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCDATASectionWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesCDATASectionWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesCDATASectionWrapper::getNamespaceURI() const
{
const DOMString theString();
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesCDATASectionWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesCDATASectionWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesCDATASectionWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesCDATASectionWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesCDATASectionWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesCDATASectionWrapper::getData() const
{
return m_navigator.getPooledString(m_xercesNode->getData());
}
unsigned int
XercesCDATASectionWrapper::getLength() const
{
return m_xercesNode->getLength();
}
XalanDOMString
XercesCDATASectionWrapper::substringData(
unsigned int offset,
unsigned int count) const
{
return XercesWrapperHelper::substringData(m_xercesNode, offset, count);
}
void
XercesCDATASectionWrapper::appendData(const XalanDOMString& /* arg
*/)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCDATASectionWrapper::insertData(
unsigned int /* offset */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCDATASectionWrapper::deleteData(
unsigned int /* offset */,
unsigned int /* count */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCDATASectionWrapper::replaceData(
unsigned int /* offset */,
unsigned int /* count */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanText*
XercesCDATASectionWrapper::splitText(unsigned int /* offset */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
bool
XercesCDATASectionWrapper::isIgnorableWhitespace() const
{
return isXMLWhitespace(getData());
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesCDATASectionWrapper.hpp
Index: XercesCDATASectionWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESCDATASECTIONWRAPPER_HEADER_GUARD_1357924680)
#define XERCESCDATASECTIONWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanCDATASection.hpp>
class DOMCDATASection;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesCDATASectionWrapper : public
XalanCDATASection
{
public:
XercesCDATASectionWrapper(
const DOMCDATASection*
theXercesCDATASection,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesCDATASectionWrapper();
/**
* Gets the name of this node.
*/
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesCDATASectionWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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);
//@}
virtual bool
isIgnorableWhitespace() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMCDATASection*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesCDATASectionWrapper(const XercesCDATASectionWrapper&
theSource);
XercesCDATASectionWrapper&
operator=(const XercesCDATASectionWrapper& theSource);
bool
operator==(const XercesCDATASectionWrapper& theRHS) const;
// Data members...
const DOMCDATASection* m_xercesNode;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESCDATASECTIONWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesCommentWrapper.cpp
Index: XercesCommentWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesCommentWrapper.hpp"
#include <xercesc/dom/DOMComment.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesCommentWrapper::XercesCommentWrapper(
const DOMComment*
theXercesComment,
const XercesWrapperNavigator& theNavigator) :
XalanComment(),
m_xercesNode(theXercesComment),
m_navigator(theNavigator)
{
assert(theXercesComment != 0);
}
XercesCommentWrapper::~XercesCommentWrapper()
{
}
const XalanDOMString&
XercesCommentWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesCommentWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesCommentWrapper::NodeType
XercesCommentWrapper::getNodeType() const
{
return COMMENT_NODE;
}
XalanNode*
XercesCommentWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesCommentWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesCommentWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesCommentWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesCommentWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesCommentWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesCommentWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesCommentWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesCommentWrapper*
#endif
XercesCommentWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesCommentWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesCommentWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesCommentWrapper::hasChildNodes() const
{
return false;
}
void
XercesCommentWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCommentWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesCommentWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesCommentWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesCommentWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesCommentWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesCommentWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesCommentWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesCommentWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesCommentWrapper::getData() const
{
return m_navigator.getPooledString(m_xercesNode->getData());
}
unsigned int
XercesCommentWrapper::getLength() const
{
return m_xercesNode->getLength();
}
XalanDOMString
XercesCommentWrapper::substringData(
unsigned int offset,
unsigned int count) const
{
return XercesWrapperHelper::substringData(m_xercesNode, offset, count);
}
void
XercesCommentWrapper::appendData(const XalanDOMString& /* arg
*/)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCommentWrapper::insertData(
unsigned int /* offset */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCommentWrapper::deleteData(
unsigned int /* offset */,
unsigned int /* count */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesCommentWrapper::replaceData(
unsigned int /* offset */,
unsigned int /* count */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesCommentWrapper.hpp
Index: XercesCommentWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESCOMMENTWRAPPER_HEADER_GUARD_1357924680)
#define XERCESCOMMENTWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanComment.hpp>
class DOMComment;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesCommentWrapper : public
XalanComment
{
public:
XercesCommentWrapper(
const DOMComment*
theXercesComment,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesCommentWrapper();
/**
* Gets the name of this node.
*/
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesCommentWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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);
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMComment*
getXercesNode() const
{
return m_xercesNode;
}
//@}
private:
// Not implemented...
XercesCommentWrapper(const XercesCommentWrapper& theSource);
XercesCommentWrapper&
operator=(const XercesCommentWrapper& theSource);
bool
operator==(const XercesCommentWrapper& theRHS) const;
// Data members...
const DOMComment* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESCOMMENTWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDocumentTypeWrapper.cpp
Index: XercesDocumentTypeWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesDocumentTypeWrapper.hpp"
#include <xercesc/dom/DOMDocumentType.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesDocumentTypeWrapper::XercesDocumentTypeWrapper(
const DOMDocumentType*
theXercesDOMDocumentType,
const XercesWrapperNavigator& theNavigator) :
XalanDocumentType(),
m_xercesNode(theXercesDOMDocumentType),
m_entities(m_xercesNode->getEntities(),
theNavigator),
m_notations(m_xercesNode->getNotations(),
theNavigator),
m_navigator(theNavigator)
{
assert(theXercesDOMDocumentType != 0);
}
XercesDocumentTypeWrapper::~XercesDocumentTypeWrapper()
{
}
const XalanDOMString&
XercesDocumentTypeWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesDocumentTypeWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesDocumentTypeWrapper::NodeType
XercesDocumentTypeWrapper::getNodeType() const
{
return DOCUMENT_TYPE_NODE;
}
XalanNode*
XercesDocumentTypeWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesDocumentTypeWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesDocumentTypeWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesDocumentTypeWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesDocumentTypeWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesDocumentTypeWrapper*
#endif
XercesDocumentTypeWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesDocumentTypeWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesDocumentTypeWrapper::hasChildNodes() const
{
return false;
}
void
XercesDocumentTypeWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesDocumentTypeWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesDocumentTypeWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesDocumentTypeWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesDocumentTypeWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesDocumentTypeWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesDocumentTypeWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesDocumentTypeWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesDocumentTypeWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesDocumentTypeWrapper::getName() const
{
return m_navigator.getPooledString(m_xercesNode->getName());
}
const XalanNamedNodeMap*
XercesDocumentTypeWrapper::getEntities() const
{
return &m_entities;
}
const XalanNamedNodeMap*
XercesDocumentTypeWrapper::getNotations() const
{
return &m_notations;
}
const XalanDOMString&
XercesDocumentTypeWrapper::getPublicId() const
{
return m_navigator.getPooledString(m_xercesNode->getPublicId());
}
const XalanDOMString&
XercesDocumentTypeWrapper::getSystemId() const
{
return m_navigator.getPooledString(m_xercesNode->getSystemId());
}
const XalanDOMString&
XercesDocumentTypeWrapper::getInternalSubset() const
{
return m_navigator.getPooledString(m_xercesNode->getInternalSubset());
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDocumentTypeWrapper.hpp
Index: XercesDocumentTypeWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESDOCUMENTTYPEWRAPPER_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTTYPEWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanDocumentType.hpp>
#include <XercesParserLiaison/XercesNamedNodeMapWrapper.hpp>
class DOMDocumentType;
class XercesWrapperNavigator;
class XercesDocumentWrapper;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentTypeWrapper : public
XalanDocumentType
{
public:
XercesDocumentTypeWrapper(
const DOMDocumentType*
theXercesDOMDocumentType,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesDocumentTypeWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesDocumentTypeWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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 const XalanDOMString&
getPublicId() const;
/**
* Get the system identifier of the external subset.
* @return The system identifier of the external subset.
*/
virtual const XalanDOMString&
getSystemId() const;
/**
* Get the internal subset as a string.
* @return The internal subset as a string.
*/
virtual const XalanDOMString&
getInternalSubset() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMDocumentType*
getXercesNode() const
{
return m_xercesNode;
}
//@}
private:
// Not implemented...
XercesDocumentTypeWrapper(const XercesDocumentTypeWrapper&
theSource);
XercesDocumentTypeWrapper&
operator=(const XercesDocumentTypeWrapper& theSource);
bool
operator==(const XercesDocumentTypeWrapper& theRHS) const;
// Data members...
const DOMDocumentType* const m_xercesNode;
XercesNamedNodeMapWrapper m_entities;
XercesNamedNodeMapWrapper m_notations;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESDOCUMENTTYPEWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.cpp
Index: XercesDocumentWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesDocumentWrapper.hpp"
#include <algorithm>
#include <cassert>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/dom/DOMCDATASection.hpp>
#include <xercesc/dom/DOMComment.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMDocumentType.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMEntity.hpp>
#include <xercesc/dom/DOMEntityReference.hpp>
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include <xercesc/dom/DOMNotation.hpp>
#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include <xercesc/dom/DOMText.hpp>
#include <Include/STLHelper.hpp>
#include <DOMSupport/DOMServices.hpp>
#include <XalanDOM/XalanDocumentType.hpp>
#include <XalanDOM/XalanElement.hpp>
#include "XercesAttrWrapper.hpp"
#include "XercesWrapperHelper.hpp"
#include "XercesCommentWrapper.hpp"
#include "XercesCDATASectionWrapper.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDOMImplementationWrapper.hpp"
#include "XercesDocumentTypeWrapper.hpp"
#include "XercesElementWrapper.hpp"
#include "XercesEntityWrapper.hpp"
#include "XercesEntityReferenceWrapper.hpp"
#include "XercesLiaisonXalanDOMStringPool.hpp"
#include "XercesNodeListWrapper.hpp"
#include "XercesNotationWrapper.hpp"
#include "XercesProcessingInstructionWrapper.hpp"
#include "XercesTextWrapper.hpp"
XercesDocumentWrapper::XercesDocumentWrapper(
const DOMDocument* theXercesDocument,
bool threadSafe,
bool buildWrapper) :
XalanDocument(),
m_xercesDocument(theXercesDocument),
m_documentElement(0),
m_nodeMap(),
m_domImplementation(new
XercesDOMImplementationWrapper(theXercesDocument->getImplementation())),
m_navigators(1, XercesWrapperNavigator(this, threadSafe == true ? false
: !buildWrapper)),
m_navigator(&m_navigators.front()),
m_children(theXercesDocument->getChildNodes(),
*m_navigator),
m_nodes(),
m_doctype(0),
m_mappingMode(threadSafe == true ? false : !buildWrapper),
m_indexValid(false),
m_elementAllocator(25),
m_textAllocator(25),
m_attributeAllocator(25),
m_stringPool(threadSafe == true ? new XercesLiaisonXalanDOMStringPool :
new XalanDOMStringPool)
{
assert(theXercesDocument != 0);
#if !defined(XALAN_NO_NAMESPACES)
using std::make_pair;
#endif
if (m_mappingMode == false)
{
// The document index is always 1...
m_navigator->setIndex(1);
// OK, let's build the nodes. This makes things
// thread-safe, so the document can be shared...
buildWrapperNodes();
}
else
{
m_nodeMap.addAssociation(theXercesDocument, this);
}
}
XercesDocumentWrapper::~XercesDocumentWrapper()
{
destroyWrapper();
}
XalanNode*
XercesDocumentWrapper::mapNode(const DOMNode* theXercesNode) const
{
XalanNode* theXalanNode = 0;
if (theXercesNode != 0)
{
theXalanNode = m_nodeMap.getNode(theXercesNode);
if (theXalanNode == 0)
{
if (theXercesNode != m_xercesDocument &&
theXercesNode->getOwnerDocument() !=
m_xercesDocument &&
theXercesNode->getParentNode() !=
static_cast<const DOMNode*>(m_xercesDocument))
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
}
else if (m_mappingMode == true)
{
// OK, we haven't yet created a bridge not, so
go ahead and
// create one.
theXalanNode = createWrapperNode(theXercesNode,
0, true);
assert(theXalanNode != 0);
}
}
}
return theXalanNode;
}
const DOMNode*
XercesDocumentWrapper::mapNode(XalanNode* theXalanNode) const
{
const DOMNode* theXercesNode = 0;
if (theXalanNode != 0)
{
theXercesNode = m_nodeMap.getNode(theXalanNode);
if (theXercesNode == 0)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
}
}
return theXercesNode;
}
const DOMAttr*
XercesDocumentWrapper::mapNode(XalanAttr* theXalanNode) const
{
const DOMNode* theXercesNode = 0;
if (theXalanNode != 0)
{
theXercesNode = m_nodeMap.getNode(theXalanNode);
if (theXercesNode == 0)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
}
}
#if defined(XALAN_OLD_STYLE_CASTS)
return (const DOMAttr*)theXercesNode;
#else
return static_cast<const DOMAttr*>(theXercesNode);
#endif
}
XalanAttr*
XercesDocumentWrapper::mapNode(const DOMAttr* theXercesNode) const
{
#if defined(XALAN_OLD_STYLE_CASTS)
return (XercesAttrWrapper*)mapNode(theXercesNode);
#else
return static_cast<XercesAttrWrapper*>(mapNode(theXercesNode));
#endif
}
XalanElement*
XercesDocumentWrapper::mapNode(const DOMElement* theXercesNode) const
{
#if defined(XALAN_OLD_STYLE_CASTS)
return (XercesElementWrapper*)mapNode(theXercesNode);
#else
return static_cast<XercesElementWrapper*>(mapNode(theXercesNode));
#endif
}
void
XercesDocumentWrapper::destroyWrapper()
{
#if !defined(XALAN_NO_NAMESPACES)
using std::for_each;
#endif
// Set this to null, since it will be deleted
// by the next for_each...
m_doctype = 0;
// m_bridgeMap contains all of the nodes that
// are still alive...
for_each(m_nodes.begin(),
m_nodes.end(),
DeleteFunctor<XalanNode>());
// Clear everything out, since we just delete everything...
m_nodes.clear();
// Clear out all of the navigators, except ours...
m_navigators.erase(m_navigators.begin() + 1, m_navigators.end());
m_navigator = &m_navigators.front();
// Clear the node map...
m_nodeMap.clear();
m_indexValid = false;
m_mappingMode = true;
m_stringPool->clear();
}
void
XercesDocumentWrapper::rebuildWrapper()
{
destroyWrapper();
buildWrapperNodes();
}
XercesWrapperNavigator&
XercesDocumentWrapper::pushNavigator(bool mappingMode) const
{
XercesDocumentWrapper* const This =
#if defined(XALAN_OLD_STYLE_CASTS)
(XercesDocumentWrapper*)this;
#else
const_cast<XercesDocumentWrapper*>(this);
#endif
This->m_navigators.push_back(XercesWrapperNavigator(This, mappingMode));
return This->m_navigators.back();
}
XercesDocumentTypeWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMDocumentType* theDoctype,
unsigned long theIndex,
bool
mapNode) const
{
// This is a special case, since there is only one
// doctype node allowed...
assert(m_doctype == 0);
assert(m_xercesDocument->getDoctype() != 0 &&
m_xercesDocument->getDoctype() == theDoctype);
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
// Update the member variable for the new instance.
This->m_doctype = new XercesDocumentTypeWrapper(theDoctype,
theNavigator);
if (mapNode == true)
{
This->m_nodeMap.addAssociation(theDoctype, m_doctype);
}
This->m_nodes.push_back(m_doctype);
return m_doctype;
}
XercesElementWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMElement* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
XercesElementWrapper* const theWrapper =
This->m_elementAllocator.create(theXercesNode,
theNavigator);
if (m_doctype != 0 || mapNode == true)
{
// Add it to the node map, since we my need it for getting
// elements by ID, or we're in mapping mode.
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesTextWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMText* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
XercesTextWrapper* const theWrapper =
This->m_textAllocator.create(theXercesNode,
theNavigator);
if (mapNode == true)
{
// Add it to the node map...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesCommentWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMComment* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesCommentWrapper* const theWrapper =
new XercesCommentWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
if (mapNode == true)
{
// Add it to the node map...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesCDATASectionWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMCDATASection* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesCDATASectionWrapper* const theWrapper =
new XercesCDATASectionWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
if (mapNode == true)
{
// Add it to the node map...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesProcessingInstructionWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMProcessingInstruction* theXercesNode,
unsigned long
theIndex,
bool
mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesProcessingInstructionWrapper* const theWrapper =
new XercesProcessingInstructionWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
if (mapNode == true)
{
// Add it to the node map...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesAttrWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMAttr* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
XercesAttrWrapper* const theWrapper =
This->m_attributeAllocator.create(theXercesNode,
theNavigator);
// Add it to the node map -- attributes ALWAYS go in the map
// for now...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
return theWrapper;
}
XercesEntityWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMEntity* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesEntityWrapper* const theWrapper =
new XercesEntityWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
// Add it to the node map -- entities ALWAYS go in the map
// for now...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
return theWrapper;
}
XercesEntityReferenceWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMEntityReference* theXercesNode,
unsigned long theIndex,
bool
mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesEntityReferenceWrapper* const theWrapper =
new XercesEntityReferenceWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
if (mapNode == true)
{
// Add it to the node map...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
}
return theWrapper;
}
XercesNotationWrapper*
XercesDocumentWrapper::createWrapperNode(
const DOMNotation* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
// Create a navigator...
XercesWrapperNavigator& theNavigator = pushNavigator(mapNode);
theNavigator.setIndex(theIndex);
XercesNotationWrapper* const theWrapper =
new XercesNotationWrapper(theXercesNode,
theNavigator);
#if defined(XALAN_NO_MUTABLE)
XercesDocumentWrapper* const This =
(XercesDocumentWrapper*)this;
#else
const XercesDocumentWrapper* const This =
this;
#endif
This->m_nodes.push_back(theWrapper);
// Add it to the node map -- notations ALWAYS go in the map
// for now...
This->m_nodeMap.addAssociation(theXercesNode, theWrapper);
return theWrapper;
}
XalanNode*
XercesDocumentWrapper::createWrapperNode(
const DOMNode* theXercesNode,
unsigned long theIndex,
bool mapNode) const
{
assert(theXercesNode != 0);
XalanNode* theNewNode = 0;
switch(theXercesNode->getNodeType())
{
case DOMNode::ATTRIBUTE_NODE:
{
const DOMAttr* theAttrNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const DOMAttr*)theXercesNode;
#else
static_cast<const
DOMAttr*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theAttrNode, theIndex,
mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::CDATA_SECTION_NODE:
{
const DOMCDATASection* theCDATASectionNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMCDATASection*)theXercesNode;
#else
static_cast<const
DOMCDATASection*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theCDATASectionNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::COMMENT_NODE:
{
const DOMComment* theCommentNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMComment*)theXercesNode;
#else
static_cast<const
DOMComment*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theCommentNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::DOCUMENT_FRAGMENT_NODE:
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
break;
case DOMNode::ELEMENT_NODE:
{
const DOMElement* theElementNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMElement*)theXercesNode;
#else
static_cast<const
DOMElement*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theElementNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::ENTITY_NODE:
{
const DOMEntity* theEntityNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const DOMEntity*)theXercesNode;
#else
static_cast<const
DOMEntity*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theEntityNode, theIndex,
mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::ENTITY_REFERENCE_NODE:
{
const DOMEntityReference* theEntityReferenceNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMEntityReference*)theXercesNode;
#else
static_cast<const
DOMEntityReference*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theEntityReferenceNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::NOTATION_NODE:
{
const DOMNotation* theNotationNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMNotation*)theXercesNode;
#else
static_cast<const
DOMNotation*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theNotationNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::PROCESSING_INSTRUCTION_NODE:
{
const DOMProcessingInstruction* thePINode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMProcessingInstruction*)theXercesNode;
#else
static_cast<const
DOMProcessingInstruction*>(theXercesNode);
#endif
theNewNode = createWrapperNode(thePINode, theIndex,
mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::TEXT_NODE:
{
const DOMText* theTextNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const DOMText*)theXercesNode;
#else
static_cast<const
DOMText*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theTextNode, theIndex,
mapNode);
assert(theNewNode != 0);
}
break;
case DOMNode::DOCUMENT_TYPE_NODE:
{
const DOMDocumentType* theDoctypeNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const
DOMDocumentType*)theXercesNode;
#else
static_cast<const
DOMDocumentType*>(theXercesNode);
#endif
theNewNode = createWrapperNode(theDoctypeNode,
theIndex, mapNode);
assert(theNewNode != 0);
}
break;
default:
assert(false);
break;
}
return theNewNode;
}
void
XercesDocumentWrapper::destroyNode(XalanNode* theNode)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::find;
#endif
const NodeVectorType::iterator i =
find(m_nodes.begin(), m_nodes.end(), theNode);
if (i == m_nodes.end())
{
// Doesn't belong to this doc, so throw...
throw
XercesDOMWrapperException(XercesDOMWrapperException::WRONG_DOCUMENT_ERR);
}
else
{
// Delete the node...
delete *i;
// Erase it from the map...
m_nodes.erase(i);
}
}
const XalanDOMString&
XercesDocumentWrapper::getNodeName() const
{
assert(m_navigator != 0);
return m_navigator->getPooledString(m_xercesDocument->getNodeName());
}
const XalanDOMString&
XercesDocumentWrapper::getNodeValue() const
{
assert(m_navigator != 0);
return m_navigator->getPooledString(m_xercesDocument->getNodeValue());
}
XercesDocumentWrapper::NodeType
XercesDocumentWrapper::getNodeType() const
{
return DOCUMENT_NODE;
}
XalanNode*
XercesDocumentWrapper::getParentNode() const
{
return 0;
}
const XalanNodeList*
XercesDocumentWrapper::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesDocumentWrapper::getFirstChild() const
{
assert(m_navigator != 0);
return m_navigator->getFirstChild(m_xercesDocument);
}
XalanNode*
XercesDocumentWrapper::getLastChild() const
{
assert(m_navigator != 0);
return m_navigator->getLastChild(m_xercesDocument);
}
XalanNode*
XercesDocumentWrapper::getPreviousSibling() const
{
return 0;
}
XalanNode*
XercesDocumentWrapper::getNextSibling() const
{
return 0;
}
const XalanNamedNodeMap*
XercesDocumentWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesDocumentWrapper::getOwnerDocument() const
{
return 0;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesDocumentWrapper*
#endif
XercesDocumentWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesDocumentWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesDocumentWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNode*
XercesDocumentWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNode*
XercesDocumentWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
bool
XercesDocumentWrapper::hasChildNodes() const
{
return m_xercesDocument->hasChildNodes();
}
void
XercesDocumentWrapper::setNodeValue(const XalanDOMString& nodeValue)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesDocumentWrapper::normalize()
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesDocumentWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesDocument, feature,
version);
}
const XalanDOMString&
XercesDocumentWrapper::getNamespaceURI() const
{
assert(m_navigator != 0);
return
m_navigator->getPooledString(m_xercesDocument->getNamespaceURI());
}
const XalanDOMString&
XercesDocumentWrapper::getPrefix() const
{
assert(m_navigator != 0);
return m_navigator->getPooledString(m_xercesDocument->getPrefix());
}
const XalanDOMString&
XercesDocumentWrapper::getLocalName() const
{
assert(m_navigator != 0);
return m_navigator->getPooledString(m_xercesDocument->getLocalName());
}
void
XercesDocumentWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesDocumentWrapper::isIndexed() const
{
return m_indexValid;
}
unsigned long
XercesDocumentWrapper::getIndex() const
{
assert(m_navigator != 0);
assert(m_navigator->getIndex() == 1);
return m_navigator->getIndex();
}
XalanElement*
XercesDocumentWrapper::createElement(const XalanDOMString& tagName)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanDocumentFragment*
XercesDocumentWrapper::createDocumentFragment()
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanText*
XercesDocumentWrapper::createTextNode(const XalanDOMString& data)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanComment*
XercesDocumentWrapper::createComment(const XalanDOMString& data)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanCDATASection*
XercesDocumentWrapper::createCDATASection(const XalanDOMString& data)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanProcessingInstruction*
XercesDocumentWrapper::createProcessingInstruction(
const XalanDOMString& target,
const XalanDOMString& data)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanAttr*
XercesDocumentWrapper::createAttribute(const XalanDOMString& name)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanEntityReference*
XercesDocumentWrapper::createEntityReference(const XalanDOMString& name)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanDocumentType*
XercesDocumentWrapper::getDoctype() const
{
return m_doctype;
}
XalanDOMImplementation*
XercesDocumentWrapper::getImplementation() const
{
return m_domImplementation.get();
}
XalanElement*
XercesDocumentWrapper::getDocumentElement() const
{
// If we're working in mapping mode, m_documentElement will
// be null, so we'll have to map the node...
return m_documentElement != 0 ? m_documentElement :
mapNode(m_xercesDocument->getDocumentElement());
}
XalanNodeList*
XercesDocumentWrapper::getElementsByTagName(const XalanDOMString& /*
tagname */) const
{
// Not supported...
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
// Dummy return value...
return 0;
}
XalanNode*
XercesDocumentWrapper::importNode(
XalanNode* importedNode,
bool deep)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NO_MODIFICATION_ALLOWED_ERR);
// Dummy return value...
return 0;
}
XalanElement*
XercesDocumentWrapper::createElementNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName)
{
// Not supported...
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
// Dummy return value...
return 0;
}
XalanAttr*
XercesDocumentWrapper::createAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& qualifiedName)
{
// Not supported...
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
// Dummy return value...
return 0;
}
XalanNodeList*
XercesDocumentWrapper::getElementsByTagNameNS(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* localName */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
// Dummy return value...
return 0;
}
XalanElement*
XercesDocumentWrapper::getElementById(const XalanDOMString& /*
elementId */) const
{
// Not supported...
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
// Dummy return value...
return 0;
}
void
XercesDocumentWrapper::buildWrapperNodes()
{
const DOMNode* theStartChild = m_xercesDocument->getFirstChild();
if (theStartChild != 0)
{
assert(m_navigator != 0);
assert(m_navigators.size() == 1);
m_navigator->setIndex(1);
m_navigator->setFirstChild(0);
BuildWrapperTreeWalker theTreeWalker(
this,
&m_navigators.back(),
m_navigators,
2);
theTreeWalker.traverse(theStartChild, m_xercesDocument);
}
// OK, now set m_documentElement...
XalanNode* theChild = m_navigator->getFirstChild();
while(theChild != 0 && theChild->getNodeType() !=
XalanNode::ELEMENT_NODE)
{
theChild = theChild->getNextSibling();
}
#if defined(XALAN_OLD_STYLE_CASTS)
m_documentElement = (XalanElement*)theChild;
#else
m_documentElement = static_cast<XalanElement*>(theChild);
#endif
m_indexValid = true;
m_mappingMode = false;
}
XercesDocumentWrapper::BuildWrapperTreeWalker::BuildWrapperTreeWalker(
XercesDocumentWrapper* theDocument,
XercesWrapperNavigator*
theDocumentNavigator,
WrapperNavigatorVectorType& theNavigators,
unsigned long
theStartIndex) :
m_document(theDocument),
m_navigators(theNavigators),
m_currentIndex(theStartIndex),
m_parentNavigatorStack(),
m_siblingNavigatorStack()
{
assert(theDocument != 0 && theDocumentNavigator != 0);
// Reserve some space...
m_parentNavigatorStack.reserve(100);
m_parentNavigatorStack.reserve(100);
// The document navigator is the last navigator on the stack...
m_parentNavigatorStack.push_back(NavigatorStackEntryType(theDocumentNavigator,
theDocument));
// There is no previous sibling...
m_siblingNavigatorStack.push_back(NavigatorStackEntryType(0, 0));
}
XercesDocumentWrapper::BuildWrapperTreeWalker::~BuildWrapperTreeWalker()
{
}
void
XercesDocumentWrapper::BuildWrapperTreeWalker::startNode(const DOMNode*
node)
{
XalanNode* const theWrapperNode =
m_document->createWrapperNode(node, m_currentIndex, false);
XercesWrapperNavigator& theCurrentNodeNavigator = m_navigators.back();
assert(m_parentNavigatorStack.empty() == false);
assert(m_siblingNavigatorStack.empty() == false);
// Get the two navigators...
NavigatorStackEntryType& theParentEntry =
m_parentNavigatorStack.back();
NavigatorStackEntryType& theSiblingEntry =
m_siblingNavigatorStack.back();
theCurrentNodeNavigator.setParentNode(theParentEntry.m_node);
// If the first child has not been set, then set it
// now...
if (theParentEntry.m_navigator->getFirstChild() == 0)
{
assert(theSiblingEntry.m_node == 0);
theParentEntry.m_navigator->setFirstChild(theWrapperNode);
}
// Always set the last child...
theParentEntry.m_navigator->setLastChild(theWrapperNode);
theCurrentNodeNavigator.setPreviousSibling(theSiblingEntry.m_node);
if (theSiblingEntry.m_navigator != 0)
{
theSiblingEntry.m_navigator->setNextSibling(theWrapperNode);
}
// Build an entry for the stacks...
const NavigatorStackEntryType
theCurrentEntry(&theCurrentNodeNavigator, theWrapperNode);
// My child nodes will now be visited, so push the current
// context on the parent stack...
m_parentNavigatorStack.push_back(theCurrentEntry);
// My siblings will also need to know about me as well...
m_siblingNavigatorStack.push_back(theCurrentEntry);
// This will serve to mark the sibling context for my first child,
// since it has no previous sibling. This will be popped off
// when endNode() is called.
m_siblingNavigatorStack.push_back(NavigatorStackEntryType(0, 0));
// Finally, increment the index counter...
++m_currentIndex;
const short theType = node->getNodeType();
if (theType == DOMNode::DOCUMENT_TYPE_NODE)
{
// Special case for doctype -- we have to build its entities...
const DOMDocumentType* const theDoctype =
#if defined(XALAN_OLD_STYLE_CASTS)
(const DOMDocumentType*)node;
#else
static_cast<const DOMDocumentType*>(node);
#endif
const DOMNamedNodeMap* const theEntities =
theDoctype->getEntities();
const unsigned int theLength =
theEntities->getLength();
for (unsigned int i = 0; i < theLength; ++i)
{
// Build it, but don't index it...
m_document->createWrapperNode(theEntities->item(i),
m_currentIndex++, true);
}
}
else if (theType == DOMNode::ELEMENT_NODE)
{
// Special case for element nodes -- we have to build the attributes...
const DOMElement* const theElement =
#if defined(XALAN_OLD_STYLE_CASTS)
(const DOMElement*)node;
#else
static_cast<const DOMElement*>(node);
#endif
const DOMNamedNodeMap* const theAttributes =
theElement->getAttributes();
assert(theAttributes != 0);
const unsigned int theLength =
theAttributes->getLength();
XercesWrapperNavigator* thePreviousAttrNavigator = 0;
XalanNode* thePreviousAttr = 0;
for (unsigned int i = 0; i < theLength; ++i)
{
// Get the attribute from the node map...
const DOMNode* const theAttr =
theAttributes->item(i);
assert(theAttr != 0);
// Create a bridge node.
XalanNode* const theCurrentAttr =
m_document->createWrapperNode(theAttr,
m_currentIndex, false);
assert(theCurrentAttr != 0);
// Get the attribute node's navigator...
XercesWrapperNavigator& theCurrentAttrNavigator =
m_navigators.back();
// Set the parent node...
theCurrentAttrNavigator.setParentNode(theWrapperNode);
if (thePreviousAttr != 0)
{
assert(thePreviousAttrNavigator != 0);
// Link in the previous attribute...
theCurrentAttrNavigator.setPreviousSibling(thePreviousAttr);
thePreviousAttrNavigator->setNextSibling(theCurrentAttr);
}
// Update the pointers so they point to this
attribute...
thePreviousAttr = theCurrentAttr;
thePreviousAttrNavigator = &theCurrentAttrNavigator;
// Finally, increment the index...
++m_currentIndex;
}
}
}
void
XercesDocumentWrapper::BuildWrapperTreeWalker::endNode(const DOMNode* /* node
*/)
{
assert(m_parentNavigatorStack.empty() == false);
assert(m_siblingNavigatorStack.empty() == false);
// I have to pop my entry, since my children are finished...
m_parentNavigatorStack.pop_back();
// Pop any sibling navigators my child pushed...
while(m_siblingNavigatorStack.back().m_navigator != 0)
{
assert(m_siblingNavigatorStack.back().m_node != 0);
m_siblingNavigatorStack.pop_back();
}
// There must be a context marker...
assert(m_siblingNavigatorStack.back().m_navigator == 0 &&
m_siblingNavigatorStack.back().m_node == 0);
// Pop the context marker...
m_siblingNavigatorStack.pop_back();
}
const XalanDOMString&
XercesDocumentWrapper::getPooledString(const XalanDOMString& theString) const
{
return m_stringPool->get(theString);
}
const XalanDOMString&
XercesDocumentWrapper::getPooledString(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength) const
{
return m_stringPool->get(theString, theLength);
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDocumentWrapper.hpp
Index: XercesDocumentWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680)
#define XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <deque>
#include <set>
#include <vector>
#include <XalanDOM/XalanDocument.hpp>
#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
#include <XalanDOM/XalanDOMImplementation.hpp>
#include <PlatformSupport/XalanDOMStringPool.hpp>
#endif
#include <Include/XalanAutoPtr.hpp>
#include <XercesParserLiaison/XercesDOMWalker.hpp>
#include <XercesParserLiaison/XercesWrapperNavigator.hpp>
#include <XercesParserLiaison/XercesWrapperToXalanNodeMap.hpp>
#include <XercesParserLiaison/XercesNodeListWrapper.hpp>
#include <XercesParserLiaison/XercesAttrWrapperAllocator.hpp>
#include <XercesParserLiaison/XercesElementWrapperAllocator.hpp>
#include <XercesParserLiaison/XercesTextWrapperAllocator.hpp>
class DOMComment;
class DOMEntity;
class DOMEntityReference;
class DOMDocument;
class DOMDocumentType;
class DOMAttr;
class DOMElement;
class DOMCDATASection;
class DOMNotation;
class DOMText;
class DOMProcessingInstruction;
class XalanDOMStringPool;
class XercesCommentWrapper;
class XercesCDATASectionWrapper;
class XercesDocumentFragmentWrapper;
class XercesDocumentTypeWrapper;
class XercesEntityWrapper;
class XercesEntityReferenceWrapper;
class XercesProcessingInstructionWrapper;
class XercesNotationWrapper;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDocumentWrapper : public
XalanDocument
{
public:
friend class XercesWrapperNavigator;
/**
*
* Constructor for XercesDocumentWrapper.
*
* If the document will be shared amongst multiple threads of execution,
* the parameter buildWrapper must be true. Otherwise, the bridge
* nodes will be built on demand, a process which is not synchronized.
* This could cause serious problems if multiple threads tried to visit
* an unbuilt node at the same time.
*
* @param theXercesDocument The Xerces document to bridge
* @param threadSafe If true, the tree can safely be shared amongst
multiple threads. (Also implies buildWrapper == true)
* @param buildWrapper If true, all of the bridge nodes will be built
during construction.
*
*/
XercesDocumentWrapper(
const DOMDocument* theXercesDocument,
bool threadSafe = true,
bool buildWrapper = true);
virtual
~XercesDocumentWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
virtual const 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 XercesDocumentWrapper*
#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
isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const;
virtual const XalanDOMString&
getNamespaceURI() const;
virtual const XalanDOMString&
getPrefix() const;
virtual const XalanDOMString&
getLocalName() const;
virtual void
setPrefix(const XalanDOMString& prefix);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
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.
/**
* Destroy the entire bridge structure that connects
* the Xerces document to this XercesDocumentWrapper
* instance. This will invalidate any pointers to
* any nodes in the document (except, of course, the
* document itself).
*/
void
destroyWrapper();
/**
* Rebuild the entire bridge structure that connects
* the Xerces document to this XercesDocumentWrapper
* instance. This destroys the bridge before
* rebuilding.
*/
void
rebuildWrapper();
XalanNode*
mapNode(const DOMNode* theXercesNode) const;
XalanAttr*
mapNode(const DOMAttr* theXercesNode) const;
XalanElement*
mapNode(const DOMElement* theXercesNode) const;
const DOMNode*
mapNode(XalanNode* theXalanNode) const;
const DOMAttr*
mapNode(XalanAttr* theXalanNode) const;
/**
*
* Get the Xerces DOMDocument that this XercesDocument represents.
*
* @return the Xerces DOMDocument instance.
*
*/
const DOMDocument*
getXercesDocument() const
{
return m_xercesDocument;
}
/**
* Build the entire bridge structure. This should be done before any
* processing begins, if the tree will be shared amongst multiple
* threads.
*/
void
buildWrapperNodes();
#if defined(XALAN_NO_NAMESPACES)
typedef deque<XercesWrapperNavigator> WrapperNavigatorVectorType;
typedef deque<XalanNode*> NodeVectorType;
#else
typedef std::deque<XercesWrapperNavigator>
WrapperNavigatorVectorType;
typedef std::deque<XalanNode*> NodeVectorType;
#endif
// Helper class to walk the tree and build everything...
class BuildWrapperTreeWalker : public XercesDOMWalker
{
public:
typedef WrapperNavigatorVectorType
WrapperNavigatorVectorInnerType;
BuildWrapperTreeWalker(
XercesDocumentWrapper*
theDocument,
XercesWrapperNavigator*
theDocumentNavigator,
WrapperNavigatorVectorInnerType&
theNavigators,
unsigned long
theStartIndex);
virtual
~BuildWrapperTreeWalker();
struct NavigatorStackEntryType
{
NavigatorStackEntryType(
XercesWrapperNavigator*
theNavigator = 0,
XalanNode*
theNode = 0) :
m_navigator(theNavigator),
m_node(theNode)
{
}
XercesWrapperNavigator* m_navigator;
XalanNode* m_node;
};
#if defined(XALAN_NO_NAMESPACES)
typedef vector<NavigatorStackEntryType>
NavigatorStackType;
#else
typedef std::vector<NavigatorStackEntryType>
NavigatorStackType;
#endif
protected:
virtual void
startNode(const DOMNode* node);
virtual void
endNode(const DOMNode* node);
private:
XercesDocumentWrapper* m_document;
WrapperNavigatorVectorInnerType& m_navigators;
unsigned long
m_currentIndex;
NavigatorStackType
m_parentNavigatorStack;
NavigatorStackType
m_siblingNavigatorStack;
};
/**
* Get a pooled string. If the string is not in the pool,
* add it.
*
* @param theString The string to pool.
* @return A const reference to the pooled string.
*/
const XalanDOMString&
getPooledString(const XalanDOMString& theString) const;
/**
* Get a pooled string. If the string is not in the pool,
* add it.
*
* @param theString The string to pool.
* @param theLength The length of the string. If XalanDOMString::npos,
the string is assumed to be null-terminated.
* @return A const reference to the pooled string.
*/
const XalanDOMString&
getPooledString(
const XalanDOMChar* theString,
XalanDOMString::size_type theLength /* =
XalanDOMString::npos */) const;
private:
// Destruction API...
void
destroyWrapperNode(XalanNode* theNode);
// Not implemented...
XercesDocumentWrapper(const XercesDocumentWrapper& theSource);
XercesDocumentWrapper&
operator=(const XercesDocumentWrapper& theRHS);
bool
operator==(const XercesDocumentWrapper& theRHS) const;
// Private delete function...
void
destroyNode(XalanNode* theNode);
// More internal implementation stuff...
// Factory methods for our implementation nodes...
XalanNode*
createWrapperNode(
const DOMNode* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesDocumentTypeWrapper*
createWrapperNode(
const DOMDocumentType* theDoctype,
unsigned long theIndex,
bool mapNode) const;
XercesElementWrapper*
createWrapperNode(
const DOMElement* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesTextWrapper*
createWrapperNode(
const DOMText* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesCommentWrapper*
createWrapperNode(
const DOMComment* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesCDATASectionWrapper*
createWrapperNode(
const DOMCDATASection* theXercesNode,
unsigned long theIndex,
bool
mapNode) const;
XercesProcessingInstructionWrapper*
createWrapperNode(
const DOMProcessingInstruction* theXercesNode,
unsigned long
theIndex,
bool
mapNode) const;
XercesAttrWrapper*
createWrapperNode(
const DOMAttr* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesEntityWrapper*
createWrapperNode(
const DOMEntity* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesEntityReferenceWrapper*
createWrapperNode(
const DOMEntityReference* theXercesNode,
unsigned long theIndex,
bool
mapNode) const;
XercesNotationWrapper*
createWrapperNode(
const DOMNotation* theXercesNode,
unsigned long theIndex,
bool mapNode) const;
XercesWrapperNavigator&
pushNavigator(bool mappingMode) const;
// This is a private helper class for building the tree...
friend class BuildWrapperTreeWalker;
const DOMDocument* const
m_xercesDocument;
XalanElement*
m_documentElement;
mutable XercesWrapperToXalanNodeMap m_nodeMap;
XalanAutoPtr<XalanDOMImplementation> m_domImplementation;
mutable WrapperNavigatorVectorType m_navigators;
// Our navigator will be the first entry in m_navigators,
// but we'll cache this so access is faster...
XercesWrapperNavigator* m_navigator;
XercesNodeListWrapper m_children;
mutable NodeVectorType m_nodes;
mutable XercesDocumentTypeWrapper* m_doctype;
bool
m_mappingMode;
bool
m_indexValid;
mutable XercesElementWrapperAllocator m_elementAllocator;
mutable XercesTextWrapperAllocator m_textAllocator;
mutable XercesAttrWrapperAllocator m_attributeAllocator;
const XalanAutoPtr<XalanDOMStringPool> m_stringPool;
};
#endif // !defined(XERCESDOCUMENTWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDOMImplementationWrapper.cpp
Index: XercesDOMImplementationWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesDOMImplementationWrapper.hpp"
#include <xercesc/dom/DOMImplementation.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include "XercesDOMException.hpp"
XercesDOMImplementationWrapper::XercesDOMImplementationWrapper(DOMImplementation*
theXercesDOMImplementation) :
XalanDOMImplementation(),
m_xercesNode(theXercesDOMImplementation)
{
assert(theXercesDOMImplementation != 0);
}
XercesDOMImplementationWrapper::~XercesDOMImplementationWrapper()
{
}
XercesDOMImplementationWrapper::XercesDOMImplementationWrapper(const
XercesDOMImplementationWrapper& theSource) :
XalanDOMImplementation(theSource),
m_xercesNode(theSource.m_xercesNode)
{
}
bool
XercesDOMImplementationWrapper::hasFeature(
const XalanDOMString& feature,
const XalanDOMString& version)
{
return m_xercesNode->hasFeature(c_wstr(feature), c_wstr(version));
}
XalanDocumentType*
XercesDOMImplementationWrapper::createDocumentType(
const XalanDOMString& /* qualifiedName */,
const XalanDOMString& /* publicId */,
const XalanDOMString& /* systemId */)
{
throw
XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanDocument*
XercesDOMImplementationWrapper::createDocument(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* qualifiedName */,
const XalanDocumentType& /* doctype */)
{
throw
XercesDOMException(XercesDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDOMImplementationWrapper.hpp
Index: XercesDOMImplementationWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESDOMIMPLEMENTATIONWRAPPER_HEADER_GUARD_1357924680)
#define XERCESDOMIMPLEMENTATIONWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanDOMImplementation.hpp>
class DOMImplementation;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMImplementationWrapper :
public XalanDOMImplementation
{
public:
XercesDOMImplementationWrapper(DOMImplementation*
theXercesDOMImplementation);
virtual
~XercesDOMImplementationWrapper();
/** @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 XalanDOMString& qualifiedName,
const XalanDOMString& publicId,
const XalanDOMString& 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);
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
DOMImplementation*
getXercesNode() const
{
return m_xercesNode;
}
//@}
private:
// These are not defined...
XercesDOMImplementationWrapper(const XercesDOMImplementationWrapper&
theSource);
XercesDOMImplementationWrapper&
operator=(const XercesDOMImplementationWrapper& theSource);
bool
operator==(const XercesDOMImplementationWrapper& theRHS) const;
// Data members...
DOMImplementation* const m_xercesNode;
};
#endif // !defined
(XERCESDOMIMPLEMENTATIONWRAPPER_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.cpp
Index: XercesDOMWalker.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Class header file.
#include "XercesDOMWalker.hpp"
// Xerces header files...
#include <xercesc/dom/DOMNode.hpp>
XercesDOMWalker::XercesDOMWalker()
{
}
XercesDOMWalker::~XercesDOMWalker()
{
}
void
XercesDOMWalker::traverse(const DOMNode* pos)
{
const DOMNode* thePos = pos;
while(thePos != 0)
{
startNode(thePos);
const DOMNode* nextNode = thePos->getFirstChild();
while(nextNode == 0)
{
endNode(thePos);
nextNode = pos->getNextSibling();
if(nextNode == 0)
{
thePos = thePos->getParentNode();
if(thePos == 0)
{
nextNode = thePos;
break;
}
}
}
thePos = nextNode;
}
}
void
XercesDOMWalker::traverse(
const DOMNode* pos,
const DOMNode* parent)
{
const DOMNode* thePos = pos;
while(parent != thePos)
{
startNode(thePos);
const DOMNode* nextNode = thePos->getFirstChild();
while(nextNode == 0)
{
endNode(thePos);
nextNode = thePos->getNextSibling();
if(nextNode == 0)
{
thePos = thePos->getParentNode();
if(parent == thePos)
{
nextNode = thePos;
break;
}
}
}
thePos = nextNode;
}
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.hpp
Index: XercesDOMWalker.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESDOMWALKER_HEADER_GUARD_1357924680)
#define XERCESDOMWALKER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
class DOMNode;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMWalker
{
public:
/**
* Constructor.
*/
XercesDOMWalker();
virtual
~XercesDOMWalker();
/**
* Perform a pre-order traversal non-recursive style.
*/
virtual void
traverse(const DOMNode* pos);
/**
* Perform a pre-order traversal non-recursive style.
*/
virtual void
traverse(
const DOMNode* pos,
const DOMNode* parent);
protected:
virtual void
startNode(const DOMNode* node) = 0;
virtual void
endNode(const DOMNode* node) = 0;
};
#endif // XERCESDOMWALKER_HEADER_GUARD_1357924680
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDOMWrapperException.cpp
Index: XercesDOMWrapperException.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesDOMWrapperException.hpp"
#include <cassert>
XercesDOMWrapperException::XercesDOMWrapperException(ExceptionCode code) :
XalanDOMException(code)
{
}
XercesDOMWrapperException::XercesDOMWrapperException(const DOMException&
theException) :
XalanDOMException(translateErrorCode(theException.code))
{
}
XercesDOMWrapperException::XercesDOMWrapperException(const
XercesDOMWrapperException& theSource) :
XalanDOMException(theSource)
{
}
XercesDOMWrapperException::~XercesDOMWrapperException()
{
}
XercesDOMWrapperException::ExceptionCode
XercesDOMWrapperException::translateErrorCode(DOMException::ExceptionCode
theCode)
{
ExceptionCode theXalanCode = UNKNOWN_ERR;
switch(theCode)
{
case DOMException::INDEX_SIZE_ERR:
theXalanCode = INDEX_SIZE_ERR;
break;
case DOMException::DOMSTRING_SIZE_ERR:
theXalanCode = DOMSTRING_SIZE_ERR;
break;
case DOMException::HIERARCHY_REQUEST_ERR:
theXalanCode = HIERARCHY_REQUEST_ERR;
break;
case DOMException::WRONG_DOCUMENT_ERR:
theXalanCode = WRONG_DOCUMENT_ERR;
break;
case DOMException::INVALID_CHARACTER_ERR:
theXalanCode = INVALID_CHARACTER_ERR;
break;
case DOMException::NO_DATA_ALLOWED_ERR:
theXalanCode = NO_DATA_ALLOWED_ERR;
break;
case DOMException::NO_MODIFICATION_ALLOWED_ERR:
theXalanCode = NO_MODIFICATION_ALLOWED_ERR;
break;
case DOMException::NOT_FOUND_ERR:
theXalanCode = NOT_FOUND_ERR;
break;
case DOMException::NOT_SUPPORTED_ERR:
theXalanCode = INDEX_SIZE_ERR;
break;
case DOMException::INUSE_ATTRIBUTE_ERR:
theXalanCode = INUSE_ATTRIBUTE_ERR;
break;
case DOMException::INVALID_STATE_ERR:
theXalanCode = INVALID_STATE_ERR;
break;
case DOMException::SYNTAX_ERR:
theXalanCode = SYNTAX_ERR;
break;
case DOMException::INVALID_MODIFICATION_ERR:
theXalanCode = INVALID_MODIFICATION_ERR;
break;
case DOMException::NAMESPACE_ERR:
theXalanCode = NAMESPACE_ERR;
break;
case DOMException::INVALID_ACCESS_ERR:
theXalanCode = INVALID_ACCESS_ERR;
break;
default:
assert(false);
break;
};
return theXalanCode;
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesDOMWrapperException.hpp
Index: XercesDOMWrapperException.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESDOMWRAPPEREXCEPTION_HEADER_GUARD_1357924680)
#define XERCESDOMWRAPPEREXCEPTION_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <XalanDOM/XalanDOMException.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesDOMWrapperException : public
XalanDOMException
{
public:
/** @name Constructors and assignment operator */
//@{
/**
* Constructor which takes an error code.
*
* @param code The error code which indicates the exception
*/
explicit
XercesDOMWrapperException(ExceptionCode code = UNKNOWN_ERR);
/**
* Constructor which takes a Xerces exception and
* translates it into a XercesDOMException.
*
* @param code The Xerces DOM_DOMException instance.
*/
XercesDOMWrapperException(const DOMException& theException);
/**
* Copy constructor.
*
* @param other The object to be copied.
*/
XercesDOMWrapperException(const XercesDOMWrapperException&
theSource);
//@}
/** @name Destructor. */
//@{
/**
* Destructor for XercesDOMException.
*/
virtual
~XercesDOMWrapperException();
//@}
private:
static ExceptionCode
translateErrorCode(DOMException::ExceptionCode theCode);
};
#endif // !defined(XERCESDOMWRAPPEREXCEPTION_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesElementWrapper.cpp
Index: XercesElementWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesElementWrapper.hpp"
#include <xercesc/dom/DOMElement.hpp>
#include <XalanDOM/XalanAttr.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesElementWrapper::XercesElementWrapper(
const DOMElement*
theXercesElement,
const XercesWrapperNavigator& theNavigator) :
XalanElement(),
m_xercesNode(theXercesElement),
m_navigator(theNavigator),
m_children(theXercesElement->getChildNodes(),
theNavigator),
m_attributes(theXercesElement->getAttributes(),
theNavigator)
{
assert(theXercesElement != 0);
}
XercesElementWrapper::~XercesElementWrapper()
{
}
const XalanDOMString&
XercesElementWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesElementWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesElementWrapper::NodeType
XercesElementWrapper::getNodeType() const
{
return ELEMENT_NODE;
}
XalanNode*
XercesElementWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesElementWrapper::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesElementWrapper::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesElementWrapper::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesElementWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesElementWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesElementWrapper::getAttributes() const
{
return &m_attributes;
}
XalanDocument*
XercesElementWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesElementWrapper*
#endif
XercesElementWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesElementWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesElementWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesElementWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesElementWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesElementWrapper::hasChildNodes() const
{
return m_xercesNode->hasChildNodes();
}
void
XercesElementWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesElementWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesElementWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesElementWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesElementWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesElementWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesElementWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesElementWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesElementWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesElementWrapper::getTagName() const
{
return m_navigator.getPooledString(m_xercesNode->getTagName());
}
const XalanDOMString&
XercesElementWrapper::getAttribute(const XalanDOMString& name)
const
{
return
m_navigator.getPooledString(m_xercesNode->getAttribute(c_wstr(name)));
}
XalanAttr*
XercesElementWrapper::getAttributeNode(const XalanDOMString& name)
const
{
#if defined(XALAN_OLD_STYLE_CASTS)
return (XalanAttr*)m_attributes.getNamedItem(name);
#else
return static_cast<XalanAttr*>(m_attributes.getNamedItem(name));
#endif
}
XalanNodeList*
XercesElementWrapper::getElementsByTagName(const XalanDOMString& /* name
*/) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
void
XercesElementWrapper::setAttribute(
const XalanDOMString& /* name */,
const XalanDOMString& /* value */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanAttr*
XercesElementWrapper::setAttributeNode(XalanAttr* /* newAttr */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanAttr*
XercesElementWrapper::removeAttributeNode(XalanAttr* /* oldAttr */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesElementWrapper::removeAttribute(const XalanDOMString& /* name
*/)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
const XalanDOMString&
XercesElementWrapper::getAttributeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return
m_navigator.getPooledString(m_xercesNode->getAttributeNS(c_wstr(namespaceURI),
c_wstr(localName)));
}
void
XercesElementWrapper::setAttributeNS(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* qualifiedName */,
const XalanDOMString& /* value */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesElementWrapper::removeAttributeNS(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* localName */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanAttr*
XercesElementWrapper::getAttributeNodeNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
DOMAttr* const theAttrNode =
m_xercesNode->getAttributeNodeNS(c_wstr(namespaceURI),
c_wstr(localName));
return m_navigator.mapNode(theAttrNode);
}
XalanAttr*
XercesElementWrapper::setAttributeNodeNS(XalanAttr* /* newAttr */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNodeList*
XercesElementWrapper::getElementsByTagNameNS(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* localName */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesElementWrapper.hpp
Index: XercesElementWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESELEMENTWRAPPER_HEADER_GUARD_1357924680)
#define XERCESELEMENTWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <map>
#include <XalanDOM/XalanElement.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <XercesParserLiaison/XercesNamedNodeMapWrapper.hpp>
#include <XercesParserLiaison/XercesNodeListWrapper.hpp>
class DOMElement;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesElementWrapper : public
XalanElement
{
public:
XercesElementWrapper(
const DOMElement*
theXercesElement,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesElementWrapper();
/**
* Gets the name of this node.
*/
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesElementWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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 const 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 const 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;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMElement*
getXercesNode() const
{
return m_xercesNode;
}
//@}
private:
// Not implemented...
XercesElementWrapper(const XercesElementWrapper& theSource);
XalanNode&
operator=(const XalanNode& theSource);
bool
operator==(const XercesElementWrapper& theRHS) const;
// Data members...
const DOMElement* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
XercesNodeListWrapper m_children;
XercesNamedNodeMapWrapper m_attributes;
};
#endif // !defined(XERCESELEMENTWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesElementWrapperAllocator.cpp
Index: XercesElementWrapperAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Class header file.
#include "XercesElementWrapperAllocator.hpp"
XercesElementWrapperAllocator::XercesElementWrapperAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XercesElementWrapperAllocator::~XercesElementWrapperAllocator()
{
}
XercesElementWrapperAllocator::ObjectType*
XercesElementWrapperAllocator::create(
const DOMElement*
theXercesElement,
const XercesWrapperNavigator& theNavigator)
{
ObjectType* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
new(theBlock) ObjectType(theXercesElement, theNavigator);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
void
XercesElementWrapperAllocator::reset()
{
m_allocator.reset();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesElementWrapperAllocator.hpp
Index: XercesElementWrapperAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESELEMENTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133)
#define XERCESELEMENTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
#include <XercesParserLiaison/XercesElementWrapper.hpp>
class DOMElement;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesElementWrapperAllocator
{
public:
typedef XercesElementWrapper
ObjectType;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<ObjectType>
ArenaBlockType;
typedef ArenaAllocator<ObjectType,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<ObjectType>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XercesElementWrapperAllocator(size_type theBlockCount);
~XercesElementWrapperAllocator();
/**
* Create a XercesElementWrapper instance.
*
* @param theXercesElement The Xerces element node
* @param theNavigator The navigator for this instance.
*
* @return pointer to the instance
*/
ObjectType*
create(
const DOMElement*
theXercesElement,
const XercesWrapperNavigator& theNavigator);
/**
* Delete all objects from allocator.
*/
void
reset();
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XercesElementWrapperAllocator(const XercesElementWrapperAllocator&);
XercesElementWrapperAllocator&
operator=(const XercesElementWrapperAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XERCESELEMENTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
1.1
xml-xalan/c/src/XercesParserLiaison/XercesEntityReferenceWrapper.cpp
Index: XercesEntityReferenceWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesEntityReferenceWrapper.hpp"
#include <xercesc/dom/DOMEntityReference.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDocumentWrapper.hpp"
#include "XercesDOMWrapperException.hpp"
XercesEntityReferenceWrapper::XercesEntityReferenceWrapper(
const DOMEntityReference*
theXercesDOMEntityReference,
const XercesWrapperNavigator& theNavigator) :
XalanEntityReference(),
m_xercesNode(theXercesDOMEntityReference),
m_navigator(theNavigator),
m_children(theXercesDOMEntityReference->getChildNodes(),
theNavigator)
{
assert(theXercesDOMEntityReference != 0);
}
XercesEntityReferenceWrapper::~XercesEntityReferenceWrapper()
{
}
const XalanDOMString&
XercesEntityReferenceWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesEntityReferenceWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesEntityReferenceWrapper::NodeType
XercesEntityReferenceWrapper::getNodeType() const
{
return ENTITY_REFERENCE_NODE;
}
XalanNode*
XercesEntityReferenceWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesEntityReferenceWrapper::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesEntityReferenceWrapper::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesEntityReferenceWrapper::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesEntityReferenceWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesEntityReferenceWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesEntityReferenceWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesEntityReferenceWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesEntityReferenceWrapper*
#endif
XercesEntityReferenceWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesEntityReferenceWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityReferenceWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityReferenceWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityReferenceWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesEntityReferenceWrapper::hasChildNodes() const
{
return m_xercesNode->hasChildNodes();
}
void
XercesEntityReferenceWrapper::setNodeValue(const XalanDOMString& /*
nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesEntityReferenceWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesEntityReferenceWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesEntityReferenceWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesEntityReferenceWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesEntityReferenceWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesEntityReferenceWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesEntityReferenceWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesEntityReferenceWrapper::getIndex() const
{
return m_navigator.getIndex();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesEntityReferenceWrapper.hpp
Index: XercesEntityReferenceWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESENTITYREFERENCEWRAPPER_HEADER_GUARD_1357924680)
#define XERCESENTITYREFERENCEWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanEntityReference.hpp>
#include <XercesParserLiaison/XercesNodeListWrapper.hpp>
class DOMEntityReference;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesEntityReferenceWrapper : public
XalanEntityReference
{
public:
XercesEntityReferenceWrapper(
const DOMEntityReference*
theXercesDOMEntityReference,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesEntityReferenceWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesEntityReferenceWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMEntityReference*
getXercesNode() const
{
return m_xercesNode;
}
//@}
private:
// Not implemented...
XercesEntityReferenceWrapper(const XercesEntityReferenceWrapper&
theSource);
XercesEntityReferenceWrapper&
operator=(const XercesEntityReferenceWrapper& theSource);
bool
operator==(const XercesEntityReferenceWrapper& theRHS) const;
// Data members...
const DOMEntityReference* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
XercesNodeListWrapper m_children;
};
#endif //
!defined(XERCESENTITYREFERENCEWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesEntityWrapper.cpp
Index: XercesEntityWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesEntityWrapper.hpp"
#include <xercesc/dom/DOMEntity.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesDOMWrapperException.hpp"
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDocumentWrapper.hpp"
XercesEntityWrapper::XercesEntityWrapper(
const DOMEntity*
theXercesDOMEntity,
const XercesWrapperNavigator& theNavigator) :
XalanEntity(),
m_xercesNode(theXercesDOMEntity),
m_navigator(theNavigator),
m_children(m_xercesNode->getChildNodes(),
theNavigator)
{
assert(theXercesDOMEntity != 0);
}
XercesEntityWrapper::~XercesEntityWrapper()
{
}
const XalanDOMString&
XercesEntityWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesEntityWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesEntityWrapper::NodeType
XercesEntityWrapper::getNodeType() const
{
return ENTITY_NODE;
}
XalanNode*
XercesEntityWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesEntityWrapper::getChildNodes() const
{
return &m_children;
}
XalanNode*
XercesEntityWrapper::getFirstChild() const
{
return m_navigator.getFirstChild(m_xercesNode);
}
XalanNode*
XercesEntityWrapper::getLastChild() const
{
return m_navigator.getLastChild(m_xercesNode);
}
XalanNode*
XercesEntityWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesEntityWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesEntityWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesEntityWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesEntityWrapper*
#endif
XercesEntityWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesEntityWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesEntityWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesEntityWrapper::hasChildNodes() const
{
return m_xercesNode->hasChildNodes();
}
void
XercesEntityWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesEntityWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesEntityWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesEntityWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesEntityWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesEntityWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesEntityWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesEntityWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesEntityWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesEntityWrapper::getPublicId() const
{
return m_navigator.getPooledString(m_xercesNode->getPublicId());
}
const XalanDOMString&
XercesEntityWrapper::getSystemId() const
{
return m_navigator.getPooledString(m_xercesNode->getSystemId());
}
const XalanDOMString&
XercesEntityWrapper::getNotationName() const
{
return m_navigator.getPooledString(m_xercesNode->getNotationName());
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesEntityWrapper.hpp
Index: XercesEntityWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESENTITYWRAPPER_HEADER_GUARD_1357924680)
#define XERCESENTITYWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanEntity.hpp>
#include <XercesParserLiaison/XercesNodeListWrapper.hpp>
class DOMEntity;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesEntityWrapper : public
XalanEntity
{
public:
XercesEntityWrapper(
const DOMEntity*
theXercesDOMEntity,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesEntityWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesEntityWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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 const XalanDOMString&
getSystemId() const;
/**
* For unparsed entities, the name of the notation for the entity.
*
* For parsed entities, this is <code>null</code>.
*/
virtual const XalanDOMString&
getNotationName() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMEntity*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesEntityWrapper(const XercesEntityWrapper& theSource);
XercesEntityWrapper&
operator=(const XercesEntityWrapper& theSource);
bool
operator==(const XercesEntityWrapper& theRHS) const;
// Data members...
const DOMEntity* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
XercesNodeListWrapper m_children;
};
#endif // !defined(XERCESENTITYWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapWrapper.cpp
Index: XercesNamedNodeMapWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesNamedNodeMapWrapper.hpp"
#include <algorithm>
#include <cassert>
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include "XercesDocumentWrapper.hpp"
#include "XercesDOMWrapperException.hpp"
XercesNamedNodeMapWrapper::XercesNamedNodeMapWrapper(
const DOMNamedNodeMap*
theXercesNamedNodeMap,
const XercesWrapperNavigator& theNavigator) :
m_xercesNamedNodeMap(theXercesNamedNodeMap),
m_navigator(theNavigator)
{
assert(m_xercesNamedNodeMap != 0);
}
XercesNamedNodeMapWrapper::~XercesNamedNodeMapWrapper()
{
}
XalanNode*
XercesNamedNodeMapWrapper::setNamedItem(XalanNode* /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNode*
XercesNamedNodeMapWrapper::item(unsigned int index) const
{
return m_navigator.mapNode(m_xercesNamedNodeMap->item(index));
}
XalanNode*
XercesNamedNodeMapWrapper::getNamedItem(const XalanDOMString& name)
const
{
return
m_navigator.mapNode(m_xercesNamedNodeMap->getNamedItem(name.c_str()));
}
unsigned int
XercesNamedNodeMapWrapper::getLength() const
{
return m_xercesNamedNodeMap->getLength();
}
XalanNode*
XercesNamedNodeMapWrapper::removeNamedItem(const XalanDOMString&
/* name */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNode*
XercesNamedNodeMapWrapper::getNamedItemNS(
const XalanDOMString& namespaceURI,
const XalanDOMString& localName) const
{
return m_navigator.mapNode(
m_xercesNamedNodeMap->getNamedItemNS(
namespaceURI.c_str(),
localName.c_str()));
}
XalanNode*
XercesNamedNodeMapWrapper::setNamedItemNS(XalanNode* /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
XalanNode*
XercesNamedNodeMapWrapper::removeNamedItemNS(
const XalanDOMString& /* namespaceURI */,
const XalanDOMString& /* localName */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNamedNodeMapWrapper.hpp
Index: XercesNamedNodeMapWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESNAMEDNODEMAPWRAPPER_HEADER_GUARD_1357924680)
#define XERCESNAMEDNODEMAPWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanNamedNodeMap.hpp>
class DOMNamedNodeMap;
class XercesWrapperNavigator;
class XercesNodeBridge;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNamedNodeMapWrapper : public
XalanNamedNodeMap
{
public:
XercesNamedNodeMapWrapper(
const DOMNamedNodeMap*
theXercesNamedNodeMap,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesNamedNodeMapWrapper();
/** @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...
XercesNamedNodeMapWrapper(const XercesNamedNodeMapWrapper&
theSource);
XercesNamedNodeMapWrapper&
operator=(const XercesNamedNodeMapWrapper& theRHS);
bool
operator==(const XercesNamedNodeMapWrapper& theRHS) const;
const DOMNamedNodeMap* const m_xercesNamedNodeMap;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESNAMEDNODEMAPWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNodeListWrapper.cpp
Index: XercesNodeListWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesNodeListWrapper.hpp"
#include <cassert>
#include <xercesc/DOM/DOMNodeList.hpp>
#include "XercesWrapperNavigator.hpp"
XercesNodeListWrapper::XercesNodeListWrapper(
const DOMNodeList*
theXercesNodeList,
const XercesWrapperNavigator& theNavigator) :
XalanNodeList(),
m_xercesNodeList(theXercesNodeList),
m_navigator(theNavigator)
{
assert(theXercesNodeList != 0);
}
XercesNodeListWrapper::~XercesNodeListWrapper()
{
}
XercesNodeListWrapper::XercesNodeListWrapper(const XercesNodeListWrapper&
theSource) :
XalanNodeList(theSource),
m_xercesNodeList(theSource.m_xercesNodeList),
m_navigator(theSource.m_navigator)
{
}
XalanNode*
XercesNodeListWrapper::item(unsigned int index) const
{
assert(m_xercesNodeList != 0);
return m_navigator.mapNode(m_xercesNodeList->item(index));
}
unsigned int
XercesNodeListWrapper::getLength() const
{
assert(m_xercesNodeList != 0);
return m_xercesNodeList->getLength();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNodeListWrapper.hpp
Index: XercesNodeListWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESNODELISTWRAPPER_HEADER_GUARD_1357924680)
#define XERCESNODELISTWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanNodeList.hpp>
class DOMNodeList;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNodeListWrapper : public
XalanNodeList
{
public:
XercesNodeListWrapper(
const DOMNodeList*
theXercesNodeList,
const XercesWrapperNavigator& theNavigator);
XercesNodeListWrapper(const XercesNodeListWrapper& theSource);
virtual
~XercesNodeListWrapper();
bool
operator==(const XercesNodeListWrapper& 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...
XercesNodeListWrapper&
operator=(const XercesNodeListWrapper& theRHS);
// Data members...
const DOMNodeList* m_xercesNodeList;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESNODELISTWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNotationWrapper.cpp
Index: XercesNotationWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesNotationWrapper.hpp"
#include <xercesc/dom/DOMNotation.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesDOMWrapperException.hpp"
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDocumentWrapper.hpp"
XercesNotationWrapper::XercesNotationWrapper(
const DOMNotation*
theXercesDOMNotation,
const XercesWrapperNavigator& theNavigator) :
XalanNotation(),
m_xercesNode(theXercesDOMNotation),
m_navigator(theNavigator)
{
assert(theXercesDOMNotation != 0);
}
XercesNotationWrapper::~XercesNotationWrapper()
{
}
const XalanDOMString&
XercesNotationWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesNotationWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesNotationWrapper::NodeType
XercesNotationWrapper::getNodeType() const
{
return NOTATION_NODE;
}
XalanNode*
XercesNotationWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesNotationWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesNotationWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesNotationWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesNotationWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesNotationWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesNotationWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesNotationWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesNotationWrapper*
#endif
XercesNotationWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesNotationWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesNotationWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesNotationWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesNotationWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesNotationWrapper::hasChildNodes() const
{
return false;
}
void
XercesNotationWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesNotationWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesNotationWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesNotationWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesNotationWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesNotationWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesNotationWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesNotationWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesNotationWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesNotationWrapper::getPublicId() const
{
return m_navigator.getPooledString(m_xercesNode->getPublicId());
}
const XalanDOMString&
XercesNotationWrapper::getSystemId() const
{
return m_navigator.getPooledString(m_xercesNode->getSystemId());
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesNotationWrapper.hpp
Index: XercesNotationWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESNOTATIONWRAPPER_HEADER_GUARD_1357924680)
#define XERCESNOTATIONWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanNotation.hpp>
class DOMNotation;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesNotationWrapper : public
XalanNotation
{
public:
XercesNotationWrapper(
const DOMNotation*
theXercesDOMNotation,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesNotationWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesNotationWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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 const XalanDOMString&
getSystemId() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMNotation*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesNotationWrapper(const XercesNotationWrapper& theSource);
XercesNotationWrapper&
operator=(const XercesNotationWrapper& theSource);
bool
operator==(const XercesNotationWrapper& theRHS) const;
// Data members...
const DOMNotation* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESNOTATIONWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesProcessingInstructionWrapper.cpp
Index: XercesProcessingInstructionWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesProcessingInstructionWrapper.hpp"
#include <xercesc/dom/DOMProcessingInstruction.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesDOMWrapperException.hpp"
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDocumentWrapper.hpp"
XercesProcessingInstructionWrapper::XercesProcessingInstructionWrapper(
const DOMProcessingInstruction*
theXercesDOMProcessingInstruction,
const XercesWrapperNavigator& theNavigator) :
XalanProcessingInstruction(),
m_xercesNode(theXercesDOMProcessingInstruction),
m_navigator(theNavigator)
{
assert(theXercesDOMProcessingInstruction != 0);
}
XercesProcessingInstructionWrapper::~XercesProcessingInstructionWrapper()
{
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesProcessingInstructionWrapper::NodeType
XercesProcessingInstructionWrapper::getNodeType() const
{
return PROCESSING_INSTRUCTION_NODE;
}
XalanNode*
XercesProcessingInstructionWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesProcessingInstructionWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesProcessingInstructionWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesProcessingInstructionWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesProcessingInstructionWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesProcessingInstructionWrapper*
#endif
XercesProcessingInstructionWrapper::cloneNode(bool /* deep */)
const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesProcessingInstructionWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesProcessingInstructionWrapper::hasChildNodes() const
{
return false;
}
void
XercesProcessingInstructionWrapper::setNodeValue(const XalanDOMString&
/* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesProcessingInstructionWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesProcessingInstructionWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesProcessingInstructionWrapper::setPrefix(const XalanDOMString& /*
prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesProcessingInstructionWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesProcessingInstructionWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getTarget() const
{
return m_navigator.getPooledString(m_xercesNode->getTarget());
}
const XalanDOMString&
XercesProcessingInstructionWrapper::getData() const
{
return m_navigator.getPooledString(m_xercesNode->getData());
}
void
XercesProcessingInstructionWrapper::setData(const XalanDOMString& /* data
*/)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesProcessingInstructionWrapper.hpp
Index: XercesProcessingInstructionWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESPROCESSINGINSTRUCTIONWRAPPER_HEADER_GUARD_1357924680)
#define XERCESPROCESSINGINSTRUCTIONWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanProcessingInstruction.hpp>
class DOMProcessingInstruction;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesProcessingInstructionWrapper :
public XalanProcessingInstruction
{
public:
XercesProcessingInstructionWrapper(
const DOMProcessingInstruction*
theXercesDOMProcessingInstruction,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesProcessingInstructionWrapper();
// These interfaces are inherited from XalanNode...
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesProcessingInstructionWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// 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 const 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 const 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);
//@}
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMProcessingInstruction*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesProcessingInstructionWrapper(const
XercesProcessingInstructionWrapper& theSource);
XercesProcessingInstructionWrapper&
operator=(const XercesProcessingInstructionWrapper& theSource);
bool
operator==(const XercesProcessingInstructionWrapper& theRHS)
const;
// Data members...
const DOMProcessingInstruction* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
};
#endif //
!defined(XERCESPROCESSINGINSTRUCTIONWRAPPER_HEADER_GUARD_1357924680)
1.1 xml-xalan/c/src/XercesParserLiaison/XercesTextWrapper.cpp
Index: XercesTextWrapper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesTextWrapper.hpp"
#include <cassert>
#include <xercesc/dom/DOMText.hpp>
#include <DOMSupport/DOMServices.hpp>
#include "XercesWrapperHelper.hpp"
#include "XercesWrapperNavigator.hpp"
#include "XercesDOMWrapperException.hpp"
#include "XercesDocumentWrapper.hpp"
XercesTextWrapper::XercesTextWrapper(
const DOMText*
theXercesText,
const XercesWrapperNavigator& theNavigator) :
XalanText(),
m_xercesNode(theXercesText),
m_navigator(theNavigator)
{
assert(m_xercesNode != 0);
}
XercesTextWrapper::~XercesTextWrapper()
{
}
const XalanDOMString&
XercesTextWrapper::getNodeName() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeName());
}
const XalanDOMString&
XercesTextWrapper::getNodeValue() const
{
return m_navigator.getPooledString(m_xercesNode->getNodeValue());
}
XercesTextWrapper::NodeType
XercesTextWrapper::getNodeType() const
{
return TEXT_NODE;
}
XalanNode*
XercesTextWrapper::getParentNode() const
{
return m_navigator.getParentNode(m_xercesNode);
}
const XalanNodeList*
XercesTextWrapper::getChildNodes() const
{
return 0;
}
XalanNode*
XercesTextWrapper::getFirstChild() const
{
return 0;
}
XalanNode*
XercesTextWrapper::getLastChild() const
{
return 0;
}
XalanNode*
XercesTextWrapper::getPreviousSibling() const
{
return m_navigator.getPreviousSibling(m_xercesNode);
}
XalanNode*
XercesTextWrapper::getNextSibling() const
{
return m_navigator.getNextSibling(m_xercesNode);
}
const XalanNamedNodeMap*
XercesTextWrapper::getAttributes() const
{
return 0;
}
XalanDocument*
XercesTextWrapper::getOwnerDocument() const
{
return m_navigator.getOwnerDocument();
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XalanNode*
#else
XercesTextWrapper*
#endif
XercesTextWrapper::cloneNode(bool /* deep */) const
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::NOT_SUPPORTED_ERR);
return 0;
}
XalanNode*
XercesTextWrapper::insertBefore(
XalanNode* /* newChild */,
XalanNode* /* refChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextWrapper::replaceChild(
XalanNode* /* newChild */,
XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextWrapper::removeChild(XalanNode* /* oldChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
XalanNode*
XercesTextWrapper::appendChild(XalanNode* /* newChild */)
{
throw
XercesDOMWrapperException(XercesDOMWrapperException::HIERARCHY_REQUEST_ERR);
return 0;
}
bool
XercesTextWrapper::hasChildNodes() const
{
return false;
}
void
XercesTextWrapper::setNodeValue(const XalanDOMString& /* nodeValue */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesTextWrapper::normalize()
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesTextWrapper::isSupported(
const XalanDOMString& feature,
const XalanDOMString& version) const
{
return XercesWrapperHelper::isSupported(m_xercesNode, feature, version);
}
const XalanDOMString&
XercesTextWrapper::getNamespaceURI() const
{
return m_navigator.getPooledString(m_xercesNode->getNamespaceURI());
}
const XalanDOMString&
XercesTextWrapper::getPrefix() const
{
return m_navigator.getPooledString(m_xercesNode->getPrefix());
}
const XalanDOMString&
XercesTextWrapper::getLocalName() const
{
return m_navigator.getPooledString(m_xercesNode->getLocalName());
}
void
XercesTextWrapper::setPrefix(const XalanDOMString& /* prefix */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
bool
XercesTextWrapper::isIndexed() const
{
return m_navigator.getOwnerDocument()->isIndexed();
}
unsigned long
XercesTextWrapper::getIndex() const
{
return m_navigator.getIndex();
}
const XalanDOMString&
XercesTextWrapper::getData() const
{
return m_navigator.getPooledString(m_xercesNode->getData());
}
unsigned int
XercesTextWrapper::getLength() const
{
return m_xercesNode->getLength();
}
XalanDOMString
XercesTextWrapper::substringData(
unsigned int offset,
unsigned int count) const
{
return XercesWrapperHelper::substringData(m_xercesNode, offset, count);
}
void
XercesTextWrapper::appendData(const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesTextWrapper::insertData(
unsigned int /* offset */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesTextWrapper::deleteData(
unsigned int /* offset */,
unsigned int /* count */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void
XercesTextWrapper::replaceData(
unsigned int /* offset */,
unsigned int /* count */,
const XalanDOMString& /* arg */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}
XalanText*
XercesTextWrapper::splitText(unsigned int /* offset */)
{
throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
return 0;
}
bool
XercesTextWrapper::isIgnorableWhitespace() const
{
return isXMLWhitespace(getData());
}
1.1 xml-xalan/c/src/XercesParserLiaison/XercesTextWrapper.hpp
Index: XercesTextWrapper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESTEXTWRAPPER_HEADER_GUARD_1357924680)
#define XERCESTEXTWRAPPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <XalanDOM/XalanText.hpp>
#include <XercesParserLiaison/XercesDOM_NodeHack.hpp>
class DOMText;
class XercesWrapperNavigator;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesTextWrapper : public XalanText
{
public:
XercesTextWrapper(
const DOMText*
theXercesText,
const XercesWrapperNavigator& theNavigator);
virtual
~XercesTextWrapper();
/**
* Gets the name of this node.
*/
virtual const XalanDOMString&
getNodeName() const;
/**
* Gets the value of this node, depending on its type.
*/
virtual const 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 XercesTextWrapper*
#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
isSupported(
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 const XalanDOMString&
getNamespaceURI() const;
/**
* Get the <em>namespace prefix</em>
* of this node, or <code>null</code> if it is unspecified.
*/
virtual const 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 const 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);
virtual bool
isIndexed() const;
virtual unsigned long
getIndex() const;
//@}
// These interfaces are inherited from XalanText...
/** @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 const 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);
//@}
virtual bool
isIgnorableWhitespace() const;
/**
* Get the Xerces node this instance represent.
*
* @return The Xerces node
*/
const DOMText*
getXercesNode() const
{
return m_xercesNode;
}
private:
// Not implemented...
XercesTextWrapper(const XercesTextWrapper& theSource);
XercesTextWrapper&
operator=(const XercesTextWrapper& theSource);
bool
operator==(const XercesTextWrapper& theRHS) const;
// Data members...
const DOMText* const m_xercesNode;
const XercesWrapperNavigator& m_navigator;
};
#endif // !defined(XERCESTEXTWRAPPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesTextWrapperAllocator.cpp
Index: XercesTextWrapperAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
// Class header file.
#include "XercesTextWrapperAllocator.hpp"
XercesTextWrapperAllocator::XercesTextWrapperAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XercesTextWrapperAllocator::~XercesTextWrapperAllocator()
{
}
XercesTextWrapperAllocator::ObjectType*
XercesTextWrapperAllocator::create(
const DOMText*
theXercesText,
const XercesWrapperNavigator& theNavigator)
{
ObjectType* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
new(theBlock) ObjectType(theXercesText, theNavigator);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
void
XercesTextWrapperAllocator::reset()
{
m_allocator.reset();
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesTextWrapperAllocator.hpp
Index: XercesTextWrapperAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESTEXTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133)
#define XERCESTEXTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <PlatformSupport/ArenaAllocator.hpp>
#include <XercesParserLiaison/XercesTextWrapper.hpp>
class XALAN_XERCESPARSERLIAISON_EXPORT XercesTextWrapperAllocator
{
public:
typedef XercesTextWrapper
ObjectType;
#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
typedef ArenaBlock<ObjectType>
ArenaBlockType;
typedef ArenaAllocator<ObjectType,
ArenaBlockType>
ArenaAllocatorType;
#else
typedef ArenaAllocator<ObjectType>
ArenaAllocatorType;
#endif
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XercesTextWrapperAllocator(size_type theBlockCount);
~XercesTextWrapperAllocator();
/**
* Create a XercesTextWrapper instance.
*
* @param theXercesText The Xerces text node
* @param theNavigator The navigator for this instance.
*
* @return pointer to the instance
*/
ObjectType*
create(
const DOMText*
theXercesText,
const XercesWrapperNavigator& theNavigator);
/**
* Delete all objects from allocator.
*/
void
reset();
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XercesTextWrapperAllocator(const XercesTextWrapperAllocator&);
XercesTextWrapperAllocator&
operator=(const XercesTextWrapperAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XERCESTEXTWRAPPERALLOCATOR_INCLUDE_GUARD_12455133
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperHelper.cpp
Index: XercesWrapperHelper.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "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 [EMAIL PROTECTED]
*
* 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 "XercesWrapperHelper.hpp"
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMCharacterData.hpp>
#include "XercesDOMWrapperException.hpp"
bool
XercesWrapperHelper::isSupported(
const DOMNode* theXercesNode,
const XalanDOMString& feature,
const XalanDOMString& version)
{
assert(theXercesNode != 0);
return theXercesNode->isSupported(
XalanDOMStringToXercesDOMString(feature),
XalanDOMStringToXercesDOMString(version));
}
const XalanDOMString
XercesWrapperHelper::substringData(
const DOMCharacterData* theXercesNode,
unsigned int offset,
unsigned int count)
{
assert(theXercesNode != 0);
try
{
const XMLCh* const theString =
theXercesNode->substringData(offset, count);
return XalanDOMString(theString,
XalanDOMString::length(theString));
}
catch(const DOMException& theException)
{
throw XercesDOMWrapperException(theException);
}
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperHelper.hpp
Index: XercesWrapperHelper.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "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 [EMAIL PROTECTED]
*
* 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(XERCESWRAPPERHELPER_HEADER_GUARD_1357924680)
#define XERCESWRAPPERHELPER_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <xercesc/util/XercesDefs.hpp>
#include <XalanDOM/XalanDOMString.hpp>
#include <XercesParserLiaison/XercesBridgeNavigator.hpp>
class DOMCharacterData;
class DOMNode;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesWrapperHelper
{
public:
typedef XMLSize_t XercesStringLengthType;
static const XMLCh*
XalanDOMStringToXercesDOMString(const XalanDOMString& theString)
{
assert(XercesStringLengthType(theString.length()) ==
theString.length());
return theString.c_str();
}
static bool
isSupported(
const DOMNode* theXercesNode,
const XalanDOMString& feature,
const XalanDOMString& version);
static const XalanDOMString
substringData(
const DOMCharacterData* theXercesNode,
unsigned int offset,
unsigned int count);
private:
// Not implemented...
XercesWrapperHelper();
XercesWrapperHelper(const XercesWrapperHelper&);
};
#endif // !defined(XERCESWRAPPERHELPER_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperNavigator.cpp
Index: XercesWrapperNavigator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesWrapperNavigator.hpp"
#include <XalanDOM/XalanNode.hpp>
#include <XalanDOM/XalanElement.hpp>
#include "XercesAttrWrapper.hpp"
#include "XercesDocumentWrapper.hpp"
#include "XercesTextWrapper.hpp"
#include "XercesDOMWrapperException.hpp"
// I'm using this to distinguish between null nodes, which are valid, and
// an uninitialized cached node address. This is probably bogus, and I'll
// probably just change this to 0, but this is experimental anyway...
#if defined(XALAN_OLD_STYLE_CASTS)
static XalanNode* const invalidNodeAddress = (XalanNode*)1;
#else
static XalanNode* const invalidNodeAddress =
reinterpret_cast<XalanNode*>(1);
#endif
XercesWrapperNavigator::XercesWrapperNavigator(
XercesDocumentWrapper* theOwnerDocument,
bool mappingMode) :
m_ownerDocument(theOwnerDocument),
m_parentNode(mappingMode == true ? invalidNodeAddress : 0),
m_previousSibling(mappingMode == true ? invalidNodeAddress : 0),
m_nextSibling(mappingMode == true ? invalidNodeAddress : 0),
m_firstChild(mappingMode == true ? invalidNodeAddress : 0),
m_lastChild(mappingMode == true ? invalidNodeAddress : 0),
m_index(UINT_MAX)
{
assert(theOwnerDocument != 0);
}
XercesWrapperNavigator::XercesWrapperNavigator(const XercesWrapperNavigator&
theSource) :
m_ownerDocument(theSource.m_ownerDocument),
m_parentNode(theSource.m_parentNode),
m_previousSibling(theSource.m_previousSibling),
m_nextSibling(theSource.m_nextSibling),
m_firstChild(theSource.m_firstChild),
m_lastChild(theSource.m_lastChild),
m_index(theSource.m_index)
{
}
XercesWrapperNavigator::~XercesWrapperNavigator()
{
}
XalanNode*
XercesWrapperNavigator::mapNode(const DOMNode* theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode);
}
XalanAttr*
XercesWrapperNavigator::mapNode(const DOMAttr* theXercesNode) const
{
return m_ownerDocument->mapNode(theXercesNode);
}
const DOMNode*
XercesWrapperNavigator::mapNode(XalanNode* theXalanNode) const
{
return m_ownerDocument->mapNode(theXalanNode);
}
const DOMAttr*
XercesWrapperNavigator::mapNode(XalanAttr* theXalanNode) const
{
return m_ownerDocument->mapNode(theXalanNode);
}
XalanNode*
XercesWrapperNavigator::getParentNode(const DOMNode* theXercesNode) const
{
if (m_parentNode == invalidNodeAddress)
{
#if defined(XALAN_NO_MUTABLE)
((XercesWrapperNavigator*)this)->m_parentNode =
m_ownerDocument->mapNode(theXercesNode->getParentNode());
#else
m_parentNode =
m_ownerDocument->mapNode(theXercesNode->getParentNode());
#endif
}
return m_parentNode;
}
XalanNode*
XercesWrapperNavigator::getPreviousSibling(const DOMNode* theXercesNode)
const
{
if (m_previousSibling == invalidNodeAddress)
{
#if defined(XALAN_NO_MUTABLE)
((XercesWrapperNavigator*)this)->m_previousSibling =
m_ownerDocument->mapNode(theXercesNode->getPreviousSibling());
#else
m_previousSibling =
m_ownerDocument->mapNode(theXercesNode->getPreviousSibling());
#endif
}
return m_previousSibling;
}
XalanNode*
XercesWrapperNavigator::getNextSibling(const DOMNode* theXercesNode) const
{
if (m_nextSibling == invalidNodeAddress)
{
#if defined(XALAN_NO_MUTABLE)
((XercesWrapperNavigator*)this)->m_nextSibling =
m_ownerDocument->mapNode(theXercesNode->getNextSibling());
#else
m_nextSibling =
m_ownerDocument->mapNode(theXercesNode->getNextSibling());
#endif
}
return m_nextSibling;
}
XalanNode*
XercesWrapperNavigator::getFirstChild(const DOMNode* theXercesNode) const
{
if (m_firstChild == invalidNodeAddress)
{
#if defined(XALAN_NO_MUTABLE)
((XercesWrapperNavigator*)this)->m_firstChild =
m_ownerDocument->mapNode(theXercesNode->getFirstChild());
#else
m_firstChild =
m_ownerDocument->mapNode(theXercesNode->getFirstChild());
#endif
}
return m_firstChild;
}
XalanNode*
XercesWrapperNavigator::getLastChild(const DOMNode* theXercesNode) const
{
if (m_lastChild == invalidNodeAddress)
{
#if defined(XALAN_NO_MUTABLE)
((XercesWrapperNavigator*)this)->m_lastChild =
m_ownerDocument->mapNode(theXercesNode->getLastChild());
#else
m_lastChild =
m_ownerDocument->mapNode(theXercesNode->getLastChild());
#endif
}
return m_lastChild;
}
XalanElement*
XercesWrapperNavigator::getOwnerElement(const DOMAttr* theXercesAttr)
const
{
assert(theXercesAttr != 0);
if (m_parentNode != invalidNodeAddress)
{
assert(m_parentNode->getNodeType() == XalanNode::ELEMENT_NODE);
#if defined(XALAN_OLD_STYLE_CASTS)
return (XalanElement*)m_parentNode;
#else
return static_cast<XalanElement*>(m_parentNode);
#endif
}
else
{
return
m_ownerDocument->mapNode(theXercesAttr->getOwnerElement());
}
}
const XalanDOMString&
XercesWrapperNavigator::getPooledString(const XMLCh* theString) const
{
return m_ownerDocument->getPooledString(theString,
XalanDOMString::length(theString));
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperNavigator.hpp
Index: XercesWrapperNavigator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESWRAPPERNAVIGATOR_HEADER_GUARD_1357924680)
#define XERCESWRAPPERNAVIGATOR_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <cassert>
#include <xercesc/util/XercesDefs.hpp>
#include <XalanDOM/XalanDOMString.hpp>
class DOMAttr;
class DOMNode;
class XercesDocumentWrapper;
class XalanAttr;
class XalanElement;
class XalanNode;
class XalanText;
class DOMText;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesWrapperNavigator
{
public:
explicit
XercesWrapperNavigator(
XercesDocumentWrapper* theOwnerDocument = 0,
bool mappingMode =
true);
XercesWrapperNavigator(const XercesWrapperNavigator& theSource);
virtual
~XercesWrapperNavigator();
XercesDocumentWrapper*
getOwnerDocument() const
{
return m_ownerDocument;
}
void
setOwnerDocument(XercesDocumentWrapper* theDocument)
{
m_ownerDocument = theDocument;
}
XalanNode*
mapNode(const DOMNode* theXercesNode) const;
XalanAttr*
mapNode(const DOMAttr* theXercesNode) const;
const DOMNode*
mapNode(XalanNode* theXalanNode) const;
const DOMAttr*
mapNode(XalanAttr* theXercesNode) const;
unsigned long
getIndex() const
{
return m_index;
}
void
setIndex(unsigned long theIndex)
{
m_index = theIndex;
}
XalanNode*
getParentNode(const DOMNode* theXercesNode) const;
XalanNode*
getParentNode() const
{
return m_parentNode;
}
void
setParentNode(XalanNode* theParent)
{
m_parentNode = theParent;
}
XalanNode*
getPreviousSibling(const DOMNode* theXercesNode) const;
XalanNode*
getPreviousSibling() const
{
return m_previousSibling;
}
void
setPreviousSibling(XalanNode* thePreviousSibling)
{
m_previousSibling = thePreviousSibling;
}
XalanNode*
getNextSibling(const DOMNode* theXercesNode) const;
XalanNode*
getNextSibling() const
{
return m_nextSibling;
}
void
setNextSibling(XalanNode* theNextSibling)
{
m_nextSibling = theNextSibling;
}
XalanNode*
getFirstChild(const DOMNode* theXercesNode) const;
XalanNode*
getFirstChild() const
{
return m_firstChild;
}
void
setFirstChild(XalanNode* theFirstChild)
{
m_firstChild = theFirstChild;
}
XalanNode*
getLastChild(const DOMNode* theXercesNode) const;
XalanNode*
getLastChild() const
{
return m_lastChild;
}
void
setLastChild(XalanNode* theLastChild)
{
m_lastChild = theLastChild;
}
XalanElement*
getOwnerElement(const DOMAttr* theXercesAttr) const;
/**
* Get a pooled string. If the string is not in the pool,
* add it.
*
* @param theString The string to pool.
* @return A const reference to the pooled string.
*/
const XalanDOMString&
getPooledString(const XMLCh* theString) const;
private:
// Not implemented...
bool
operator==(const XercesWrapperNavigator& theRHS) const;
// Data members...
XercesDocumentWrapper* m_ownerDocument;
mutable XalanNode* m_parentNode;
mutable XalanNode* m_previousSibling;
mutable XalanNode* m_nextSibling;
mutable XalanNode* m_firstChild;
mutable XalanNode* m_lastChild;
unsigned long m_index;
};
#endif // !defined(XERCESWRAPPERNAVIGATOR_HEADER_GUARD_1357924680)
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperToXalanNodeMap.cpp
Index: XercesWrapperToXalanNodeMap.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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 "XercesWrapperToXalanNodeMap.hpp"
#include <cassert>
#include <xercesc/dom/DOMDocument.hpp>
#include <XalanDOM/XalanDOMException.hpp>
#include <XalanDOM/XalanNode.hpp>
XercesWrapperToXalanNodeMap::XercesWrapperToXalanNodeMap() :
m_xalanMap(),
m_xercesMap()
{
}
XercesWrapperToXalanNodeMap::~XercesWrapperToXalanNodeMap()
{
}
void
XercesWrapperToXalanNodeMap::addAssociation(
const DOMNode* theXercesNode,
XalanNode* theXalanNode)
{
m_xercesMap.insert(XercesNodeMapType::value_type(theXercesNode,
theXalanNode));
m_xalanMap.insert(XalanNodeMapType::value_type(theXalanNode,
theXercesNode));
}
void
XercesWrapperToXalanNodeMap::clear()
{
m_xalanMap.clear();
m_xercesMap.clear();
}
XalanNode*
XercesWrapperToXalanNodeMap::getNode(const DOMNode* theXercesNode)
const
{
const XercesNodeMapType::const_iterator i =
m_xercesMap.find(theXercesNode);
if (i == m_xercesMap.end())
{
return 0;
}
else
{
return (*i).second;
}
}
const DOMNode*
XercesWrapperToXalanNodeMap::getNode(XalanNode* theXalanNode)
const
{
const XalanNodeMapType::const_iterator i =
m_xalanMap.find(theXalanNode);
if (i != m_xalanMap.end())
{
return (*i).second;
}
else
{
return 0;
}
}
1.1
xml-xalan/c/src/XercesParserLiaison/XercesWrapperToXalanNodeMap.hpp
Index: XercesWrapperToXalanNodeMap.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2002 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 [EMAIL PROTECTED]
*
* 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(XERCESWRAPPERTOXALANNODEMAP_HEADER_GUARD_1357924680)
#define XERCESWRAPPERTOXALANNODEMAP_HEADER_GUARD_1357924680
#include <XercesParserLiaison/XercesParserLiaisonDefinitions.hpp>
#include <map>
class DOMNode;
class XalanNode;
class XALAN_XERCESPARSERLIAISON_EXPORT XercesWrapperToXalanNodeMap
{
public:
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanNode*, const DOMNode*, less<XalanNode*> >
XalanNodeMapType;
typedef map<const DOMNode*, XalanNode*, less<DOMNode*> >
XercesNodeMapType;
#else
typedef std::map<XalanNode*, const DOMNode*> XalanNodeMapType;
typedef std::map<const DOMNode*, XalanNode*> XercesNodeMapType;
#endif
XercesWrapperToXalanNodeMap();
~XercesWrapperToXalanNodeMap();
void
addAssociation(
const DOMNode* theXercesNode,
XalanNode* theXalanNode);
void
clear();
XalanNode*
getNode(const DOMNode* theXercesNode) const;
const DOMNode*
getNode(XalanNode* theXalanNode) const;
private:
XalanNodeMapType m_xalanMap;
XercesNodeMapType m_xercesMap;
};
#endif // !defined(XERCESWRAPPERTOXALANNODEMAP_HEADER_GUARD_1357924680)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]