Exemplo n.º 1
0
nsresult
nsExpatDriver::HandleStartElement(const PRUnichar *aValue,
                                  const PRUnichar **aAtts)
{
  NS_ASSERTION(mSink, "content sink not found!");

  // Calculate the total number of elements in aAtts.
  // XML_GetSpecifiedAttributeCount will only give us the number of specified
  // attrs (twice that number, actually), so we have to check for default attrs
  // ourselves.
  PRUint32 attrArrayLength;
  for (attrArrayLength = XML_GetSpecifiedAttributeCount(mExpatParser);
       aAtts[attrArrayLength];
       attrArrayLength += 2) {
    // Just looping till we find out what the length is
  }

  if (mSink) {
    nsresult rv = mSink->
      HandleStartElement(aValue, aAtts, attrArrayLength,
                         XML_GetIdAttributeIndex(mExpatParser),
                         XML_GetCurrentLineNumber(mExpatParser));
    MaybeStopParser(rv);
  }

  return NS_OK;
}
Exemplo n.º 2
0
void MeaXMLParser::StartElementHandler(void *userData, const XML_Char *elementName,
                                        const XML_Char **attrs)
{
    MeaXMLParser *ps = static_cast<MeaXMLParser*>(userData);
    
    if (ps->m_haveDTD) {
        ps->m_validator->StartElement(ps->m_parser, elementName, attrs);
    }

    MeaXMLAttributes attributes(attrs, XML_GetSpecifiedAttributeCount(ps->m_parser));
    CString name(FromUTF8(elementName));
    CString container;
    if (!ps->m_elementStack->empty())
        container = ps->m_elementStack->top();
    ps->m_handler->StartElementHandler(container, name, attributes);
    ps->m_elementStack->push(name);

    if (ps->m_buildDOM) {
        MeaXMLNode* node = new MeaXMLNode(name, attributes);
        if (ps->m_nodeStack->empty()) {
            MeaAssert(ps->m_dom == NULL);
            ps->m_dom = node;
        }
        else {
            ps->m_nodeStack->top()->AddChild(node);
        }
        ps->m_nodeStack->push(node);
    }
}
Exemplo n.º 3
0
void hostile_xmlstart(void *data, const char *el, const char **attr) 
{
	int iAttrCount = XML_GetSpecifiedAttributeCount(currentParer);
	const char * id;
	const char * lifestr;
	int topx = 0;
	int topy = 0;
	int bottomx = 0;
	int bottomy = 0;
	Barrage * b;
	Level * level;
	//printf("HostileFactory TAG : %s\n",el);

	switch(getTagType(el))
	{
	case BOUNDINGBOX :	
        for (int i = 0;i < iAttrCount;i++){
            //printf("attr[%d]= %s\n",i,attr[i]);
			if (i%2 == 0)
			{
				
				if (!strcmp(attr[i],"top"))
					sscanf(attr[i+1],"%d,%d",&topx,&topy);
				if (!strcmp(attr[i],"bottom"))
					sscanf(attr[i+1],"%d,%d",&bottomx,&bottomy);
			}
        }
		
		currentHostile->setBoundingBox(BoundingBox((short)topx,(short)topy,(short)bottomx,(short)bottomy));
		break;
	case BARRAGE :
		level = (Level*)oldUserData;
		id = getAttribute("id",attr,iAttrCount);
		b = level->getBarrageManager()->getBarrage(id);
		if (b != NULL)
		{
			currentHostile->addBarrage(b);
		}
		else
		{
			printf("ERROR : COULDN'T FIND BARRAGE WITH ID %s PLEASE CHECK CONFIGURATION\n",id);
			exit(0);
		}
		break;
	case LIFE :
		lifestr = getAttribute("value",attr,iAttrCount);
		currentHostile->setLife(atoi(lifestr));
		break;
	case SCORE :
		lifestr = getAttribute("value",attr,iAttrCount);
		currentHostile->setScore(atoi(lifestr));
		break;
	case RENDERABLE:
		g_renderableFactory->setFactoryCallbacks(currentParer,hostile_xmlstart,hostile_xmlend);
		currentHostile->setRenderable(g_renderableFactory->getRenderable());
		break;
		
	}
}
Exemplo n.º 4
0
void ParserEngine::handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts)
{
	ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
	
	if (pThis->_pContentHandler)
	{
		try
		{
			pThis->_pNamespaceStrategy->startElement(name, atts, XML_GetSpecifiedAttributeCount(pThis->_parser)/2, pThis->_pContentHandler);	
		}
		catch (XMLException& exc)
		{
			throw SAXParseException(exc.message(), pThis->locator());
		}
	}
}
Exemplo n.º 5
0
static void f_StartElement (void *ud, const char *name, const char **attrs) {
  lxp_userdata *xpu = (lxp_userdata *)ud;
  lua_State *L = xpu->L;
  int lastspec = XML_GetSpecifiedAttributeCount(xpu->parser) / 2;
  int i = 1;
  if (getHandle(xpu, StartElementKey) == 0) return;  /* no handle */
  lua_pushstring(L, name);
  lua_newtable(L);
  while (*attrs) {
    if (i <= lastspec) {
      lua_pushnumber(L, i++);
      lua_pushstring(L, *attrs);
      lua_settable(L, -3);
    }
    lua_pushstring(L, *attrs++);
    lua_pushstring(L, *attrs++);
    lua_settable(L, -3);
  }
  docall(xpu, 2, 0);  /* call function with self, name, and attributes */
}
Exemplo n.º 6
0
int _Expat_XML_GetSpecifiedAttributeCount(struct ExpatIFace * Self, XML_Parser parser)
{
	return XML_GetSpecifiedAttributeCount(parser);
}