Exemple #1
0
void DOMtoXMLElement(DOMNode* dom, XMLElement& xml)
{
  xml.setName(StrX(dom->getNodeName()));
  unsigned int i;
  string text;
  DOMNodeList* children = dom->getChildNodes();
  for (i=0;children && i<children->getLength();i++) {
    DOMNode* child = children->item(i);
    switch (child->getNodeType()) {
    case DOMNode::TEXT_NODE:
      text+=StrX(child->getNodeValue());
      break;
    case DOMNode::ELEMENT_NODE:
      {
	XMLElement childElement;
	DOMtoXMLElement(child, childElement);
	xml.addChild(childElement);
      }
      break;
    default:
      continue;
    }
  }
  xml.setText(text);
  DOMNamedNodeMap* attrs = dom->getAttributes();
  if (attrs == 0)
    return;
  for (i=0;i<attrs->getLength();i++) {
    DOMNode* attr = attrs->item(i);
    xml.setAttribute(StrX(attr->getNodeName()), StrX(attr->getNodeValue()));
  }
}
std::string getAttributeByName (DOMNode* node, std::string attrName) {
	cdebug << "getAttr " << attrName << std::endl;
	assert (node->getNodeType () == DOMNode::ELEMENT_NODE);
	
	std::string value = "";
	
	if (node->hasAttributes()) {
		DOMNamedNodeMap *pAttributes = node->getAttributes ();
		
		for (unsigned int i = 0; i < pAttributes->getLength (); i++) {
			DOMAttr* pAttributeNode = (DOMAttr*) pAttributes->item(i);
			char* name = XMLString::transcode(pAttributeNode->getName());
			if (name == attrName) {
				char* tmpValue = XMLString::transcode(pAttributeNode->getValue());
				value = tmpValue;
				XMLString::release(&tmpValue);
			}
			XMLString::release(&name);
		}
	} else {
		cdebug << "Error in file to parse" << std::endl;
		throw ("Error in file to parse attributes");
	}
	cdebug << value << std::endl;
	return value;
} /* std::string getAttributeByName (DOMNode* node, std::string attrName) */
Exemple #3
0
// ----------------------------------------------------------------------------
//	Base Attributes Builder
// ----------------------------------------------------------------------------
void AttributesBuilder::getAttributes()
{
	if ( node_->hasAttributes() ) {
		DOMNamedNodeMap* theAttributes = node_->getAttributes();
		int numAttributes = theAttributes->getLength();
	
		for (int n=0; n < numAttributes; ++n) {
			DOMNode* attrib = theAttributes->item(n);

			const XMLCh* xmlch_Name = attrib->getNodeName();
			char* attrName = XMLString::transcode(xmlch_Name);

			const XMLCh* xmlch_Value = attrib->getNodeValue();
			char* attrValue = XMLString::transcode(xmlch_Value);
		
			try {
				//attrib_->update(pname.get(), pval.get());
				attrib_->update(attrName, attrValue);
			} catch (std::runtime_error &ex) {
				std::cerr << ex.what() << std::endl
						<< builderType_ << __FUNCTION__ << "(): "
						<< "In space \"" << attrib_->getValAsStr("name")
						<< "\", unrecognized attribute \"" << attrName << "=" << attrValue
						<< "\". Ignoring it." << std::endl;
			};

			XMLString::release( &attrName );
			XMLString::release( &attrValue );
		}
		
	}
}
void XercesUpdateFactory::setTypes(DOMNode *node, const DOMNode *from)
{
  if(node->getNodeType() == DOMNode::ELEMENT_NODE) {
    const XMLCh *turi, *tname;
    XercesNodeImpl::typeUriAndName(from, turi, tname);
    XercesSequenceBuilder::setElementTypeInfo((DOMElement *)node, turi, tname);

    DOMNamedNodeMap *attrs = node->getAttributes();
    DOMNamedNodeMap *attrsfrom = from->getAttributes();
    for(unsigned int i = 0; i < attrs->getLength(); ++i) {
      DOMNode *a = attrs->item(i);
      DOMNode *afrom = attrsfrom->getNamedItemNS(a->getNamespaceURI(), Axis::getLocalName(a));
      if(afrom) setTypes(a, afrom);
    }

    DOMNode *child = node->getFirstChild();
    DOMNode *cfrom = from->getFirstChild();
    while(child) {
      if(child->getNodeType() == DOMNode::ELEMENT_NODE)
        setTypes(child, cfrom);
      child = child->getNextSibling();
      cfrom = cfrom->getNextSibling();
    }
  }
  else if(node->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
    const XMLCh *turi, *tname;
    XercesNodeImpl::typeUriAndName(from, turi, tname);
    XercesSequenceBuilder::setAttributeTypeInfo((DOMAttr *)node, turi, tname);
  }
}
//=============================================================================
// METHOD: SPELLxmlConfigReaderXC::convertToNode
//=============================================================================
SPELLxmlNode* SPELLxmlConfigReaderXC::convertToNode( DOMElement* element )
{
    // Create an abstract node with this name
    SPELLxmlNode* node = new SPELLxmlNode( XMLString::transcode(element->getNodeName()) );

    // Get any possible attributes
    DOMNamedNodeMap* attrs = element->getAttributes();
    XMLSize_t numAttrs = attrs->getLength();
    for( XMLSize_t idx = 0; idx < numAttrs; idx++)
    {
        // Get the attribute node
        DOMNode* attrNode = attrs->item(idx);
        // Get name and value
        const XMLCh* aname  = attrNode->getNodeName();
        const XMLCh* avalue = attrNode->getNodeValue();
        // Convert name and value to strings
        std::string name = "<?>";
        if (aname != NULL)
        {
            name = XMLString::transcode(aname);
        }
        std::string value = "<?>";
        if (avalue != NULL)
        {
            value = XMLString::transcode(avalue);
        }
        node->addAttribute( name, value );
    }

    // Get any possible children
    DOMNodeList* children = element->getChildNodes();
    XMLSize_t numChildren = children->getLength();
    for( XMLSize_t idx = 0; idx < numChildren; idx++)
    {
        // Get the children node
        DOMNode* childNode = children->item(idx);
        // Process only ELEMENTs and TEXTs
        if (childNode->getNodeType() && // true is not NULL
                childNode->getNodeType() == DOMNode::ELEMENT_NODE) // is element
        {
            // For elements, recursively add children
            SPELLxmlNode* child = convertToNode( dynamic_cast<xercesc::DOMElement*>(childNode) );
            node->addChild(child);
        }
        else if (childNode->getNodeType() == DOMNode::TEXT_NODE)
        {
            // For text values, add the value. This code will just ignore
            // carriage-return values
            const XMLCh* nvalue = childNode->getNodeValue();
            if (nvalue != NULL)
            {
                std::string thevalue = XMLString::transcode(nvalue);
                SPELLutils::trim(thevalue, " \n\r\t");
                node->setValue( thevalue );
            }
        }
    }

    return node;
}
Exemple #6
0
void AcsAlarmTestCase::verifyUserTimestampElement(DOMDocument * doc)
{
	// Verify the user-timestamp element
	DOMNodeList * userTimestampNodes = doc->getElementsByTagName(USER_TIMESTAMP_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no user-properties element found",
		(NULL != userTimestampNodes && userTimestampNodes->getLength() == 1));

	// verify that there are 2 attributes
	DOMNamedNodeMap * attributesMap = userTimestampNodes->item(0)->getAttributes();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element does not contain 2 attributes",
		(NULL!= attributesMap && attributesMap->getLength() == 2));

	// check for seconds attribute
	DOMNode * secondsValueNode = attributesMap->getNamedItem(SECONDS_TAG_NAME);
	const XMLCh * secondsValue = secondsValueNode->getNodeValue();
	char *secondsCharValue = XMLString::transcode(secondsValue);
	int secondsIntValue = atoi(secondsCharValue);
	XMLString::release(&secondsCharValue);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element, 'seconds' attribute value is not correct",
		(NULL!= secondsValue && secondsIntValue == SECONDS_VALUE));

	// check for microseconds attribute
	DOMNode * microsecondsValueNode = attributesMap->getNamedItem(MICROSECONDS_TAG_NAME);
	const XMLCh * microsecondsValue = microsecondsValueNode->getNodeValue();
	char *microsecondsCharValue = XMLString::transcode(microsecondsValue);
	int microsecondsIntValue = atoi(microsecondsCharValue);
	XMLString::release(&microsecondsCharValue);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element, 'microseconds' attribute value is not correct",
		(NULL!= microsecondsValue && microsecondsIntValue == MICROSECONDS_VALUE));

}
bool
XMLExtServiceHelper::parseExtServicesReq( DOMNode* cur, DOMNode* out,
                                          DOMDocument* reply, 
                                          bool indent,
                                          const HttpHeader& inHeaders )
{
   // Attributes
   DOMNamedNodeMap* attributes = cur->getAttributes();

   // Language of the request.
   LangTypes::language_t lang = LangTypes::english;
   // Semi-optional crc
   MC2String crc;
   
   for( int i = 0, n = attributes->getLength(); i < n; ++i ) {
      DOMNode* attrib = attributes->item( i );
      if ( XMLString::equals( attrib->getNodeName(), "language" ) ) {
         lang = m_xmlParserThread->getStringAsLanguage( 
            XMLUtility::getChildTextStr( *attrib ).c_str() );
      } else if ( XMLString::equals( attrib->getNodeName(), "crc" ) ) {
         crc = XMLUtility::getChildTextStr( *attrib );
      }
   }

   // Make the answer.
   appendExternalSearchDesc( out,
                             reply,
                             cur,
                             crc,
                             lang,
                             1,
                             indent );

   return true;
}
EppCommandInfoLaunchRegistration* EppCommandInfoLaunchRegistration::fromXML( const DOMNode& root )
{
	EppCommandInfoLaunchRegistration* cmd  = new EppCommandInfoLaunchRegistration();
	if( cmd == null )
	{
		return null;
	}
	DOMNodeList* list      = root.getChildNodes();
	DOMNamedNodeMap* attrs = root.getAttributes();

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node  = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") )
		{
			name = name.substringData(7, name.length() - 7);
		}
		if( name.equals("phase") )
		{
			EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node);
			if( null != _pptr )
			{
				cmd->_phase = *_pptr;
				delete _pptr;
			}
			_pptr = null;
		}
		else if ( name.equals("applicationID") )
		{
			cmd->_appId = EppUtil::getText(*node);
		}
	}
	for( unsigned int i = 0;i<attrs->getLength();i++ )
	{
		DOMNode* attr = attrs->item(i);
		if( XS(attr->getNodeName()).equals("includeMark") )
		{
			DOMString _v = attr->getNodeValue();
			if( _v.length() > 0 )
			{
				if( _v.equals("true") )
				{
					cmd->includeMark(true);
				}
			}
			break;
		}
	}
	return cmd;
}
Exemple #9
0
void AcsAlarmTestCase::verifyFaultStateElement(DOMDocument * doc, bool propertiesAndTimestampPopulated)
{
	// Verify that the fault-state element exists
	DOMNodeList * faultStateNodes = doc->getElementsByTagName(FAULT_STATE_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no fault-state element found",
		(NULL != faultStateNodes && faultStateNodes->getLength() == 1));

	// verify that there are the expected attributes (family, member, code) on the fault-state element
	DOMNode * faultStateItem = faultStateNodes->item(0);
	if(NULL != faultStateItem)
	{
		// verify that there are 3 attributes in total
		DOMNamedNodeMap * attributesMap = faultStateItem->getAttributes();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 3 attributes",
			(NULL!= attributesMap && attributesMap->getLength() == 3));

		// check that the fault-state element has a "family" attribute
		DOMNode * familyNode = attributesMap->getNamedItem(FAMILY_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'family' attribute",
			(NULL!= familyNode));

		// verify that the value of family attribute is correct
		const XMLCh * familyNodeValue = familyNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'family' is not correct",
			(NULL != familyNodeValue && XMLString::equals(familyNodeValue, FAMILY_VALUE_XMLCH)));

		// check that the fault-state element has a "member" attribute
		DOMNode * memberNode = attributesMap->getNamedItem(MEMBER_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'member' attribute",
			(NULL!= memberNode));

		// verify that the value of member attribute is correct
		const XMLCh * memberNodeValue = memberNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'member' is not correct",
			(NULL != memberNodeValue && XMLString::equals(memberNodeValue, MEMBER_VALUE_XMLCH)));

		// check that the fault-state element has a "code" attribute
		DOMNode * codeNode = attributesMap->getNamedItem(CODE_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'code' attribute",
			(NULL!= codeNode));

		// verify that the value of code attribute is correct
		const XMLCh * codeNodeValue = codeNode->getNodeValue();
		char *codeNodeCharValue = XMLString::transcode(codeNodeValue);
		int codeNodeValueInt = atoi(codeNodeCharValue);
		XMLString::release(&codeNodeCharValue);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'code' is not correct",
			(NULL != codeNodeValue && codeNodeValueInt == CODE_VALUE));
	}

	verifyDescriptorElement(doc);
	if(propertiesAndTimestampPopulated)
	{
		verifyUserPropertiesElement(doc);
		verifyUserTimestampElement(doc);
	}
}
Exemple #10
0
void *PointSet::read(DOMNode *node) {
	unsigned int i; 				// variable to counter
	DOMNodeList *children;			// variable to hold the node children
	
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes

	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "DEF")) {
			setLink(XMLString::transcode(attributes->item(i)->getNodeValue()),this);
		}// else
		//if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
		//	return(getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		//} 
	}

	children = node->getChildNodes();
	if (children != NULL) {
		for (i = 0; i < children->getLength (); i++) {			
			if (!strcmp (XMLString::transcode(children->item(i)->getNodeName()),"Coordinate")) {
				coordinate = Coordinate::get(children->item(i));
				coordinateNumber = coordinate->getNumberOfElements();
			} else
			if (!strcmp (XMLString::transcode(children->item(i)->getNodeName()),"Color")) {
				color = Color::get(children->item(i));
				colorNumber = color->getNumberOfElements();
			} 
		}
	}
	
	#ifdef DEBUG
		float sizes[2];
		float step;
		glGetFloatv(GL_POINT_SIZE_RANGE,sizes);
		glGetFloatv(GL_POINT_SIZE_GRANULARITY,&step);
		cout << "Max and Min point size " << sizes[0] << " , " << sizes[1] << " Granularity " << step << endl;
	#endif
	
	if(colorNumber) {
		if(colorNumber==3) {
			cout << "Three colors selected" << endl;
		} else
		if(colorNumber!=coordinateNumber) {
			cerr << "Color and coordinate not matching" << endl;
		}
	}

		
	#ifdef DEBUG
		cout << "Coordinate Number " << coordinateNumber << endl;
		cout << "Color Number " << colorNumber << endl;
	#endif

	return(NULL);
	
}
//
// domCheckSum  -  Compute the check sum for a DOM node.
//                 Works recursively - initially called with a document node.
//
void ThreadParser::domCheckSum(const DOMNode *node)
{
    const XMLCh        *s;
    DOMNode          *child;
    DOMNamedNodeMap  *attributes;

    switch (node->getNodeType() )
    {
    case DOMNode::ELEMENT_NODE:
        {
            s = node->getNodeName();   // the element name

            attributes = node->getAttributes();  // Element's attributes
            int numAttributes = attributes->getLength();
            int i;
            for (i=0; i<numAttributes; i++)
                domCheckSum(attributes->item(i));

            addToCheckSum(s);          // Content and Children
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);

            break;
        }

    case DOMNode::ATTRIBUTE_NODE:
        {
            s = node->getNodeName();  // The attribute name
            addToCheckSum(s);
            s = node->getNodeValue();  // The attribute value
            if (s != 0)
                addToCheckSum(s);
            break;
        }

    case DOMNode::TEXT_NODE:
    case DOMNode::CDATA_SECTION_NODE:
        {
            s = node->getNodeValue();
            addToCheckSum(s);
            break;
        }

    case DOMNode::ENTITY_REFERENCE_NODE:
    case DOMNode::DOCUMENT_NODE:
        {
            // For entity references and the document, nothing is dirctly
            //  added to the checksum, but we do want to process the chidren nodes.
            //
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);
            break;
        }
    }
}
bool XmlParser::nodesMatch(DOMElement *mergeEl, DOMElement *patchEl) {

   DualString mergeTagName(mergeEl->getTagName());
   DualString patchTagName(patchEl->getTagName());
   if (verbose) {
      cerr << "Comparing Tag \'" << mergeTagName.asCString() << "\' to \'" << patchTagName.asCString();
   }
   if (!XMLString::equals(mergeTagName.asXMLString(), patchTagName.asXMLString())) {
      if (verbose) {
         cerr << "\' - false\n";
      }
      return false;
   }
   if (verbose) {
      cerr << "\' - equal\n";
   }
   DOMNamedNodeMap *patchAttributes = patchEl->getAttributes();

   unsigned attributeCount = patchAttributes->getLength();
   for (unsigned attrIndex = 0; attrIndex < attributeCount; attrIndex++) {
      DOMNode *attribute = patchAttributes->item(attrIndex);
      DualString attributeName(attribute->getNodeName());
      if (XMLString::equals(attributeName.asXMLString(), attr_merge_actions.asXMLString())) {
         if (verbose) {
            cerr << "Skipping attribute \'" << attributeName.asCString() << "\'\n";
         }
         continue;
      }
      if (verbose) {
         cerr << "Checking for attribute \'" << attributeName.asCString();
      }
      if (!mergeEl->hasAttribute(attributeName.asXMLString())) {
         if (verbose) {
            cerr << "\' - Not present\n";
         }
         return false;
      }
      if (verbose) {
         cerr << "\' - Present";
      }
      DualString patchAttributeValue(attribute->getNodeValue());
      DualString mergeAttributeValue(mergeEl->getAttribute(attributeName.asXMLString()));
      if (!XMLString::equals(patchAttributeValue.asXMLString(), mergeAttributeValue.asXMLString())) {
         if (verbose) {
            cerr << "\' - Not equal\n";
         }
         return false;
      }
      if (verbose) {
         cerr << "\' - Equal (" << patchAttributeValue.asCString() << ")\n";
      }
   }
   return true;
}
Exemple #13
0
bool DataSource::parserDataSource(XSchema* pschema,xercesc::DOMElement* element)
{
	this->parentschema=pschema;

	if(element)
	{
		    DOMNamedNodeMap *attributes;
			DOMNodeList *children =element->getChildNodes();
			DOMNode *tmpnode;
			std::string tmpstr=XMLString::transcode(element->getNodeName());
			if(tmpstr!="DataSource")
			{
				return false;
			}

			attributes=element->getAttributes();

			if(attributes)
			{
				for(int j=0;j<attributes->getLength();j++)
				{
					tmpnode=attributes->item(j);
					tmpstr=XMLString::transcode(tmpnode->getNodeName());
					if(tmpstr == "type")
					{
						this->type_ = (DataSource::CUBETYPE) atoi(XMLString::transcode(tmpnode->getNodeValue()));
						
					}
					else if(tmpstr=="url")
					{
						this->_URL=XMLString::transcode(tmpnode->getNodeValue());
					}
					else if(tmpstr=="passWord")
					{
						this->_psword=XMLString::transcode(tmpnode->getNodeValue());
					}
					else if(tmpstr=="userName")
					{
						this->_UserName =XMLString::transcode(tmpnode->getNodeValue());
					}
				}			
			}
			else
			{
				return false;
			}			 
	}
	else
	{
		
		return false;
	}
	return true;
}
Exemple #14
0
void AcsAlarmTestCase::verifyUserTimestampElement(DOMDocument * doc)
{
	// Verify the user-timestamp element
	DOMNodeList * userTimestampNodes = doc->getElementsByTagName(USER_TIMESTAMP_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no user-properties element found",
		(NULL != userTimestampNodes && userTimestampNodes->getLength() == 1));

	// verify that there are 2 attributes
	DOMNamedNodeMap * attributesMap = userTimestampNodes->item(0)->getAttributes();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp contain attributes",
		(NULL!= attributesMap && attributesMap->getLength() == 0));
}
Exemple #15
0
const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, bool useDefault, DOMElement *el) const {
    DOMNode *thisNode = castToNode(this);

    const XMLCh* ns = thisNode->getNamespaceURI();
    // REVISIT: if no prefix is available is it null or empty string, or
    //          could be both?
    const XMLCh* prefix = thisNode->getPrefix();

    if (ns != 0 && XMLString::equals(ns,namespaceURI)) {
        if (useDefault || prefix != 0) {
            const XMLCh* foundNamespace =  el->lookupNamespaceURI(prefix);
            if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                return prefix;
            }
        }
    }
    if (thisNode->hasAttributes()) {
        DOMNamedNodeMap *nodeMap = thisNode->getAttributes();

        if(nodeMap != 0) {
            int length = nodeMap->getLength();

            for (int i = 0;i < length;i++) {
                DOMNode *attr = nodeMap->item(i);
                const XMLCh* attrPrefix = attr->getPrefix();
                const XMLCh* value = attr->getNodeValue();

                ns = attr->getNamespaceURI();

                if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                    // DOM Level 2 nodes
                    if ((useDefault && XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) ||
                        (attrPrefix != 0 && XMLString::equals(attrPrefix, XMLUni::fgXMLNSString)) &&
                        XMLString::equals(value, namespaceURI)) {
                        const XMLCh* localname= attr->getLocalName();
                        const XMLCh* foundNamespace = el->lookupNamespaceURI(localname);
                        if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                            return localname;
                        }
                    }
                }
            }
        }
    }
    DOMNode *ancestor = getElementAncestor(thisNode);
    if (ancestor != 0) {
        return castToNodeImpl(ancestor)->lookupNamespacePrefix(namespaceURI, useDefault, el);
    }
    return 0;
}
Exemple #16
0
Inline *Inline::get(DOMNode *node) {
unsigned int i; 				// variable to counter
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes
	
	char DEF2[256];					// temporary variable to hold the DEF name
	strcpy(DEF2,"");					// reseting the variable
	
	Inline *inline2 = NULL;					// temporary variable
	
	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "DEF")) {
			strcpy(DEF2,XMLString::transcode (attributes->item(i)->getNodeValue()));
			break;
		} else 
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
			
			inline2 = (Inline *)getLink(XMLString::transcode(attributes->item(i)->getNodeValue()));
			
			if( inline2->ami("Inline") ) {
				cout << "USE of a different DEF type" << endl;
			}
			
			return(inline2);
			
		} 
	}
		
	
	// verificar se o USE ta retornando NULL
	
	inline2 = new Inline();
	if(inline2==NULL) { 
		cerr << "Error on getting Group" << endl;
	}
	
	if(strcmp(DEF2,"")) {
		#ifdef DEBUG3
			cout << "DEF : " << DEF2 << endl;
		#endif
		strcpy(inline2->DEF,DEF2);
		setLink(inline2->DEF,inline2);			
	}
	
	inline2->read(node);
	
	return inline2;

}
Exemple #17
0
XMLNode *JobXML::deepCopyElement( XMLNode **copy, const XMLNode *original )
{
   // add the element to the copy
   char *nodeName = XMLString::transcode( original->getNodeName() );
   XMLNode *newElement = AddElement( (*copy), nodeName );
   XMLString::release( &nodeName );

   // add its attributes
   if ( original->hasAttributes() )
   {
      DOMNamedNodeMap *attributes = original->getAttributes();
      for( unsigned int i=0; i<attributes->getLength(); i++ )
      {
         DOMAttr *attr = (DOMAttr*)attributes->item( i );
         char *key = XMLString::transcode( attr->getName() );
         char *val = XMLString::transcode( attr->getValue() );
         SetAttribute( newElement, key, val );
         XMLString::release( &key );
         XMLString::release( &val );
      }
   }

   // recursively copy all child elements
   int childElementCount=0;
   XMLNode *itr = original->getFirstChild();
   for ( ; itr != NULL; itr = itr->getNextSibling() )
   {      
      if ( itr->getNodeType() == XMLNode::ELEMENT_NODE )
      {
         deepCopyElement( &newElement, itr );
         childElementCount++;
      }
   }

   // if no child elements, copy this element's text content and we are done
   if ( childElementCount == 0 )
   {
      char *content = XMLString::transcode( original->getTextContent() );
      SetContent( newElement, content );
      XMLString::release( &content );
   }

   return newElement;
}
Exemple #18
0
Anchor *Anchor::get(DOMNode *node) {
	
	unsigned int i; 				// variable to counter
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes
	
	Anchor *anchor;
	
	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
			return((Anchor *)getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		} 
	}
	
	anchor = new Anchor();
	anchor->read(node);
	
	return anchor;
}
Exemple #19
0
// ---------------------------------------------------------------------------
//
//  Recursively Count up the total number of child Elements under the specified Node.
//  Process attributes of the node, if any.
//
// ---------------------------------------------------------------------------
static int countChildElements(DOMNode *n, bool printOutEncounteredEles)
{
    DOMNode *child;
    int count = 0;
    if (n) {
        if (n->getNodeType() == DOMNode::ELEMENT_NODE)
        {
            if(printOutEncounteredEles) {
                char *name = XMLString::transcode(n->getNodeName());
                cout <<"----------------------------------------------------------"<<endl;
                cout <<"Encountered Element : "<< name << endl;

                XMLString::release(&name);

                if(n->hasAttributes()) {
                    // get all the attributes of the node
                    DOMNamedNodeMap *pAttributes = n->getAttributes();
                    int nSize = pAttributes->getLength();
                    cout <<"\tAttributes" << endl;
                    cout <<"\t----------" << endl;
                    for(int i=0; i<nSize; ++i) {
                        DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
                        // get attribute name
                        char *name = XMLString::transcode(pAttributeNode->getName());

                        cout << "\t" << name << "=";
                        XMLString::release(&name);

                        // get attribute type
                        name = XMLString::transcode(pAttributeNode->getValue());
                        cout << name << endl;
                        XMLString::release(&name);
                    }
                }
            }
            ++count;
        }
        for (child = n->getFirstChild(); child != 0; child=child->getNextSibling())
            count += countChildElements(child, printOutEncounteredEles);
    }
    return count;
}
Exemple #20
0
PointSet *PointSet::get(DOMNode *node) {
	
	unsigned int i; 				// variable to counter
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes
	
	PointSet *pointSet;
	
	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
			return((PointSet *)getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		} 
	}
	
	pointSet = new PointSet();
	pointSet->read(node);
		
	return pointSet;
	
}
Exemple #21
0
NurbsCurve *NurbsCurve::get(DOMNode *node) {
	
	NurbsCurve *nurbsCurve;
	
	unsigned int i; 				// variable to counter
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes
	
	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
			return((NurbsCurve *)getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		} 
	}
	
	nurbsCurve = new NurbsCurve();
	nurbsCurve->read(node);
	
	
	return nurbsCurve;
	
}
Exemple #22
0
// ---------------------------------------------------------------------------
// utility func to extract a DOMNodes Base attr value if present
// ---------------------------------------------------------------------------
static const XMLCh *
getBaseAttrValue(DOMNode *node){
    if (node->getNodeType() == DOMNode::ELEMENT_NODE){
        DOMElement *elem = (DOMElement *)node;
        if(elem->hasAttributes()) {
            /* get all the attributes of the node */
            DOMNamedNodeMap *pAttributes = elem->getAttributes();
            XMLSize_t nSize = pAttributes->getLength();
            for(XMLSize_t i=0;i<nSize;++i) {
                DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
                /* get attribute name */
                if (XMLString::equals(pAttributeNode->getName(), XIncludeUtils::fgXIBaseAttrName)){
                    /*if (namespace == XMLUni::fgXMLString){

                    }*/
                    return pAttributeNode->getValue();
                }
            }
        }
    }
    return NULL;
}
Exemple #23
0
void SYSTEM::CConfigItem::RemoveAllAttributes()
{
	if(((DOMElement*)itemElement)->hasAttributes())
	{
		DOMNamedNodeMap *pAttributes = ((DOMElement*)itemElement)->getAttributes();
		XMLSize_t count = pAttributes->getLength();
		DOMAttr* pNode = NULL;
		for (XMLSize_t i = 0 ; i < count ; ++i)
		{
			pNode = (DOMAttr*)pAttributes->item(0);

			if( m_curValue != NULL )
				XMLString::release(&m_curValue);
			if(!pNode)		//属性名称不存在
				m_curValue = NULL;
			else
				m_curValue = XMLString::transcode(pNode->getName());/*DOMAttr **/

			((DOMElement*)itemElement)->removeAttribute(pNode->getName());
		}
	}
}
Exemple #24
0
void DWXML::printElement(xercesc::DOMElement *element)
{
	int k;
	DOMNamedNodeMap *attributes;
    DOMNodeList *children =element->getChildNodes();
	DOMNode *tmpnode;
	std::cout<<"< "<<XMLString::transcode(element->getNodeName());
	attributes=element->getAttributes();
	int r= children->getLength();
	if(attributes)
	{
		for(int j=0;j<attributes->getLength();j++)
		{
			tmpnode=attributes->item(j);
			std::cout<<" "<<XMLString::transcode(tmpnode->getNodeName());
			std::cout<<"=";
			std::cout<<" "<<XMLString::transcode(tmpnode->getNodeValue());
		}
	}
	std::cout<<" >";
	if(element->hasChildNodes())
	{
		std::cout<<std::endl;
		std::cout<<"children.length:"<<r<<std::endl;
		for( k=0;k<children->getLength();k++)
		{
			std::cout<<k<<"="<<"type: "<<children->item(k)->getNodeType()<<std::endl;;
			if(children->item(k)->getNodeType()==1)
			{
				printElement((DOMElement *)children->item(k));
			}
			else if(children->item(k)->getNodeType()== 3)
			{			    
				cout<<" "<<XMLString::transcode(children->item(k)->getNodeValue());
			}
		}
	}
}
Exemple #25
0
Triggerconf::STRING_LIST Triggerconf::getConfigAttributeNames (string module, string submodule, string configname)
{
	STRING_LIST ret;

	if (! existsConfigElement (module, submodule, configname)) return ret;

	DOMNode* node = selectConfigElement (module, submodule, configname);
	if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) return ret;

	DOMElement* elem = (DOMElement*) node;
	DOMNamedNodeMap* attributes = elem->getAttributes ();

	for (unsigned int i=0; i<attributes->getLength (); i++) {
		DOMNode* attr = attributes->item (i);
		const XMLCh* xname = attr->getNodeName ();	
		char* cname = XMLString::transcode (xname);

		ret.push_back (cname);	
		XMLString::release (&cname);
	}

	return ret;
}
EppLaunchPhase* EppLaunchPhase::fromXML( const DOMNode& root )
{
    DOMNamedNodeMap* attrs = root.getAttributes();
    EppLaunchPhase *_ret = new EppLaunchPhase();
    if( null == _ret )
        return null;
    {
        DOMNode* node = (DOMNode*)&root;
        DOMString name = node->getLocalName();
        if( name.isNull() )
        {
            name = node->getNodeName();
        }
        if( name.isNotNull() )
        {
            if( name.substringData(0, 7).equals("launch:") )
            {
                name = name.substringData(7, name.length() - 7);
            }
            if( name.equals("phase") )
            {
                _ret->_phase = EppUtil::getText(*node);
            }
        }
    }
    for( unsigned int i = 0; i<attrs->getLength(); i++ )
    {
        DOMNode* attr = attrs->item(i);
        DOMString _v = attr->getNodeValue();
        if( XS(attr->getNodeName()).equals("name") )
        {
            _ret->_sub_phase = attr->getNodeValue();
            break;
        }
    }
    return _ret;
}
Exemple #27
0
// ---------------------------------------------------------------------------
//  GeneralAttributeCheck: Validation methods
// ---------------------------------------------------------------------------
void
GeneralAttributeCheck::checkAttributes(const DOMElement* const elem,
                                       const unsigned short elemContext,
                                       TraverseSchema* const schema,
                                       const bool isTopLevel,
                                       ValueVectorOf<DOMNode*>* const nonXSAttList)
{
    if (nonXSAttList)
        nonXSAttList->removeAllElements();

    if (elem == 0 || !fAttMap || elemContext>=E_Count)
        return;

    const XMLCh* elemName = elem->getLocalName();
    if (!XMLString::equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA, elem->getNamespaceURI())) {
        schema->reportSchemaError
        (
            elem
            , XMLUni::fgXMLErrDomain
            , XMLErrs::ELTSchemaNS
            , elemName
        );
    }

    const XMLCh*     contextStr = (isTopLevel) ? fgGlobal : fgLocal;
    DOMNamedNodeMap* eltAttrs = elem->getAttributes();
    int              attrCount = eltAttrs->getLength();
    XMLByte          attList[A_Count];

    memset(attList, 0, sizeof(attList));

    for (int i = 0; i < attrCount; i++) {

        DOMNode*     attribute = eltAttrs->item(i);
        const XMLCh* attName = attribute->getNodeName();

        // skip namespace declarations
        if (XMLString::equals(attName, XMLUni::fgXMLNSString)
            || XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
            continue;

        // Bypass attributes that start with xml
        // add this to the list of "non-schema" attributes
        if ((*attName == chLatin_X || *attName == chLatin_x)
           && (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
           && (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {

           if (nonXSAttList)
                nonXSAttList->addElement(attribute);

            continue;
        }

        // for attributes with namespace prefix
        const XMLCh* attrURI = attribute->getNamespaceURI();

        if (attrURI != 0 && *attrURI) {

            // attributes with schema namespace are not allowed
            // and not allowed on "documentation" and "appInfo"
            if (XMLString::equals(attrURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_APPINFO) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) {

                schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                    XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
            }
            else if (nonXSAttList)
            {
                nonXSAttList->addElement(attribute);
            }

            continue;
        }

        int attNameId = A_Invalid;
        attName = attribute->getLocalName();

        bool bContinue=false;   // workaround for Borland bug with 'continue' in 'catch'
        try {
            attNameId= fAttMap->get(attName, fMemoryManager);
        }
        catch(const OutOfMemoryException&)
        {
            throw;
        }
        catch(...) {

            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
            bContinue=true;
        }
        if(bContinue)
            continue;

        if (fgElemAttTable[elemContext][attNameId] & Att_Mask) {

            attList[attNameId] = 1;
            validate
            (
                elem
                , attName
                , attribute->getNodeValue()
                , fgElemAttTable[elemContext][attNameId] & DV_Mask
                , schema
            );
        }
        else {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
        }
    }

    // ------------------------------------------------------------------
    // Check for required attributes
    // ------------------------------------------------------------------
    for (unsigned int j=0; j < A_Count; j++) {

        if ((fgElemAttTable[elemContext][j] & Att_Required) && attList[j] == 0) {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::AttributeRequired,
                                      fAttNames[j], contextStr, elemName);
        }
    }
}
Exemple #28
0
void *NurbsCurve::read(DOMNode *node) {
	unsigned int i; 				//* variable to counter
	DOMNamedNodeMap *attributes;	//* variable to hold the node attributes
	
	char *ctemp;					//* temporary variable
	
	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {		
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "DEF")) {
			strcpy(this->DEF,XMLString::transcode (attributes->item(i)->getNodeValue()));
			setLink(XMLString::transcode(attributes->item(i)->getNodeValue()),this);
		} else
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
			return(getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		}
	}
		
		
		
 	for (i = 0; i < attributes->getLength(); i++) {		
		if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "tessellation")) {
		} else
		if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "containerField")) {
		} else
		if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "order")) {
		} else
		if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "controlPoint")) {
			numberOfPoints=0;
			ctemp = strtok(XMLString::transcode (attributes->item(i)->getNodeValue())," ");
			while (ctemp != NULL) {
				points[numberOfPoints][0] = atof(ctemp);
				ctemp = strtok(NULL," ");
				points[numberOfPoints][1] = atof(ctemp);
				ctemp = strtok(NULL," ");
				points[numberOfPoints++][2] = atof(ctemp);
				ctemp = strtok(NULL," ");
			
				#ifdef DEBUG
					cout << "Points : " << points[numberOfPoints-1][0] << " , " << 
										   points[numberOfPoints-1][1] << " , " << 
										   points[numberOfPoints-1][2] << endl;
				#endif
			
			}
		}
	}
	

	#ifdef DEBUG
		cout << "Number of Points : " << numberOfPoints << endl;
	#endif

	controlPoint = new float[3*numberOfPoints];

	unsigned int f;
	for(f=0;f<routeStruct::routeCount;f++) {
		if (!strcmp (x3d::my_x3d->routeTable[f]->toNode,DEF)) {
			if(!strcmp(x3d::my_x3d->routeTable[f]->toField,"set_controlPoint")) {
				if((*x3d::my_x3d->routeTable[f]->field2)==NULL) {
					(*x3d::my_x3d->routeTable[f]->field2) = new float[3*numberOfPoints];
				}
				delete controlPoint;
				controlPoint = (float *)(*x3d::my_x3d->routeTable[f]->field2);
			}
		}
	}
	

	return(NULL);
	
}
Exemple #29
0
void XmlTag::construct(XmlTag * parent, DOMNode * n, bool logging)
{
    this->parent = parent;
    this->name = "unknown";
    if (parent == NULL)
    {
        if (logging)
        {
            pLogEngine l (LogEngine::create (LOG_DEVELOPER, "XmlTag"));
            this->log = l;
        }
    }
    else
    {
        if (logging) this->log = parent->log;
    }

    if (n == NULL)
    {
        if (logging) log->__format(LOG_ERROR, "Empty tag (%s)!", getFullName().c_str());
        return;
    }
    if (n->getNodeType() != DOMNode::ELEMENT_NODE)
    {
        if (logging) log->__format(LOG_ERROR, "This (%s) is not a tag!", getFullName().c_str());
    }
    assignXmlString (name, n->getNodeName());

    //fill tag attributes map
    if (!n->hasAttributes())
    {
        if (logging) log->__format(LOG_WARNING, "No attributes in this tag (%s)!", getFullName().c_str() );
    }
    else
    {
        std::string attributeName = "";
        std::string attributeData = "";
        DOMNamedNodeMap *attList = n->getAttributes ();
        int size = attList->getLength ();
        for (int i = 0; i < size; ++i)
        {
            DOMAttr *attNode = (DOMAttr *) attList->item (i);
            assignXmlString (attributeName, attNode->getName ());
            assignXmlString (attributeData, attNode->getValue ());
            if ( (attributeName != "") && (attributeData != "") )
            {
                attributes[attributeName] = attributeData;
                attributesRead[attributeName] = false;
            }
        }
    }
    //fill child tags map
    if (n->hasChildNodes())
    {
        std::string childTagName;
        for (n = n->getFirstChild (); n != 0; n = n->getNextSibling ())
        {
            if (n) if (n->getNodeType() == DOMNode::ELEMENT_NODE)
                {
                    assignXmlString (childTagName, n->getNodeName());
                    //XmlTag * tmpTag = new XmlTag(this, n, logging);
                    XmlTag * tmpTag = new XmlTag(this, n);
                    tags.push_back(tmpTag);
                }
        }
    }
}
Exemple #30
0
bool XCube::parserCube(XSchema* pschema,xercesc::DOMElement* element)
{
	this->_parentschema=pschema;
	if(element)
	{
		    DOMNamedNodeMap *attributes;
			DOMNodeList *children =element->getChildNodes();
			DOMNode *tmpnode;
			std::string tmpstr=XMLString::transcode(element->getNodeName());
			if(tmpstr!="Cube")
			{
				return false;
			}

			attributes=element->getAttributes();

			if(attributes)
			{
				for(int j=0;j<attributes->getLength();j++)
				{
					tmpnode=attributes->item(j);
					tmpstr=XMLString::transcode(tmpnode->getNodeName());
					if(tmpstr=="name")
					{
						this->_name=XMLString::transcode(tmpnode->getNodeValue());
					}
					else if(tmpstr=="tableName")
					{
						this->_fact=XMLString::transcode(tmpnode->getNodeValue());
					}
				}			
			}
			else
			{
				return false;
			}

			if(element->hasChildNodes())
			{	 
				for(int k=0;k<children->getLength();k++)
				{
					if(children->item(k)->getNodeType()==1)
					{   
						DOMElement* tmpelement=(DOMElement*)children->item(k);
						tmpstr=XMLString::transcode(tmpelement->getNodeName());
						if(tmpstr=="Dimension")
						{
						   Dimension *dimension=new Dimension;	
						   if(dimension->parserDimension(this,tmpelement))
						   {
								this->_dimensions.push_back(dimension);
						   }
						   else
						   {
							   return false;
						   }
						}
						else if(tmpstr=="DimensionUsage")
						{
						   Dimension* dimension=NULL;						   
						   attributes=tmpelement->getAttributes();
						   if(attributes)
						   {
								for(int j=0;j<attributes->getLength();j++)
								{
									DOMNode *tmpnode=attributes->item(j);
									tmpstr=XMLString::transcode(tmpnode->getNodeName());
								//	std::string dname1=XMLString::transcode(tmpnode->getNodeValue());
									if(tmpstr=="source")
									{
										std::string dname=XMLString::transcode(tmpnode->getNodeValue());
										dimension=this->getSchema()->getShareDimension(dname);
									}
								}
								if(dimension)
								{	
									Dimension *tmpdmen=new Dimension;
									*tmpdmen=*dimension;
									for(int j=0;j<attributes->getLength();j++)
									{
										DOMNode *tmpnode=attributes->item(j);
										tmpstr=XMLString::transcode(tmpnode->getNodeName());
										if(tmpstr=="name")
										{
											std::string dname=XMLString::transcode(tmpnode->getNodeValue());
											tmpdmen->setName(dname);
										}
										else if(tmpstr=="foreignKey")
										{
											std::string fkey=XMLString::transcode(tmpnode->getNodeValue());
                                            tmpdmen->setForeignKey(fkey);
										}
									}
									tmpdmen->setCubeDimension(this);
									this->_dimensions.push_back(tmpdmen);	
								}
							}				  
						}
						else if(tmpstr=="Measure")
						{
						 	Measure *measure=new Measure;					
							if(measure->parserMeasure(this,tmpelement))
							{
								this->_measures.push_back(measure);
							}
							else
							{
								return false;
							}
						}
						else if(tmpstr=="CalculatedMember")
						{
						    calcMember *calmember=new calcMember;	
							if(calmember->parserCalMember(this,tmpelement))
							{
								this->_calcmembers.push_back(calmember);
							}
							else
							{
								return false;
							}
						}
					}
				}	 
			}
			else
			{
				return false;
			}
	}
	else
	{		
		return false;
	}
	return true;
}