MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / StartElementHandler

Function StartElementHandler

xmpsdk/src/ExpatAdapter.cpp:292–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290// =================================================================================================
291
292static void StartElementHandler ( void * userData, XMP_StringPtr name, XMP_StringPtr* attrs )
293{
294 XMP_Assert ( attrs != 0 );
295 ExpatAdapter * thiz = (ExpatAdapter*)userData;
296
297 size_t attrCount = 0;
298 for ( XMP_StringPtr* a = attrs; *a != 0; ++a ) ++attrCount;
299 if ( (attrCount & 1) != 0 ) XMP_Throw ( "Expat attribute info has odd length", kXMPErr_ExternalFailure );
300 attrCount = attrCount/2; // They are name/value pairs.
301
302 #if XMP_DebugBuild & DumpXMLParseEvents
303 if ( thiz->parseLog != 0 ) {
304 PrintIndent ( thiz->parseLog, thiz->elemNesting );
305 fprintf ( thiz->parseLog, "StartElement: %s, %d attrs", name, attrCount );
306 for ( XMP_StringPtr* attr = attrs; *attr != 0; attr += 2 ) {
307 XMP_StringPtr attrName = *attr;
308 XMP_StringPtr attrValue = *(attr+1);
309 fprintf ( thiz->parseLog, ", %s = \"%s\"", attrName, attrValue );
310 }
311 fprintf ( thiz->parseLog, "\n" );
312 }
313 #endif
314
315 XML_Node * parentNode = thiz->parseStack.back();
316 XML_Node * elemNode = new XML_Node ( parentNode, "", kElemNode );
317
318 SetQualName ( name, elemNode );
319
320 for ( XMP_StringPtr* attr = attrs; *attr != 0; attr += 2 ) {
321
322 XMP_StringPtr attrName = *attr;
323 XMP_StringPtr attrValue = *(attr+1);
324 XML_Node * attrNode = new XML_Node ( elemNode, "", kAttrNode );
325
326 SetQualName ( attrName, attrNode );
327 attrNode->value = attrValue;
328 if ( attrNode->name == "xml:lang" ) NormalizeLangValue ( &attrNode->value );
329 elemNode->attrs.push_back ( attrNode );
330
331 }
332
333 parentNode->content.push_back ( elemNode );
334 thiz->parseStack.push_back ( elemNode );
335
336 if ( elemNode->name == "rdf:RDF" ) {
337 thiz->rootNode = elemNode;
338 ++thiz->rootCount;
339 }
340 #if XMP_DebugBuild
341 ++thiz->elemNesting;
342 #endif
343
344} // StartElementHandler
345
346// =================================================================================================
347

Callers

nothing calls this directly

Calls 3

PrintIndentFunction · 0.85
SetQualNameFunction · 0.85
NormalizeLangValueFunction · 0.85

Tested by

no test coverage detected