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


C++ NamedNodeMap类代码示例

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


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

示例1: getAttributeItem

void NamedNodeMap::setAttributes(const NamedNodeMap& other)
{
    // clone all attributes in the other map, but attach to our element
    if (!m_element)
        return;

    // If assigning the map changes the id attribute, we need to call
    // updateId.
    Attribute* oldId = getAttributeItem(m_element->idAttributeName());
    Attribute* newId = other.getAttributeItem(m_element->idAttributeName());

    if (oldId || newId)
        m_element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom);

    clearAttributes();
    unsigned newLength = other.length();
    m_attributes.resize(newLength);
    for (unsigned i = 0; i < newLength; i++)
        m_attributes[i] = other.m_attributes[i]->clone();

    // FIXME: This is wasteful.  The class list could be preserved on a copy, and we
    // wouldn't have to waste time reparsing the attribute.
    // The derived class, HTMLNamedNodeMap, which manages a parsed class list for the CLASS attribute,
    // will update its member variable when parse attribute is called.
    for (unsigned i = 0; i < newLength; i++)
        m_element->attributeChanged(m_attributes[i].get(), true);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:27,代码来源:NamedAttrMap.cpp

示例2: runTest

   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList elementList;
      Element firstNode;
      Node testNode;
      NamedNodeMap attributes;
      Attr domesticAttr;
      Attr setAttr;
      Node setNode;
      doc = (Document) baseT::load("staff", true);
      elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
      firstNode = (Element) elementList.item(0);
      domesticAttr = doc.createAttribute(SA::construct_from_utf8("domestic"));
      domesticAttr.setValue(SA::construct_from_utf8("Yes"));
      setAttr = firstNode.setAttributeNode(domesticAttr);
      elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
      testNode = elementList.item(2);
      attributes = testNode.getAttributes();
      
      {
         boolean success = false;
         try {
            setNode = attributes.setNamedItem(domesticAttr);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::INUSE_ATTRIBUTE_ERR);
         }
         assertTrue(success);
      }

   }
开发者ID:QuentinFiard,项目名称:arabica,代码行数:34,代码来源:namednodemapinuseattributeerr.hpp

示例3: arg

Value FunLang::evaluate() const
{
    String lang = arg(0)->evaluate().toString();

    Attribute* languageAttribute = 0;
    Node* node = evaluationContext().node.get();
    while (node) {
        NamedNodeMap* attrs = node->attributes();
        if (attrs)
            languageAttribute = attrs->getAttributeItem(XMLNames::langAttr);
        if (languageAttribute)
            break;
        node = node->parentNode();
    }

    if (!languageAttribute)
        return BOOL_TO_VALUE_CAST false;

    String langValue = languageAttribute->value();
    while (true) {
        if (equalIgnoringCase(langValue, lang))
            return BOOL_TO_VALUE_CAST true;

        // Remove suffixes one by one.
        size_t index = langValue.reverseFind('-');
        if (index == notFound)
            break;
        langValue = langValue.left(index);
    }

    return BOOL_TO_VALUE_CAST false;
}
开发者ID:13W,项目名称:phantomjs,代码行数:32,代码来源:XPathFunctions.cpp

示例4:

Node*
Element::_getElementById (const DOMString& id)
{
    for (size_t i = 0; i < _children.length(); i++) {
        NamedNodeMap attrs = _children.item(i)->attributes();

        for (size_t h = 0; h < attrs.length(); h++) {
            Attr* attr = (Attr*) attrs.item(h);

            if (attr->_isId) {
                if (attr->value() == id) {
                    return _children.item(i);
                }
            }
        }
    }

    for (size_t i = 0; i < _children.length(); i++) {
        Node* element = _children.item(i)->_getElementById(id);

        if (element) {
            return element;
        }
    }

    return NULL;
}
开发者ID:meh,项目名称:xmlpp,代码行数:27,代码来源:Element.cpp

示例5: runTest

   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc1;
      Document doc2;
      NodeList elementList;
      Node testAddress;
      NamedNodeMap attributes;
      Node newAttribute;
      String strong;
      Node setNode;
      doc1 = (Document) baseT::load("hc_staff", true);
      doc2 = (Document) baseT::load("hc_staff", true);
      elementList = doc1.getElementsByTagName(SA::construct_from_utf8("acronym"));
      testAddress = elementList.item(2);
      newAttribute = doc2.createAttribute(SA::construct_from_utf8("newAttribute"));
      attributes = testAddress.getAttributes();
      
      {
         boolean success = false;
         try {
            setNode = attributes.setNamedItem(newAttribute);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
         }
         assertTrue(success);
      }

   }
开发者ID:QuentinFiard,项目名称:arabica,代码行数:31,代码来源:hc_namednodemapwrongdocumenterr.hpp

示例6: imageToMarkup

static String imageToMarkup(const String& url, Element* element)
{
    StringBuilder markup;
    markup.append("<img src=\"");
    markup.append(url);
    markup.append("\"");
    // Copy over attributes.  If we are dragging an image, we expect things like
    // the id to be copied as well.
    NamedNodeMap* attrs = element->attributes();
    unsigned length = attrs->length();
    for (unsigned i = 0; i < length; ++i) {
        Attribute* attr = attrs->attributeItem(i);
        if (attr->localName() == "src")
            continue;
        markup.append(" ");
        markup.append(attr->localName());
        markup.append("=\"");
        String escapedAttr = attr->value();
        escapedAttr.replace("\"", "&quot;");
        markup.append(escapedAttr);
        markup.append("\"");
    }

    markup.append("/>");
    return markup.toString();
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:26,代码来源:ClipboardChromium.cpp

示例7: runTest

   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList acronymList;
      Node testNode;
      NamedNodeMap attributes;
      Attr titleAttr;
      String value;
      Node textNode;
      Node retval;
      Node lastChild;
      Document otherDoc;
      doc = (Document) baseT::load("hc_staff", true);
      otherDoc = (Document) baseT::load("hc_staff", true);
      acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym"));
      testNode = acronymList.item(3);
      attributes = testNode.getAttributes();
      titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title"));
      textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday"));
      
      {
         boolean success = false;
         try {
            retval = titleAttr.appendChild(textNode);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR);
         }
         assertTrue(success);
      }

   }
开发者ID:QuentinFiard,项目名称:arabica,代码行数:34,代码来源:hc_attrappendchild5.hpp

示例8: jsNamedNodeMapLength

JSValue jsNamedNodeMapLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl());
    JSValue result = jsNumber(imp->length());
    return result;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:8,代码来源:JSNamedNodeMap.cpp

示例9: appendOpenTag

void MarkupAccumulator::appendElement(StringBuilder& out, Element* element, Namespaces* namespaces)
{
    appendOpenTag(out, element, namespaces);

    NamedNodeMap* attributes = element->attributes();
    unsigned length = attributes->length();
    for (unsigned int i = 0; i < length; i++)
        appendAttribute(out, element, *attributes->attributeItem(i), namespaces);

    appendCloseTag(out, element);
}
开发者ID:KaoTD,项目名称:Nokia-RM-1013-2.0.0.11,代码行数:11,代码来源:MarkupAccumulator.cpp

示例10: parametersForPlugin

void HTMLEmbedElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues)
{
    NamedNodeMap* attributes = this->attributes(true);
    if (!attributes)
        return;

    for (unsigned i = 0; i < attributes->length(); ++i) {
        Attribute* it = attributes->attributeItem(i);
        paramNames.append(it->localName().string());
        paramValues.append(it->value().string());
    }
}
开发者ID:ramgar,项目名称:lenovo_b6000-8000_kernel_source,代码行数:12,代码来源:HTMLEmbedElement.cpp

示例11: getNames

void DatasetDOMStringMap::getNames(Vector<String>& names)
{
    NamedNodeMap* attributeMap = m_element->attributes(true);
    if (attributeMap) {
        unsigned length = attributeMap->length();
        for (unsigned i = 0; i < length; i++) {
            Attribute* attribute = attributeMap->attributeItem(i);
            if (isValidAttributeName(attribute->localName()))
                names.append(convertAttributeNameToPropertyName(attribute->localName()));
        }
    }
}
开发者ID:ricardo-quesada,项目名称:Webkit-Projects,代码行数:12,代码来源:DatasetDOMStringMap.cpp

示例12: mergeAttributesFromTokenIntoElement

void HTMLConstructionSite::mergeAttributesFromTokenIntoElement(AtomicHTMLToken& token, Element* element)
{
    if (!token.attributes())
        return;

    NamedNodeMap* attributes = element->attributes(false);
    for (unsigned i = 0; i < token.attributes()->length(); ++i) {
        Attribute* attribute = token.attributes()->attributeItem(i);
        if (!attributes->getAttributeItem(attribute->name()))
            element->setAttribute(attribute->name(), attribute->value());
    }
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:12,代码来源:HTMLConstructionSite.cpp

示例13: write

void XmlWriter::write(const NodePtr nodeArg)
{
    NodePtr node = nodeArg;

    indent+=2;

    NamedNodeMap attributes = node->getAttributes();
    int nrAttrs = attributes.getLength();

    //### Start open tag
    spaces();
    po("<");
    pos(node->getNodeName());
    if (nrAttrs>0)
        po("\n");

    //### Attributes
    for (int i=0 ; i<nrAttrs ; i++)
        {
        NodePtr attr = attributes.item(i);
        spaces();
        pos(attr->getNodeName());
        po("=\"");
        pos(attr->getNodeValue());
        po("\"\n");
        }

    //### Finish open tag
    if (nrAttrs>0)
        spaces();
    po(">\n");

    //### Contents
    spaces();
    pos(node->getNodeValue());

    //### Children
    for (NodePtr child = node->getFirstChild() ;
         child.get() ;
         child=child->getNextSibling())
        {
        write(child);
        }

    //### Close tag
    spaces();
    po("</");
    pos(node->getNodeName());
    po(">\n");

    indent-=2;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:52,代码来源:xmlwriter.cpp

示例14: contains

bool DatasetDOMStringMap::contains(const String& name)
{
    NamedNodeMap* attributeMap = m_element->attributes(true);
    if (attributeMap) {
        unsigned length = attributeMap->length();
        for (unsigned i = 0; i < length; i++) {
            Attribute* attribute = attributeMap->attributeItem(i);
            if (propertyNameMatchesAttributeName(name, attribute->localName()))
                return true;
        }
    }
    return false;
}
开发者ID:ricardo-quesada,项目名称:Webkit-Projects,代码行数:13,代码来源:DatasetDOMStringMap.cpp

示例15: highestVisuallyEquivalentDivBelowRoot

// When inserting a new line, we want to avoid nesting empty divs if we can.  Otherwise, when
// pasting, it's easy to have each new line be a div deeper than the previous.  E.g., in the case
// below, we want to insert at ^ instead of |.
// <div>foo<div>bar</div>|</div>^
static Element* highestVisuallyEquivalentDivBelowRoot(Element* startBlock)
{
    Element* curBlock = startBlock;
    // We don't want to return a root node (if it happens to be a div, e.g., in a document fragment) because there are no
    // siblings for us to append to.
    while (!curBlock->nextSibling() && curBlock->parentElement()->hasTagName(divTag) && curBlock->parentElement()->parentElement()) {
        NamedNodeMap* attributes = curBlock->parentElement()->attributes(true);
        if (attributes && !attributes->isEmpty())
            break;
        curBlock = curBlock->parentElement();
    }
    return curBlock;
}
开发者ID:ohyeah521,项目名称:GT-I9300_Platform,代码行数:17,代码来源:InsertParagraphSeparatorCommand.cpp


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