forked from ebu/MXFTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebucoreParser.cpp
514 lines (478 loc) · 22.6 KB
/
ebucoreParser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
/*!
* \project_name EBU Player
* \file ebucoreParser.cpp
* \brief EBUCore Parser body
* \authors Marco Dos Santos Oliveira
* \version 0.1
* \dateOfCreation 20 august 2012
* \dateOfUpdate 26 september 2012
* This software is published in LGPLv3.0
*
*/
// include files and libraries
#include "ebucoreParser.hpp"
// class constructor
ebucoreParser::ebucoreParser(void)
{
// EBUcore Schemas folder
std::string dir = std::string("./EBUCoreSchema");
// Schemas filenames
std::vector<std::string> files = std::vector<std::string>();
// Get the schemas filenames
getSchemas(dir,files);
//prepare dublin core attributes
DCAttr.push_back(DCAttribute());
// extract all schemas
for (unsigned int i = 0;i < files.size();i++) {
std::cout << files[i] << std::endl;
std::cout<< "start parsing..."<<std::endl;
extractSchema(dir+"/"+files[i]);
}
// clean the stack and reuse it for skeleton generation
ebucoreStack.clear();
generateSkeleton();
}
// class destructor
ebucoreParser::~ebucoreParser(void)
{
ebucoreStack.clear();
ebucoremodel.clear();
}
#ifdef _WIN32
int ebucoreParser::getSchemas(std::string dir, std::vector<std::string> &files)
{
WIN32_FIND_DATA FindFileData;
wchar_t * FileName = genericFeatures::string2wchar_t(dir);
HANDLE hFind = FindFirstFile(FileName, &FindFileData);
if (isExtension(genericFeatures::wchar_t2string(FindFileData.cFileName), "xsd")) {
files.push_back(genericFeatures::wchar_t2string(FindFileData.cFileName));
}
while (FindNextFile(hFind, &FindFileData)) {
std::string path(genericFeatures::wchar_t2string(FindFileData.cFileName));
if (isExtension(path, "xsd")) {
files.push_back(path);
}
}
return 0;
}
#else
// get the path to the schemas
int ebucoreParser::getSchemas (std::string dir, std::vector<std::string> &files) {
DIR *dp;
struct dirent *dirp;
// if opening folder fail then
if((dp = opendir(dir.c_str())) == NULL) {
// display error message
std::cout << "Error(" << errno << ") opening " << dir << std::endl;
return errno;
}
// while not the end of folder
while ((dirp = readdir(dp)) != NULL) {
// if it is am xsd file then
if (dirp->d_type == DT_REG && isExtension(dirp->d_name, "xsd"))
// save the schema filename inside the vector
files.push_back(std::string(dirp->d_name));
}
closedir(dp); // close folder
return 0;
}
#endif
// extract a schema
void ebucoreParser::extractSchema(std::string pathtofile) {
// init xercesc
xercesc::XMLPlatformUtils::Initialize();
xercesc::DOMImplementation* dom_xsd = xercesc::DOMImplementationRegistry::getDOMImplementation(xercesc::XMLString::transcode(""));
xercesc::DOMLSParser* dom_file = dom_xsd->createLSParser(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS, 0);
// extract xml DOM document and element
xercesc::DOMDocument* schema_doc = dom_file->parseURI(pathtofile.c_str());
xercesc::DOMElement* schema_root = schema_doc->getDocumentElement();
// put the cursor at the beginning
schema_root = schema_root->getFirstElementChild();
schema_root = schema_root->getNextElementSibling()->getNextElementSibling();
// generate and store the ebucore root
ebucoremodel.push_back(constructSchema(schema_root));
}
// wrap element attribute
ebucoreParser::AttributeStruct ebucoreParser::packAttribute(xercesc::DOMElement * el) {
// prepare the attribute struct
ebucoreParser::AttributeStruct attr;
// grab the attributes
std::string name (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("name"))));
std::string ref (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("ref"))));
std::string type (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("type"))));
std::string byDefault (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("default"))));
// wrap the attribute
attr.name = ((name.size()>0)?name:ref);
attr.type = ((type.size()>0)?type:"string");
attr.hasDefaultValue = ((byDefault.size()>0)?true:false);
attr.defaultValue = ((byDefault.size()>0)?byDefault:"NULL");
// wrap the attribute enumeration
attr.hasEnumeration = false;
std::vector<std::string> attrEnum;
attr.Enumeration = attrEnum;
// return the attribute
return attr;
}
// generate the attributes of an element
std::list<ebucoreParser::AttributeStruct> ebucoreParser::generateAttributes(std::string father, xercesc::DOMElement * el) {
// groupName to store the attributeGroups
std::vector<std::string> groupName;
// attributes list
std::list<ebucoreParser::AttributeStruct> attributes;
// when father type hasn't a name, that means the type is implicit
if (father =="") {
// we must save the current position
xercesc::DOMElement * tmp = el->getFirstElementChild();
// and looking for the implicit father complexType (without name)
if ((std::string)(xercesc::XMLString::transcode(tmp->getTagName())) == "complexType" ) {
// when the complexType is identified, put the cursor inside the first child
tmp = tmp->getFirstElementChild();
// while xercesc pointer not null
while (tmp != 0) {
// if attribute is a simpleContent
if ((std::string)(xercesc::XMLString::transcode(tmp->getTagName())) == "simpleContent") {
// grab the first child of the first child of the current element
xercesc::DOMElement * localTmp = tmp->getFirstElementChild()->getFirstElementChild();
// if xercersc pointer not null
while (localTmp != 0) {
// if attribute is a simple attribute
if ((std::string)(xercesc::XMLString::transcode(localTmp->getTagName())) == "attribute" ) {
// wrap and push the attribute
attributes.push_back(packAttribute(localTmp));
// if attribute is an attributeGroup
} else if ((std::string)(xercesc::XMLString::transcode(localTmp->getTagName())) == "attributeGroup" ) {
// push the attributeGroup name inside the attributeGroup stack
groupName.push_back(removePrefix ((std::string)(xercesc::XMLString::transcode(localTmp->getAttribute (xercesc::XMLString::transcode("ref")))),":" ));
}
// next element...
localTmp = localTmp->getNextElementSibling();
}
// if attribute is a complexContent
} else if ((std::string)(xercesc::XMLString::transcode(tmp->getTagName())) == "complexContent") {
// grab the first child of the current element
xercesc::DOMElement * localTmp = tmp->getFirstElementChild();
// if it is a DublinCore attribute
if (isDCSimpleType((std::string)(xercesc::XMLString::transcode(localTmp->getAttribute (xercesc::XMLString::transcode("base")))))) {
//push the dublincore attribute
attributes.push_back(DCAttribute());
} else {
// if it is not a dublincore attribute, that means that is an attributeGroup or external attribute
groupName.push_back(removePrefix ((std::string)(xercesc::XMLString::transcode(localTmp->getAttribute (xercesc::XMLString::transcode("base")))),":" ));
}
// enter inside the current element
localTmp = localTmp->getFirstElementChild();
// in plus of external attribute and attributeGroup treatments, we can have
// several local attributes and attributeGroups to solve
// if xercesc pointer is not null
while (localTmp != 0) {
// if it is a simple attribute
if ((std::string)(xercesc::XMLString::transcode(localTmp->getTagName())) == "attribute" ) {
// wrap and push the attribute
attributes.push_back(packAttribute(localTmp));
// if it is an attributeGroup
} else if ((std::string)(xercesc::XMLString::transcode(localTmp->getTagName())) == "attributeGroup" ) {
// save the attributeGroup name/reference...
groupName.push_back(removePrefix ((std::string)(xercesc::XMLString::transcode(localTmp->getAttribute (xercesc::XMLString::transcode("ref")))),":"));
}
// next element...
localTmp = localTmp->getNextElementSibling();
}
// if attribute is an attributeGroup
} else if ((std::string)(xercesc::XMLString::transcode(tmp->getTagName())) == "attributeGroup"){
// save the attributeGroup name/reference
groupName.push_back(removePrefix ((std::string)(xercesc::XMLString::transcode(tmp->getAttribute (xercesc::XMLString::transcode("ref")))), ":" ));
// if attribute is a simple attribute
} else if ((std::string)(xercesc::XMLString::transcode(tmp->getTagName())) == "attribute") {
// wrap and push the attribute
attributes.push_back(packAttribute(tmp));
}
// next...
tmp = tmp->getNextElementSibling();
}
}
}
// We don't know if the father is an implicit complexType who references
// an external attributeGroup, so we consider it as an external references
if (father!="") { groupName.push_back(father);}
// for each external attributeGroup, build the set of attributes
for (int i=0;i<(int)groupName.size();i++) {
// pointer starter...
xercesc::DOMElement * tmpEl = el;
// looking for the root of the schema document
while ((std::string)(xercesc::XMLString::transcode((tmpEl->getParentNode())->getNodeName())) != "schema") {
tmpEl = dynamic_cast<xercesc::DOMElement*>(tmpEl->getParentNode());
}
// grab the first child of the schema
tmpEl=(dynamic_cast<xercesc::DOMElement*>(tmpEl->getParentNode()))->getFirstElementChild();
// looking for a complexType or an attributeGroup with the right name
while (((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "complexType" && xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) != groupName.at(i) ) || ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "attributeGroup" && xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) != groupName.at(i)) ) {
tmpEl = tmpEl->getNextElementSibling();
}
//grab the first child
tmpEl=tmpEl->getFirstElementChild();
// while xerces pointer not null
do {
// and if the element is an attribute
if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "attribute") {
// wrap and push the attribute
attributes.push_back(packAttribute(tmpEl));
}
// next
tmpEl = tmpEl->getNextElementSibling();
} while (tmpEl != 0);
}
return attributes;
}
// generate the children of an elements
std::list<ebucoreParser::ElementStruct> ebucoreParser::generateChildren(std::string father, xercesc::DOMElement * el, int level) {
// instantiate the children list
std::list<ebucoreParser::ElementStruct> children;
// copy the current position of xercesc pointer
xercesc::DOMElement * tmpEl = el;
// while xercesc pointer not null, element different of complexType with the proper name
while (tmpEl != 0 && ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "complexType" || xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) != father )) {
tmpEl = tmpEl->getNextElementSibling();// next
}
// grab the first child of proper element
tmpEl=tmpEl->getFirstElementChild();
// looking for the sequence of elements
while (tmpEl != 0 && (std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "sequence") {
tmpEl = tmpEl->getNextElementSibling(); // next
}
// if pointer not null, grab the first child of the current element
if (tmpEl != 0) {
tmpEl=tmpEl->getFirstElementChild();
}
// while xerces point not null, loop
while (tmpEl != 0) {
// if current tag kind is element
if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "element") {
// prepare the element information
std::string name (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))));
std::string type (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("type"))));
std::string ref (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref"))));
std::string minimum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("minOccurs"))));
std::string maximum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("maxOccurs"))));
// instantiate the children struct
ebucoreParser::ElementStruct internalChildren;
// grab the right name/references
internalChildren.name = (name.size()>0)?name:ref;
// identify the cardinality and the type of element
internalChildren.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1);
internalChildren.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1);
internalChildren.type = ( (type.size()>0) ? type : "" );
// if type is not standard
if (!isStandardType(type)) {
// if type is not null
if (type.size()>0) {
//generate the attribute list of the current element
internalChildren.attribute = (isDCSimpleType(type)) ? DCAttr : generateAttributes(removePrefix(internalChildren.type, ":"), tmpEl);
// and correct his type if required
internalChildren.type = ( (isDCSimpleType(type)) ? DCType() : internalChildren.type );
} else {
// generate the attribute list of the current element and correct his type if required
internalChildren.attribute = (isDCSimpleType(internalChildren.name))? DCAttr : generateAttributes("", tmpEl);
internalChildren.type = ( (isDCSimpleType(internalChildren.name)) ? DCType() : "") ;
}
}
// if element type is ebucore and the type not present in the stack, then
if (isEBUCoreType(internalChildren.type) && !groupExist(internalChildren.type)) {
ebucoreStack.push_back(internalChildren.type); // push the type
// generate the children
internalChildren.children = generateChildren(removePrefix(internalChildren.type,":"), el, level+1);
ebucoreStack.pop_back(); // pop the type
}
// push the children list
children.push_back(internalChildren);
// if the current tag king is group, then
} else if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "group") {
// generate the children of this group and then add it to current list of children
generateGroupChildren(children, xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref"))), el);
}
tmpEl = tmpEl->getNextElementSibling(); // next
}
return children;
}
// include external elements (from groups)
void ebucoreParser::generateGroupChildren(std::list<ElementStruct> children, std::string father, xercesc::DOMElement * el) {
// store the current position of xercesc pointer
xercesc::DOMElement * tmpEl = el;
// looking for the group who contains the other elements with the father name
while (tmpEl != 0 && !((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "group" && xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))) == removePrefix(father,":") )) {
tmpEl = tmpEl->getNextElementSibling();
}
// enter inside the group
tmpEl=tmpEl->getFirstElementChild();
// looking for the sequence
while (tmpEl != 0 && (std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) != "sequence") {
tmpEl = tmpEl->getNextElementSibling();
}
// if pointer not null, grab the first child
if (tmpEl != 0) {
tmpEl=tmpEl->getFirstElementChild();
}
// while xerces pointer not null,
while (tmpEl != 0) {
// if it's an element
if ((std::string)(xercesc::XMLString::transcode(tmpEl->getTagName())) == "element") {
// prepare the element informations
std::string name (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("name"))));
std::string type (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("type"))));
std::string ref (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("ref"))));
std::string minimum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("minOccurs"))));
std::string maximum (xercesc::XMLString::transcode(tmpEl->getAttribute (xercesc::XMLString::transcode("maxOccurs"))));
// instantiate the list of children
ebucoreParser::ElementStruct internalChildren;
// identify the element name
internalChildren.name = (name.size()>0)?name:ref;
// identify the cardinality and type
internalChildren.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1);
internalChildren.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1);
internalChildren.type = ( (type.size()>0) ? type : "" );
// if it is not a standard type
if (!isStandardType(type)) {
// and if type is not null
if (type.size()>0) {
// generate attributes
internalChildren.attribute = (isDCSimpleType(type)) ? DCAttr : generateAttributes(removePrefix(internalChildren.type, ":"), tmpEl);
// and correct the type is required
internalChildren.type = ( (isDCSimpleType(type)) ? DCType() : internalChildren.type );
} else {
// generate attributes and correct the type is required
internalChildren.attribute = (isDCSimpleType(internalChildren.name))? DCAttr : generateAttributes("", tmpEl);
internalChildren.type = ( (isDCSimpleType(internalChildren.name)) ? DCType() : "") ;
}
}
// if it is an ebucore element and the type of this element is not present in the element type stack
if (isEBUCoreType(internalChildren.type) && !groupExist(internalChildren.type)) {
// push the type
ebucoreStack.push_back(internalChildren.type);
// generate children
internalChildren.children = generateChildren(removePrefix(internalChildren.type,":"), el, 1);
// pop the type
ebucoreStack.pop_back();
}
//push the internal child
children.push_back(internalChildren);
}
// next
tmpEl = tmpEl->getNextElementSibling();
}
}
// pre-generate and pack the unique dublin core attribute
ebucoreParser::AttributeStruct ebucoreParser::DCAttribute(void) {
AttributeStruct attr;
attr.name = "xml:lang";
attr.type = "string";
attr.hasDefaultValue = false;
attr.hasEnumeration = false;
return attr;
}
std::string ebucoreParser::DCType(void) {
return "DublinCore";
}
/*std::vector<std::string> ebucoreParser::listEnumeration(xercesc::DOMElement * el) {
std::vector<std::string> listEnum;
while (el != 0) {
std::cout<<"Enum :: "<<(std::string)xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("value")))<<std::endl;
listEnum.push_back((std::string)xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("value"))));
el = el->getNextElementSibling();
}
return listEnum;
}*/
// construct an ebucore skeleton
ebucoreParser::ElementStruct ebucoreParser::constructSchema(xercesc::DOMElement * el) {
// prepare the element information
std::string str (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("name"))));
std::string type (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("type"))));
std::string ref (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("ref"))));
std::string minimum (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("minOccurs"))));
std::string maximum (xercesc::XMLString::transcode(el->getAttribute (xercesc::XMLString::transcode("maxOccurs"))));
// instantiate a new root
ebucoreParser::ElementStruct root;
// grab the name, the cardinalities, the type, attributes and children
root.name = (str.size()>0)?str:ref;
root.minCardinality = ((minimum.size()>0)?atoi(minimum.c_str()):1);
root.maxCardinality = ((maximum.size()>0)?isUnbounded(maximum):1);
root.type = ((type.size()>0)?type:"undefined");
// store the current element type inside the stack to avoid infinite loops
ebucoreStack.push_back(root.type);
// generate the attributes of the current element
root.attribute = ebucoreParser::generateAttributes(removePrefix (type, ":"), el);
// generate the children of the current element
root.children = generateChildren(removePrefix (type, ":"), el,1);
// pop the current element type outside of the stack
ebucoreStack.pop_back();
return root;
}
// test if it is dublincore type
bool ebucoreParser::isDCSimpleType(std::string str) {
std::string target("dc:"); // dublincore prefix
return (std::string::npos != str.find(target)) ? true :false ;
}
// test if it is standard type
bool ebucoreParser::isStandardType(std::string str) {
// array of standard types
const std::string elementType[] = {"string","nonNegativeInteger","boolean","long","integer","date","time","duration","hexBinary","anyURI","ID","IDREFS"};
for (int i=0;i<12;i++) {
if (elementType[i] == str) {return true;}
}
return false;
}
// test if it is ebucore type
bool ebucoreParser::isEBUCoreType(std::string str) {
std::string target("ebucore:");
return (std::string::npos != str.find(target)) ? true :false ;
}
// test if element is unbounded or not
int ebucoreParser::isUnbounded(std::string maximum) {
return ((maximum == "unbounded")?-1:std::atoi(maximum.c_str()));
}
// test if a filename has a particular extension
bool ebucoreParser::isExtension(std::string str, std::string extension) {
// find last "." position in a string
int lastindex = str.find_last_of(".");
// copy what comes after last dot
std::string str2 = str.substr (lastindex+1,str.size()-(lastindex+1));
//loop through each character and make it lower-case. stop when you hit '\0'.
for(int i = 0; str2[i] != '\0'; i++){
str2[i] = tolower(str2[i]);
}
// compare the file extension to the extension pattern
return (extension.compare(str2) == 0) ? true : false;
}
// test if an ebucore type is present in the ebucoreStack
bool ebucoreParser::groupExist(std::string str) {
for (std::vector<std::string>::iterator it = ebucoreStack.begin() ; it != ebucoreStack.end(); ++it) {
if (*it == str) { return true; }
}
return false;
}
std::string ebucoreParser::removePrefix(std::string str, std::string prefix) {
// find last "." position in a string
int lastindex = str.find_last_of(prefix);
// copy what comes after last dot
std::string str2 = str.substr (lastindex+1,str.size()-(lastindex+1));
// compare the file extension to the extension pattern
return str2;
}
void ebucoreParser::generateSkeletonElement(ebucoreParser::ElementStruct skeleton) {
//ebucoreStack.push_back(skeleton.name);
//std::cout<<"generating an element..."<<std::endl;
//std::cout<<"name "<<skeleton.name<<std::endl;
for (std::list<ebucoreParser::ElementStruct>::iterator it=skeleton.children.begin() ; it != skeleton.children.end(); ++it) {
ebucoreParser::ElementStruct child = *it;
//std::cout<<"inside the loop"<<std::endl;
//std::cout<<"child name : "<<child.name<<" and it has a minimal cardinality of : "<<child.minCardinality<<std::endl;
if (child.minCardinality>0) {
//std::cout<<"go deeper..."<<std::endl;
generateSkeletonElement(child);
}
}
//ebucoreStack.pop_back();
}
void ebucoreParser::generateSkeleton(void) {
out.open ("example.xml");
generateSkeletonElement(ebucoremodel.at(0));
out.close();
}