コード例 #1
0
ファイル: Element.cpp プロジェクト: 119/vdc
void Element::setAttribute(const XMLString& name, const XMLString& value)
{
	Attr* pAttr = getAttributeNode(name);
	if (pAttr)
	{
		pAttr->setValue(value);
	}
	else
	{
		pAttr = ownerDocument()->createAttribute(name);
		pAttr->setValue(value);
		setAttributeNode(pAttr);
		pAttr->release();
	}
}
コード例 #2
0
ファイル: Element.cpp プロジェクト: 119/vdc
void Element::setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value)
{
	Attr* pAttr = getAttributeNodeNS(namespaceURI, qualifiedName);
	if (pAttr)
	{
		pAttr->setValue(value);
	}
	else
	{
		pAttr = _pOwner->createAttributeNS(namespaceURI, qualifiedName);
		pAttr->setValue(value);
		setAttributeNodeNS(pAttr);
		pAttr->release();
	}
}
コード例 #3
0
   /*
    * 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);
      }

   }
コード例 #4
0
ファイル: Attr.cpp プロジェクト: CaptEmulation/svgl
Node *
Attr::cloneNode(bool deep) const
{
  Attr * attr = new Attr(*this);
  if (deep) {
    attr->setValue(getValue());
  }
  return attr;
}
コード例 #5
0
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList genderList;
      Node gender;
      NodeList genList;
      Node gen;
      NodeList gList;
      Node g;
      NamedNodeMap attrList;
      Attr attrNode;
      doc = (Document) baseT::load("staff", true);
      genderList = doc.getElementsByTagName(SA::construct_from_utf8("gender"));
      gender = genderList.item(2);
      baseT::assertNotNull(gender, __LINE__, __FILE__);
      genList = gender.getChildNodes();
      gen = genList.item(0);
      baseT::assertNotNull(gen, __LINE__, __FILE__);
      gList = gen.getChildNodes();
      g = gList.item(0);
      baseT::template skipIfNot<EntityReference>(g);
     baseT::assertNotNull(g, __LINE__, __FILE__);
      attrList = g.getAttributes();
      baseT::assertNotNull(attrList, __LINE__, __FILE__);
      attrNode = (Attr) attrList.getNamedItem(SA::construct_from_utf8("domestic"));
      baseT::assertNotNull(attrNode, __LINE__, __FILE__);
      
      {
         boolean success = false;
         try {
            attrNode.setValue(SA::construct_from_utf8("newvalue"));
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR);
         }
         assertTrue(success);
      }

      {
         boolean success = false;
         try {
            attrNode.setNodeValue(SA::construct_from_utf8("newvalue2"));
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR);
         }
         assertTrue(success);
      }

   }
コード例 #6
0
void JSAttr::setValue(ExecState* exec, JSValue value)
{
    Attr* imp = static_cast<Attr*>(impl());
    String attrValue = valueToStringWithNullCheck(exec, value);

    Element* ownerElement = imp->ownerElement();
    if (ownerElement && (ownerElement->hasTagName(iframeTag) || ownerElement->hasTagName(frameTag))) {
        if (equalIgnoringCase(imp->name(), "src") && protocolIsJavaScript(deprecatedParseURL(attrValue))) {
            if (!checkNodeSecurity(exec, static_cast<HTMLFrameElementBase*>(ownerElement)->contentDocument()))
                return;
        }
    }

    ExceptionCode ec = 0;
    imp->setValue(attrValue, ec);
    setDOMException(exec, ec);
}