| 290 | // ================================================================================================= |
| 291 | |
| 292 | static 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 |
nothing calls this directly
no test coverage detected