...
|
...
|
@@ -202,7 +202,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
|
202
|
202
|
{
|
203
|
203
|
const char *element_tag = NULL, *end_tag = NULL;
|
204
|
204
|
const xmlChar *node_name = NULL, *node_value = NULL;
|
205
|
|
- json_object *thisjobj;
|
|
205
|
+ json_object *thisjobj = NULL;
|
206
|
206
|
int node_type, ret = CL_SUCCESS, endtag = 0, toval = 0;
|
207
|
207
|
|
208
|
208
|
cli_dbgmsg("in ooxml_parse_element @ layer %d\n", rlvl);
|
...
|
...
|
@@ -238,6 +238,32 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
|
238
|
238
|
}
|
239
|
239
|
|
240
|
240
|
/* handle attributes if you want */
|
|
241
|
+ if (xmlTextReaderHasAttributes(reader) == 1) {
|
|
242
|
+ json_object *attributes;
|
|
243
|
+
|
|
244
|
+ thisjobj = cli_jsonobj(wrkptr, element_tag);
|
|
245
|
+ if (!thisjobj) {
|
|
246
|
+ return CL_EPARSE;
|
|
247
|
+ }
|
|
248
|
+ cli_dbgmsg("ooxml_parse_element: retrieved json object [%s]\n", element_tag);
|
|
249
|
+
|
|
250
|
+ attributes = cli_jsonobj(thisjobj, "Attributes");
|
|
251
|
+ if (!thisjobj) {
|
|
252
|
+ return CL_EPARSE;
|
|
253
|
+ }
|
|
254
|
+ cli_dbgmsg("ooxml_parse_element: retrieved json object [Attributes]\n");
|
|
255
|
+
|
|
256
|
+ while (xmlTextReaderMoveToNextAttribute(reader) == 1) {
|
|
257
|
+ const xmlChar *name, *value;
|
|
258
|
+ name = xmlTextReaderConstLocalName(reader);
|
|
259
|
+ value = xmlTextReaderConstValue(reader);
|
|
260
|
+ if (name == NULL || value == NULL) continue;
|
|
261
|
+
|
|
262
|
+ cli_dbgmsg("%s: %s\n", name, value);
|
|
263
|
+
|
|
264
|
+ cli_jsonstr(attributes, name, value);
|
|
265
|
+ }
|
|
266
|
+ }
|
241
|
267
|
|
242
|
268
|
/* advance to first content node */
|
243
|
269
|
if (xmlTextReaderRead(reader) != 1)
|
...
|
...
|
@@ -253,11 +279,13 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
|
253
|
253
|
switch (node_type) {
|
254
|
254
|
case XML_READER_TYPE_ELEMENT:
|
255
|
255
|
/* generate json object node */
|
256
|
|
- thisjobj = cli_jsonobj(wrkptr, element_tag);
|
257
|
256
|
if (!thisjobj) {
|
258
|
|
- return CL_EPARSE;
|
|
257
|
+ thisjobj = cli_jsonobj(wrkptr, element_tag);
|
|
258
|
+ if (!thisjobj) {
|
|
259
|
+ return CL_EPARSE;
|
|
260
|
+ }
|
|
261
|
+ cli_dbgmsg("ooxml_parse_element: retrieved json object [%s]\n", element_tag);
|
259
|
262
|
}
|
260
|
|
- cli_dbgmsg("ooxml_parse_element: retrieved json object [%s]\n", element_tag);
|
261
|
263
|
|
262
|
264
|
if (rlvl == 0)
|
263
|
265
|
root = thisjobj;
|