当前位置: 首页>>代码示例>>C++>>正文


C++ DOM_Node::getNextSibling方法代码示例

本文整理汇总了C++中DOM_Node::getNextSibling方法的典型用法代码示例。如果您正苦于以下问题:C++ DOM_Node::getNextSibling方法的具体用法?C++ DOM_Node::getNextSibling怎么用?C++ DOM_Node::getNextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOM_Node的用法示例。


在下文中一共展示了DOM_Node::getNextSibling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkReadOnly

void RangeImpl::checkReadOnly(DOM_Node& start, DOM_Node& end,
                              unsigned int startOffset, unsigned int endOffset)
{
    if ((start == null) || (end == null) ) return;
    //if both start and end are text check and return
    if (start.getNodeType() == DOM_Node::TEXT_NODE) {
        if (start.fImpl->isReadOnly()) {
            throw DOM_DOMException(
                DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null);
        }
        if (start == end)
            return;
    }
    //set the start and end nodes to check
    DOM_Node sNode = start.getFirstChild();
    for(unsigned int i = 0; i<startOffset; i++)
        sNode = sNode.getNextSibling();

    DOM_Node eNode;
    if (end.getNodeType() == DOM_Node::TEXT_NODE) {
        eNode = end; //need to check only till this node
    }
    else { //need to check all the kids that fall before the end offset value
        eNode = end.getFirstChild();
        for (unsigned int i = 0; i<endOffset-1; i++)
            eNode = eNode.getNextSibling();
    }
    //recursivly search if any node is readonly
    recurseTreeAndCheck(sNode, eNode);
}
开发者ID:mydw,项目名称:mydw,代码行数:30,代码来源:RangeImpl.cpp

示例2: getNode

DOM_Node XMLDocument::getNode(DOM_Node currNode, char* path, DataTypeAttribute** dtAttributes)
{
	if (path == NULL)
		return NULL_DOM_Node;

	char* currName = currNode.getNodeName().transcode();

  if (strcmp(currName, path) == 0 && (dtAttributes == NULL || doAttributesMatch(currNode, dtAttributes))) {
    delete[] currName;
		return currNode;
  }
  delete[] currName;

	char* cp = strchr(path, '.');
	char pathName[256];
	if (cp == NULL)
		strcpy(pathName, path);
	else
	{
		strncpy(pathName, path, cp - path);
		pathName[cp - path] = '\0';
	}

	DOM_Node child = currNode.getFirstChild();
	while (child != NULL)
	{
		char* childName = child.getNodeName().transcode();
		if (child.getNodeType() != DOM_Node::ELEMENT_NODE)
		{
			child = child.getNextSibling();
      delete[] childName;
			continue;
		}

		if (strcmp(pathName, childName) == 0)
		{
      if (cp != NULL) {
        delete[] childName;
				return getNode(child, cp+1, dtAttributes);
      }

			if (dtAttributes != NULL)
			{
				if (!doAttributesMatch(child, dtAttributes))
				{
					child = child.getNextSibling();
          delete[] childName;
					continue;
				}
			}

      delete[] childName;
			return child;
		}

    delete[] childName;
		child = child.getNextSibling();
	}
 	return NULL_DOM_Node;
}
开发者ID:gres147679,项目名称:openipmp,代码行数:60,代码来源:XMLDocument.cpp

示例3: traverseCommonEndContainer

/**
 * Visits the nodes selected by this range when we know
 * a-priori that the start and end containers are not the
 * same, but the end container is an ancestor of the start container
 *
 */
DOM_DocumentFragment RangeImpl::traverseCommonEndContainer( DOM_Node startAncestor, int how )
{
    DOM_DocumentFragment frag = null;
    if ( how!=DELETE_CONTENTS)
        frag = fDocument.createDocumentFragment();
    DOM_Node n = traverseLeftBoundary( startAncestor, how );
    if ( frag!=null )
        frag.appendChild( n );
    int startIdx = indexOf( startAncestor, fEndContainer );
    ++startIdx;  // Because we already traversed it....

    int cnt = fEndOffset - startIdx;
    n = startAncestor.getNextSibling();
    while( cnt > 0 )
    {
        DOM_Node sibling = n.getNextSibling();
        DOM_Node xferNode = traverseFullySelected( n, how );
        if ( frag!=null )
            frag.appendChild( xferNode );
        --cnt;
        n = sibling;
    }

    if ( how != CLONE_CONTENTS )
    {
        setStartAfter( startAncestor );
        collapse( true );
    }

    return frag;
}
开发者ID:mydw,项目名称:mydw,代码行数:37,代码来源:RangeImpl.cpp

示例4: getValue

//======================================================================
//======================================================================
char* XMLDocument::getValue(DOM_Node currNode, char* path, DataTypeAttribute** dtAttributes)
{
	if (mDoc == NULL)
		return NULL;

	if (path == NULL)
		return NULL;

	DOM_Node child = getNode(currNode, path, dtAttributes);
	if (child == NULL)
		return NULL;

	child = child.getFirstChild();
	if (child == NULL)
		return NULL;

	// If siblings exist, this is not an leaf, but a branch
	DOM_Node sib  = child.getNextSibling();
	if (sib != NULL)
		return NULL;

	if (child.getNodeType() != DOM_Node::TEXT_NODE && child.getNodeType() != DOM_Node::CDATA_SECTION_NODE)
		return NULL;

	return child.getNodeValue().transcode();
}
开发者ID:gres147679,项目名称:openipmp,代码行数:28,代码来源:XMLDocument.cpp

示例5: selectNode

void RangeImpl::selectNode(const DOM_Node& refNode)
{
    validateNode(refNode);
    if ( !isLegalContainedNode(refNode)) {
        throw DOM_RangeException(
            DOM_RangeException::INVALID_NODE_TYPE_ERR, null);
    }
    //First check for the text type node
    if (refNode.getNodeType() ==  DOM_Node::TEXT_NODE)
    {
        //The node itself is the container.
        fStartContainer = refNode;
        fEndContainer   = refNode;

        //Select all the contents of the node
        fStartOffset = 0;
        fEndOffset = ((DOM_Text &)refNode).getLength();
        return;
    }

    DOM_Node parent = refNode.getParentNode();
    if (parent != null ) // REVIST: what to do if it IS null?
    {
        fStartContainer = parent;
        fEndContainer = parent;

        unsigned int i = 0;
        for (DOM_Node n = parent.getFirstChild(); n!=null, n!=refNode; n = n.getNextSibling()) {
            i++;
        }

        fStartOffset = i;
        fEndOffset = fStartOffset+1;
    }
}
开发者ID:mydw,项目名称:mydw,代码行数:35,代码来源:RangeImpl.cpp

示例6: traverseLeftBoundary

/**
 * Traverses the "left boundary" of this range and
 * operates on each "boundary node" according to the
 * how parameter.  It is a-priori assumed
 * by this method that the left boundary does
 * not contain the range's end container.
 *
 * A "left boundary" is best visualized by thinking
 * of a sample tree:
 *
 *                 A
 *                /|\
 *               / | \
 *              /  |  \
 *             B   C   D
 *            /|\     /|\
 *           E F G   H I J
 *
 * Imagine first a range that begins between the
 * "E" and "F" nodes and ends between the
 * "I" and "J" nodes.  The start container is
 * "B" and the end container is "D".  Given this setup,
 * the following applies:
 *
 * Partially Selected Nodes: B, D<br>
 * Fully Selected Nodes: F, G, C, H, I
 *
 * The "left boundary" is the highest subtree node
 * that contains the starting container.  The root of
 * this subtree is always partially selected.
 *
 * In this example, the nodes that are traversed
 * as "left boundary" nodes are: F, G, and B.
 *
 */
DOM_Node RangeImpl::traverseLeftBoundary( DOM_Node root, int how )
{
    DOM_Node next = getSelectedNode( getStartContainer(), getStartOffset() );
    bool isFullySelected = ( next!=getStartContainer() );

    if ( next==root )
        return traverseNode( next, isFullySelected, true, how );

    DOM_Node parent = next.getParentNode();
    DOM_Node clonedParent = traverseNode( parent, false, true, how );

    while( parent!=null )
    {
        while( next!=null )
        {
            DOM_Node nextSibling = next.getNextSibling();
            DOM_Node clonedChild =
                traverseNode( next, isFullySelected, true, how );
            if ( how!=DELETE_CONTENTS )
                clonedParent.appendChild(clonedChild);
            isFullySelected = true;
            next = nextSibling;
        }
        if ( parent==root )
            return clonedParent;

        next = parent.getNextSibling();
        parent = parent.getParentNode();
        DOM_Node clonedGrandParent = traverseNode( parent, false, true, how );
        if ( how!=DELETE_CONTENTS )
            clonedGrandParent.appendChild( clonedParent );
        clonedParent = clonedGrandParent;

    }

    // should never occur
    return null;

}
开发者ID:mydw,项目名称:mydw,代码行数:74,代码来源:RangeImpl.cpp

示例7: nextNode

DOM_Node RangeImpl::nextNode(const DOM_Node& node, bool visitChildren) const
{

    if (node == null) return null;

    DOM_Node result;
    if (visitChildren) {
        result = node.getFirstChild();
        if (result != null) {
            return result;
        }
    }

    // if hasSibling, return sibling
    result = node.getNextSibling();
    if (result != null) {
        return result;
    }


    // return parent's 1st sibling.
    DOM_Node parent = node.getParentNode();


    while ( (parent != null) && (parent != fDocument) )
    {
        result = parent.getNextSibling();
        if (result != null) {
            return result;
        } else {
            parent = parent.getParentNode();
            if (parent == fEndContainer) return parent;

        }

    }
    // end of list, return null
    return null;
}
开发者ID:mydw,项目名称:mydw,代码行数:39,代码来源:RangeImpl.cpp

示例8: traverseCommonAncestors

/**
 * Visits the nodes selected by this range when we know
 * a-priori that the start and end containers are not
 * the same, and we also know that neither the start
 * nor end container is an ancestor of the other.
 */
DOM_DocumentFragment RangeImpl::traverseCommonAncestors( DOM_Node startAncestor, DOM_Node endAncestor, int how )
{
    DOM_DocumentFragment frag = null;
    if ( how!=DELETE_CONTENTS)
        frag = fDocument.createDocumentFragment();

    DOM_Node n = traverseLeftBoundary( startAncestor, how );
    if ( frag!=null )
        frag.appendChild( n );

    DOM_Node commonParent = startAncestor.getParentNode();
    int startOffset = indexOf( startAncestor, commonParent );
    int endOffset = indexOf( endAncestor, commonParent );
    ++startOffset;

    int cnt = endOffset - startOffset;
    DOM_Node sibling = startAncestor.getNextSibling();

    while( cnt > 0 )
    {
        DOM_Node nextSibling = sibling.getNextSibling();
        n = traverseFullySelected( sibling, how );
        if ( frag!=null )
            frag.appendChild( n );
        sibling = nextSibling;
        --cnt;
    }

    n = traverseRightBoundary( endAncestor, how );
    if ( frag!=null )
        frag.appendChild( n );

    if ( how != CLONE_CONTENTS )
    {
        setStartAfter( startAncestor );
        collapse( true );
    }
    return frag;
}
开发者ID:mydw,项目名称:mydw,代码行数:45,代码来源:RangeImpl.cpp

示例9: traverseContents

/** This is the master routine invoked to visit the nodes
*   selected by this range.  For each such node, different
*   actions are taken depending on the value of the TraversalType argument.
*/
DOM_DocumentFragment RangeImpl::traverseContents(TraversalType how)
{
    if (fDetached)
        throw DOM_DOMException(DOM_DOMException::INVALID_STATE_ERR, null);

    if (fStartContainer == null || fEndContainer == null) {
        return DOM_DocumentFragment(); // REVIST: Throw exception?
    }

    /* Traversal is accomplished by first determining the
       relationship between the endpoints of the range.
       For each of four significant relationships, we will
       delegate the traversal call to a method that
       can make appropriate assumptions.
    */

    // case 1: same container
    if ( fStartContainer == fEndContainer )
        return traverseSameContainer( how );

    // case 2: Child C of start container is ancestor of end container
    for (DOM_Node node = fStartContainer.getFirstChild(); node != null; node=node.getNextSibling()) {
        if (isAncestorOf(node, fEndContainer))
            return traverseCommonStartContainer( node, how );
    }

    // case 3: Child C of end container  is ancestor of start container
    for (DOM_Node nd = fEndContainer.getFirstChild(); nd != null; nd=nd.getNextSibling()) {
        if (isAncestorOf(nd, fStartContainer))
            return traverseCommonEndContainer( nd, how );
    }

    // case 4: preorder traversal of context tree.
    // There is a common ancestor container.  Find the
    // ancestor siblings that are children of that container.
    DOM_Node ancestor = commonAncestorOf(fStartContainer, fEndContainer);
    return traverseCommonAncestors( ancestor, ancestor, how );
}
开发者ID:mydw,项目名称:mydw,代码行数:42,代码来源:RangeImpl.cpp

示例10: traverseSameContainer

/**
 * Visits the nodes selected by this range when we know
 * a-priori that the start and end containers are the same.
 *
 */
DOM_DocumentFragment RangeImpl::traverseSameContainer( int how )
{
    DOM_DocumentFragment frag = null;
    if ( how!=DELETE_CONTENTS)
        frag = fDocument.createDocumentFragment();

    // If selection is empty, just return the fragment
    if ( fStartOffset==fEndOffset )
        return frag;

    DOM_Node current = fStartContainer;
    DOM_Node cloneCurrent = null;

    // Text node needs special case handling
    if ( fStartContainer.getNodeType()== DOM_Node::TEXT_NODE )
    {
        cloneCurrent = fStartContainer.cloneNode(false);
        cloneCurrent.setNodeValue(
            cloneCurrent.getNodeValue().substringData(fStartOffset, fEndOffset - fStartOffset));

        // set the original text node to its new value
        if ( how != CLONE_CONTENTS )
            ((DOM_Text &)fStartContainer).deleteData(fStartOffset, fEndOffset-fStartOffset);
        if ( how != DELETE_CONTENTS)
            frag.appendChild(cloneCurrent);
    }
    else {
        // Copy nodes between the start/end offsets.
        DOM_Node n = getSelectedNode( fStartContainer, fStartOffset );
        int cnt = fEndOffset - fStartOffset;
        while( cnt > 0 )
        {
            DOM_Node sibling = n.getNextSibling();
            DOM_Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.appendChild( xferNode );
            --cnt;
            n = sibling;
        }
    }

    // Nothing is partially selected, so collapse to start point
    if ( how != CLONE_CONTENTS )
        collapse(true);
    return frag;
}
开发者ID:mydw,项目名称:mydw,代码行数:51,代码来源:RangeImpl.cpp

示例11: getSelectedNode

/**
 * Utility method to retrieve a child node by index.  This method
 * assumes the caller is trying to find out which node is
 * selected by the given index.  Note that if the index is
 * greater than the number of children, this implies that the
 * first node selected is the parent node itself.
 *
 */
DOM_Node RangeImpl::getSelectedNode( DOM_Node container, int offset )
{
    if ( container.getNodeType() == DOM_Node::TEXT_NODE )
        return container;

    // This case is an important convenience for
    // traverseRightBoundary()
    if ( offset<0 )
        return container;

    DOM_Node child = container.getFirstChild();
    while( child!=null && offset > 0 )
    {
        --offset;
        child = child.getNextSibling();
    }
    if ( child!=null )
        return child;
    return container;
}
开发者ID:mydw,项目名称:mydw,代码行数:28,代码来源:RangeImpl.cpp

示例12: clone

DOM_Node XMLDocument::clone(DOM_Node currNode)
{
	switch (currNode.getNodeType())
	{
		case DOM_Node::ELEMENT_NODE:
		{
			DOM_Element elem = mDoc.createElement(currNode.getNodeName());
			DOM_NamedNodeMap nnodeMap = currNode.getAttributes();
			for (unsigned int i = 0; i < nnodeMap.getLength(); i++)
			{
				DOM_Node attNode = nnodeMap.item(i);
				elem.setAttribute(attNode.getNodeName(), attNode.getNodeValue());
			}
			DOM_Node child = currNode.getFirstChild();
			while (child != NULL)
			{
				DOM_Node cNode = clone(child);
				if (cNode != NULL)
					elem.appendChild(cNode);
				child = child.getNextSibling();
			}
			return (DOM_Node)elem;
		}
		case DOM_Node::TEXT_NODE:
		{
			DOM_Text childText = mDoc.createTextNode(currNode.getNodeValue());
			return (DOM_Node)childText;
		}
		case DOM_Node::CDATA_SECTION_NODE:
		{
			DOM_CDATASection childCData = mDoc.createCDATASection(currNode.getNodeValue());
			return (DOM_Node)childCData;
		}
		default:
		{
			return NULL_DOM_Node;
		}
	}
}
开发者ID:gres147679,项目名称:openipmp,代码行数:39,代码来源:XMLDocument.cpp

示例13: getNextSibling

DOM_Node TreeWalkerImpl::getNextSibling (DOM_Node node) {
	
	DOM_Node result;

    if (node.isNull() || node == fRoot) return result;

    DOM_Node newNode = node.getNextSibling();
    if (newNode.isNull()) {

        newNode = node.getParentNode();

        if (newNode.isNull() || node == fRoot)  return result;

        short parentAccept = acceptNode(newNode);

        if (parentAccept == DOM_NodeFilter::FILTER_SKIP) {
            return getNextSibling(newNode);
        }

        return result;
    }

    short accept = acceptNode(newNode);

    if (accept == DOM_NodeFilter::FILTER_ACCEPT)
        return newNode;
    else
    if (accept == DOM_NodeFilter::FILTER_SKIP) {
        DOM_Node fChild =  getFirstChild(newNode);
        if (fChild.isNull()) {
            return getNextSibling(newNode);
        }
        return fChild;
    }
    return getNextSibling(newNode);

}
开发者ID:ksmyth,项目名称:xerces-c,代码行数:37,代码来源:TreeWalkerImpl.cpp

示例14: selectNodeContents

void RangeImpl::selectNodeContents(const DOM_Node& node)
{
    validateNode(node);

    fStartContainer = node;
    fEndContainer = node;

    fStartOffset = 0;
    if (node.getNodeType() == DOM_Node::TEXT_NODE ) {
        fEndOffset = ((DOM_Text &)node).getLength();
        return;
    }

    DOM_Node first = node.getFirstChild();
    if (first == null) {
        fEndOffset = 0;
        return;
    }
    unsigned int i = 0;
    for (DOM_Node n = first; n!=null; n = n.getNextSibling()) {
        i++;
    }
    fEndOffset = i;
}
开发者ID:mydw,项目名称:mydw,代码行数:24,代码来源:RangeImpl.cpp

示例15: strdup


//.........这里部分代码省略.........
			{
				CORBA::Boolean v;
				if( val == "true" )
				{
					v = true;
				}
				else
				{
					v = false;
				}
				any <<= CORBA::Any::from_boolean( v );
			}

			if( type == "char" )
			{
				CORBA::Char v = val[0];
				any <<= CORBA::Any::from_char( v );
			}

			if( type == "double" )
			{
				CORBA::Double v = atof( val.c_str() );
				any <<= v;
			}

			if( type == "float" )
			{
				CORBA::Float v = atof( val.c_str() );
				any <<= v;
			}

			if( type == "short" )
			{
				CORBA::Short v = atoi( val.c_str() );
				any <<= v;
			}

			if( type == "long" )
			{
				CORBA::Long v = atol( val.c_str() );
				any <<= v;
			}

			if( type == "objref" )
			{
				// TODO
			}

			if( type == "octet" )
			{
				CORBA::Octet v = val[0];
				any <<= CORBA::Any::from_octet( v );
			}

			if( type == "string" )
			{
				any <<= val.c_str();
			}

			if( type == "ulong" )
			{
				CORBA::ULong v = atol( val.c_str() );
				any <<= v;
			}

			if( type == "ushort" )
			{
				CORBA::UShort v = atol( val.c_str() );
				any <<= v;
			}

			// new config entry
			config->length( ++len );
			( *config )[len - 1] = new ConfigValue_impl( CORBA::string_dup( name.c_str() ), any );
		}

		// sequence
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "sequence" ) ) )
		{
		}

		// struct
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "struct" ) ) )
		{
		}

		// value
		if( ( child.getNodeType() == DOM_Node::ELEMENT_NODE ) &&
			( child.getNodeName().equals( "valuetype" ) ) )
		{
		}

		// next element
		child = child.getNextSibling();
	}

	return config;
}
开发者ID:BackupTheBerlios,项目名称:qedo-svn,代码行数:101,代码来源:Properties.cpp


注:本文中的DOM_Node::getNextSibling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。