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; }
void txDriver::StartElement(const XML_Char *aName, const XML_Char **aAtts) { PRInt32 attcount = 0; const XML_Char** atts = aAtts; while (*atts) { ++atts; ++attcount; } PRInt32 idOffset = XML_GetIdAttributeIndex(mExpatParser); nsresult rv = mCompiler->startElement(static_cast<const PRUnichar*>(aName), static_cast<const PRUnichar**>(aAtts), attcount/2, idOffset); if (NS_FAILED(rv)) { PR_LOG(txLog::xslt, PR_LOG_ALWAYS, ("compile failed at %i with %x\n", XML_GetCurrentLineNumber(mExpatParser), rv)); mCompiler->cancel(rv); } }
int txXMLParser::StartElement(const XML_Char *aName, const XML_Char **aAtts) { nsCOMPtr<nsIAtom> prefix, localName; PRInt32 nsID; XMLUtils::splitExpatName(aName, getter_AddRefs(prefix), getter_AddRefs(localName), &nsID); Element* newElement = mDocument->createElementNS(prefix, localName, nsID); if (!newElement) { return XML_ERROR_NO_MEMORY; } const XML_Char** theAtts = aAtts; while (*theAtts) { XMLUtils::splitExpatName(*theAtts++, getter_AddRefs(prefix), getter_AddRefs(localName), &nsID); nsDependentString attValue(*theAtts++); nsresult rv = newElement->appendAttributeNS(prefix, localName, nsID, attValue); if (NS_FAILED(rv)) { return XML_ERROR_NO_MEMORY; } } int idx; if ((idx = XML_GetIdAttributeIndex(mExpatParser)) > -1) { nsDependentString idName((const PRUnichar*)*(aAtts + idx)); nsDependentString idValue((const PRUnichar*)*(aAtts + idx + 1)); // make sure IDs are unique if (!idValue.IsEmpty()) { mDocument->setElementID(idValue, newElement); } } mCurrentNode->appendChild(newElement); mCurrentNode = newElement; return XML_ERROR_NONE; }
int _Expat_XML_GetIdAttributeIndex(struct ExpatIFace * Self, XML_Parser parser) { return XML_GetIdAttributeIndex(parser); }