mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-27 09:39:08 +01:00
XML: complete merge from 1.4.2
This commit is contained in:
@@ -61,20 +61,31 @@ public:
|
||||
Node* insertBefore(Node* newChild, Node* refChild);
|
||||
Node* replaceChild(Node* newChild, Node* oldChild);
|
||||
Node* removeChild(Node* oldChild);
|
||||
Node* appendChild(Node* newChild);
|
||||
bool hasChildNodes() const;
|
||||
bool hasAttributes() const;
|
||||
Node* appendChild(Node* newChild);
|
||||
bool hasChildNodes() const;
|
||||
bool hasAttributes() const;
|
||||
Node* getNodeByPath(const XMLString& path) const;
|
||||
Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const;
|
||||
|
||||
protected:
|
||||
AbstractContainerNode(Document* pOwnerDocument);
|
||||
AbstractContainerNode(Document* pOwnerDocument);
|
||||
AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node);
|
||||
~AbstractContainerNode();
|
||||
|
||||
void dispatchNodeRemovedFromDocument();
|
||||
void dispatchNodeInsertedIntoDocument();
|
||||
void dispatchNodeRemovedFromDocument();
|
||||
void dispatchNodeInsertedIntoDocument();
|
||||
|
||||
static const Node* findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap);
|
||||
static const Node* findElement(const XMLString& name, const Node* pNode, const NSMap* pNSMap);
|
||||
static const Node* findElement(int index, const Node* pNode, const NSMap* pNSMap);
|
||||
static const Node* findElement(const XMLString& attr, const XMLString& value, const Node* pNode, const NSMap* pNSMap);
|
||||
static const Attr* findAttribute(const XMLString& name, const Node* pNode, const NSMap* pNSMap);
|
||||
bool hasAttributeValue(const XMLString& name, const XMLString& value, const NSMap* pNSMap) const;
|
||||
static bool namesAreEqual(const Node* pNode1, const Node* pNode2, const NSMap* pNSMap);
|
||||
static bool namesAreEqual(const Node* pNode, const XMLString& name, const NSMap* pNSMap);
|
||||
|
||||
private:
|
||||
AbstractNode* _pFirstChild;
|
||||
AbstractNode* _pFirstChild;
|
||||
|
||||
friend class AbstractNode;
|
||||
friend class NodeAppender;
|
||||
|
||||
@@ -91,10 +91,12 @@ public:
|
||||
void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture);
|
||||
bool dispatchEvent(Event* evt);
|
||||
|
||||
// Extensions
|
||||
XMLString innerText() const;
|
||||
// Extensions
|
||||
XMLString innerText() const;
|
||||
Node* getNodeByPath(const XMLString& path) const;
|
||||
Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const;
|
||||
|
||||
virtual void autoRelease();
|
||||
virtual void autoRelease();
|
||||
|
||||
protected:
|
||||
AbstractNode(Document* pOwnerDocument);
|
||||
|
||||
@@ -111,15 +111,15 @@ public:
|
||||
EntityResolver* getEntityResolver() const;
|
||||
/// Returns the entity resolver used by the underlying SAXParser.
|
||||
|
||||
void setEntityResolver(EntityResolver* pEntityResolver);
|
||||
/// Sets the entity resolver on the underlying SAXParser.
|
||||
void setEntityResolver(EntityResolver* pEntityResolver);
|
||||
/// Sets the entity resolver on the underlying SAXParser.
|
||||
|
||||
static const XMLString FEATURE_WHITESPACE;
|
||||
|
||||
static const XMLString FEATURE_FILTER_WHITESPACE;
|
||||
|
||||
private:
|
||||
SAXParser _saxParser;
|
||||
NamePool* _pNamePool;
|
||||
bool _whitespace;
|
||||
SAXParser _saxParser;
|
||||
NamePool* _pNamePool;
|
||||
bool _filterWhitespace;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -86,11 +86,22 @@ public:
|
||||
/// of supported values.
|
||||
|
||||
const std::string& getNewLine() const;
|
||||
/// Returns the line ending characters used by the
|
||||
/// internal XMLWriter.
|
||||
/// Returns the line ending characters used by the
|
||||
/// internal XMLWriter.
|
||||
|
||||
void writeNode(XMLByteOutputStream& ostr, const Node* pNode);
|
||||
/// Writes the XML for the given node to the specified stream.
|
||||
void setIndent(const std::string& indent);
|
||||
/// Sets the string used for one indentation step.
|
||||
///
|
||||
/// The default is a single TAB character.
|
||||
/// The given string should only contain TAB or SPACE
|
||||
/// characters (e.g., a single TAB character, or
|
||||
/// two to four SPACE characters).
|
||||
|
||||
const std::string& getIndent() const;
|
||||
/// Returns the string used for one indentation step.
|
||||
|
||||
void writeNode(XMLByteOutputStream& ostr, const Node* pNode);
|
||||
/// Writes the XML for the given node to the specified stream.
|
||||
|
||||
void writeNode(const std::string& systemId, const Node* pNode);
|
||||
/// Writes the XML for the given node to the file specified in systemId,
|
||||
@@ -98,9 +109,10 @@ public:
|
||||
|
||||
private:
|
||||
std::string _encodingName;
|
||||
Poco::TextEncoding* _pTextEncoding;
|
||||
int _options;
|
||||
std::string _newLine;
|
||||
Poco::TextEncoding* _pTextEncoding;
|
||||
int _options;
|
||||
std::string _newLine;
|
||||
std::string _indent;
|
||||
};
|
||||
|
||||
|
||||
@@ -125,6 +137,12 @@ inline const std::string& DOMWriter::getNewLine() const
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& DOMWriter::getIndent() const
|
||||
{
|
||||
return _indent;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/DOM/AbstractContainerNode.h"
|
||||
#include "Poco/DOM/DocumentEvent.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/NamePool.h"
|
||||
#include "Poco/AutoReleasePool.h"
|
||||
|
||||
@@ -66,11 +66,12 @@ protected:
|
||||
Node* find(const Node* pParent, unsigned long index) const;
|
||||
|
||||
const Node* _pParent;
|
||||
XMLString _name;
|
||||
mutable unsigned long _count;
|
||||
|
||||
friend class Element;
|
||||
friend class Document;
|
||||
XMLString _name;
|
||||
mutable unsigned long _count;
|
||||
|
||||
friend class AbstractContainerNode;
|
||||
friend class Element;
|
||||
friend class Document;
|
||||
};
|
||||
|
||||
|
||||
@@ -92,11 +93,12 @@ protected:
|
||||
|
||||
const Node* _pParent;
|
||||
XMLString _localName;
|
||||
XMLString _namespaceURI;
|
||||
mutable unsigned long _count;
|
||||
|
||||
friend class Element;
|
||||
friend class Document;
|
||||
XMLString _namespaceURI;
|
||||
mutable unsigned long _count;
|
||||
|
||||
friend class AbstractContainerNode;
|
||||
friend class Element;
|
||||
friend class Document;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/DOM/EventTarget.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/SAX/NamespaceSupport.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -226,17 +227,68 @@ public:
|
||||
/// Returns the local name of the node.
|
||||
|
||||
virtual bool hasAttributes() const = 0;
|
||||
/// Returns whether this node (if it is an element) has any attributes.
|
||||
|
||||
// Extensions
|
||||
virtual XMLString innerText() const = 0;
|
||||
/// Returns a string containing the concatenated values of the node
|
||||
/// and all its child nodes.
|
||||
///
|
||||
/// This method is not part of the W3C Document Object Model.
|
||||
/// Returns whether this node (if it is an element) has any attributes.
|
||||
|
||||
// Extensions
|
||||
typedef Poco::XML::NamespaceSupport NSMap;
|
||||
|
||||
virtual XMLString innerText() const = 0;
|
||||
/// Returns a string containing the concatenated values of the node
|
||||
/// and all its child nodes.
|
||||
///
|
||||
/// This method is not part of the W3C Document Object Model.
|
||||
|
||||
virtual Node* getNodeByPath(const XMLString& path) const = 0;
|
||||
/// Searches a node (element or attribute) based on a simplified XPath
|
||||
/// expression.
|
||||
///
|
||||
/// Only simple XPath expressions are supported. These are the slash
|
||||
/// notation for specifying paths to elements, and the square bracket
|
||||
/// expression for finding elements by their index, by attribute value,
|
||||
/// or finding attributes by names.
|
||||
///
|
||||
/// The slash at the beginning is optional, the evaluation always starts
|
||||
/// at this element. A double-slash at the beginning recursively searches
|
||||
/// the entire subtree for the first element.
|
||||
///
|
||||
/// Examples:
|
||||
/// elem1/elem2/elem3
|
||||
/// /elem1/elem2/elem3
|
||||
/// /elem1/elem2[1]
|
||||
/// /elem1/elem2[@attr1]
|
||||
/// /elem1/elem2[@attr1='value']
|
||||
/// //elem2[@attr1='value']
|
||||
/// //[@attr1='value']
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
virtual Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const = 0;
|
||||
/// Searches a node (element or attribute) based on a simplified XPath
|
||||
/// expression. The given NSMap must contain mappings from namespace
|
||||
/// prefixes to namespace URIs for all namespace prefixes used in
|
||||
/// the path expression.
|
||||
///
|
||||
/// Only simple XPath expressions are supported. These are the slash
|
||||
/// notation for specifying paths to elements, and the square bracket
|
||||
/// expression for finding elements by their index, by attribute value,
|
||||
/// or finding attributes by names.
|
||||
///
|
||||
/// The slash at the beginning is optional, the evaluation always starts
|
||||
/// at this element. A double-slash at the beginning recursively searches
|
||||
/// the entire subtree for the first element.
|
||||
///
|
||||
/// Examples:
|
||||
/// /ns1:elem1/ns2:elem2/ns2:elem3
|
||||
/// /ns1:elem1/ns2:elem2[1]
|
||||
/// /ns1:elem1/ns2:elem2[@attr1]
|
||||
/// /ns1:elem1/ns2:elem2[@attr1='value']
|
||||
/// //ns2:elem2[@ns1:attr1='value']
|
||||
/// //[@ns1:attr1='value']
|
||||
///
|
||||
/// This method is an extension to the W3C Document Object Model.
|
||||
|
||||
protected:
|
||||
virtual ~Node();
|
||||
virtual ~Node();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -77,13 +77,13 @@ class XML_API TreeWalker
|
||||
{
|
||||
public:
|
||||
TreeWalker(Node* root, unsigned long whatToShow, NodeFilter* pFilter = 0);
|
||||
/// Creates a TreeWalker over the subtree rooted at the specified node.
|
||||
|
||||
TreeWalker(const TreeWalker& walker);
|
||||
/// Creates a TreeWalker by copying another NodeIterator.
|
||||
|
||||
TreeWalker& operator = (const TreeWalker& walker);
|
||||
/// Assignment operator.
|
||||
/// Creates a TreeWalker over the subtree rooted at the specified node.
|
||||
|
||||
TreeWalker(const TreeWalker& walker);
|
||||
/// Creates a TreeWalker by copying another TreeWalker.
|
||||
|
||||
TreeWalker& operator = (const TreeWalker& walker);
|
||||
/// Assignment operator.
|
||||
|
||||
~TreeWalker();
|
||||
/// Destroys the TreeWalker.
|
||||
|
||||
Reference in New Issue
Block a user