27 #include "../../../common/StringUtils.h"
28 #include "../../../xml/AbstractWriter.h"
29 #include "../../../xml/Reader.h"
30 #include "../../../xml/ReaderFactory.h"
31 #include "../../All.h"
32 #include "../../Annotated.h"
33 #include "../../Annotation.h"
34 #include "../../Any.h"
35 #include "../../AnyAttribute.h"
36 #include "../../AppInfo.h"
37 #include "../../Attribute.h"
38 #include "../../AttributeGroup.h"
39 #include "../../Choice.h"
40 #include "../../ComplexContent.h"
41 #include "../../ComplexType.h"
42 #include "../../Documentation.h"
43 #include "../../Element.h"
44 #include "../../Exception.h"
45 #include "../../Extension.h"
46 #include "../../Field.h"
47 #include "../../Group.h"
48 #include "../../Import.h"
49 #include "../../Include.h"
50 #include "../../Key.h"
51 #include "../../KeyRef.h"
52 #include "../../List.h"
53 #include "../../QName.h"
54 #include "../../Redefine.h"
55 #include "../../Restriction4ComplexContent.h"
56 #include "../../Restriction4SimpleContent.h"
57 #include "../../Restriction4SimpleType.h"
58 #include "../../Selector.h"
59 #include "../../SimpleContent.h"
60 #include "../../SimpleType.h"
61 #include "../../Schema.h"
62 #include "../../Sequence.h"
63 #include "../../Union.h"
64 #include "../../Unique.h"
73 #include <boost/format.hpp>
82 std::auto_ptr<All> all(
new All);
104 return all.release();
116 std::auto_ptr<Annotation> annotation(
new Annotation());
135 if(pos != std::string::npos)
144 annotation->add(appinfo);
154 if(tag ==
"documentation")
161 if(pos != std::string::npos)
166 if(pos != std::string::npos)
175 annotation->add(doc);
187 return annotation.release();
199 std::auto_ptr<Any> any(
new Any);
210 if(pos != std::string::npos)
211 any->setNamespace(
new std::string(reader.
getAttr(pos)));
216 if(pos != std::string::npos)
218 std::string value = reader.
getAttr(pos);
221 any->setProcessContents(pc);
234 return any.release();
253 if(pos != std::string::npos)
254 anyAttribute->setNamespace(
new std::string(reader.
getAttr(pos)));
258 if(pos != std::string::npos)
260 std::string value = reader.
getAttr(pos);
263 anyAttribute->setProcessContents(pc);
276 return anyAttribute.release();
295 if(pos != std::string::npos)
296 attribute->setDefault(
new std::string(reader.
getAttr(pos)));
300 if(pos != std::string::npos)
301 attribute->setFixed(
new std::string(reader.
getAttr(pos)));
305 if(pos != std::string::npos)
310 if(pos != std::string::npos)
311 attribute->setName(
new std::string(reader.
getAttr(pos)));
315 if(pos != std::string::npos)
320 if(pos != std::string::npos)
325 if(pos != std::string::npos)
327 std::string value = reader.
getAttr(pos);
330 attribute->setUse(use);
347 return attribute.release();
366 if(pos != std::string::npos)
367 attributeGroup->setName(
new std::string(reader.
getAttr(pos)));
371 if(pos != std::string::npos)
381 std::set<std::string> children;
382 children.insert(
"attribute");
383 children.insert(
"attributeGroup");
385 std::set<std::string>::iterator it;
389 std::string tag = *it;
390 if(tag ==
"attribute")
406 return attributeGroup.release();
433 std::set<std::string> children;
434 children.insert(
"element");
435 children.insert(
"group");
436 children.insert(
"choice");
437 children.insert(
"sequence");
438 children.insert(
"any");
440 std::set<std::string>::iterator it;
444 std::string tag = *it;
463 if(tag ==
"sequence")
470 choice->addAny(
ReadAny(reader));
476 return choice.release();
495 if(pos != std::string::npos)
496 cc->setAsMixed(reader.
getAttr(pos) ==
"true" ?
true :
false);
537 if(pos != std::string::npos)
538 ct->setName(
new std::string(reader.
getAttr(pos)));
542 if(pos != std::string::npos)
543 ct->setAsAbstract(reader.
getAttr(pos) ==
"true" ?
true :
false);
547 if(pos != std::string::npos)
548 ct->setAsMixed(reader.
getAttr(pos) ==
"true" ?
true :
false);
560 std::set<std::string> children;
561 children.insert(
"simpleContent");
562 children.insert(
"complexContent");
563 children.insert(
"group");
564 children.insert(
"all");
565 children.insert(
"choice");
566 children.insert(
"sequence");
567 children.insert(
"attribute");
568 children.insert(
"attributeGroup");
569 children.insert(
"anyAttribute");
571 std::set<std::string>::iterator it;
575 std::string tag = *it;
576 if(tag ==
"simpleContent")
582 if(tag ==
"complexContent")
596 ct->setContent(
ReadAll(reader));
606 if(tag ==
"sequence")
612 if(tag ==
"attribute")
618 if(tag ==
"attributeGroup")
624 if(tag ==
"anyAttribute")
650 if(pos != std::string::npos)
651 element->setName(
new std::string(reader.
getAttr(pos)));
655 if(pos != std::string::npos)
660 if(pos != std::string::npos)
665 if(pos != std::string::npos)
670 if(pos != std::string::npos)
671 element->setDefaultValue(
new std::string(reader.
getAttr(pos)));
675 if(pos != std::string::npos)
676 element->setFixedValue(
new std::string(reader.
getAttr(pos)));
683 if(pos != std::string::npos)
684 element->setAsNillable(reader.
getAttr(pos) ==
"true" ?
true :
false);
688 if(pos != std::string::npos)
689 element->setAsAbstract(reader.
getAttr(pos) ==
"true" ?
true :
false);
704 std::set<std::string> children;
705 children.insert(
"unique");
706 children.insert(
"key");
707 children.insert(
"keyref");
709 std::set<std::string>::iterator it;
713 std::string tag = *it;
716 element->addIdentityConstraint(
ReadUnique(reader));
722 element->addIdentityConstraint(
ReadKey(reader));
727 element->addIdentityConstraint(
ReadKeyRef(reader));
733 return element.release();
752 if(pos != std::string::npos)
763 std::set<std::string> children;
764 children.insert(
"group");
765 children.insert(
"all");
766 children.insert(
"choice");
767 children.insert(
"sequence");
768 children.insert(
"attribute");
769 children.insert(
"attributeGroup");
770 children.insert(
"anyAttribute");
772 std::set<std::string>::iterator it;
776 std::string tag = *it;
779 extension->setContent(
ReadGroup(reader));
785 extension->setContent(
ReadAll(reader));
795 if(tag ==
"sequence")
801 if(tag ==
"attribute")
807 if(tag ==
"attributeGroup")
813 if(tag ==
"anyAttribute")
820 return extension.release();
839 assert(pos != std::string::npos);
840 field->setXPath(
new std::string(reader.
getAttr(pos)));
852 return field.release();
871 if(pos != std::string::npos)
872 group->setName(
new std::string(reader.
getAttr(pos)));
876 if(pos != std::string::npos)
890 group->setContent(
ReadAll(reader));
900 return group.release();
919 if(pos != std::string::npos)
920 import->setNamespace(
new std::string(reader.
getAttr(pos)));
924 if(pos != std::string::npos)
925 import->setSchemaLocation(
new std::string(reader.
getAttr(pos)));
935 return import.release();
954 if(pos != std::string::npos)
955 include->setSchemaLocation(reader.
getAttr(pos));
965 return include.release();
984 assert(pos != std::string::npos);
985 key->setName(
new std::string(reader.
getAttr(pos)));
998 return key.release();
1008 return key.release();
1027 assert(pos != std::string::npos);
1028 keyRef->setName(
new std::string(reader.
getAttr(pos)));
1032 assert(pos != std::string::npos);
1046 return keyRef.release();
1056 return keyRef.release();
1075 if(pos != std::string::npos)
1092 return list.release();
1111 if(pos != std::string::npos)
1112 redefine->setSchemaLocation(reader.
getAttr(pos));
1118 std::set<std::string> children;
1119 children.insert(
"annotation");
1120 children.insert(
"simpleType");
1121 children.insert(
"complexType");
1122 children.insert(
"group");
1123 children.insert(
"attributeGroup");
1125 std::set<std::string>::iterator it;
1129 std::string tag = *it;
1130 if(tag ==
"annotation")
1136 if(tag ==
"simpleType")
1142 if(tag ==
"complexType")
1154 if(tag ==
"attributeGroup")
1161 return redefine.release();
1180 if(pos != std::string::npos)
1188 std::set<std::string> children;
1189 children.insert(
"group");
1190 children.insert(
"all");
1191 children.insert(
"choice");
1192 children.insert(
"sequence");
1193 children.insert(
"attribute");
1194 children.insert(
"attributeGroup");
1195 children.insert(
"anyAttribute");
1200 std::set<std::string>::iterator it;
1204 std::string tag = *it;
1208 restriction->setContent(
ReadGroup(reader));
1214 restriction->setContent(
ReadAll(reader));
1224 if(tag ==
"sequence")
1230 if(tag ==
"attribute")
1236 if(tag ==
"attributeGroup")
1242 if(tag ==
"anyAttribute")
1249 return restriction.release();
1268 if(pos != std::string::npos)
1278 std::set<std::string> children;
1279 children.insert(
"minExclusive");
1280 children.insert(
"minInclusive");
1281 children.insert(
"maxExclusive");
1282 children.insert(
"maxInclusive");
1283 children.insert(
"totalDigits");
1284 children.insert(
"fractionDigits");
1285 children.insert(
"length");
1286 children.insert(
"minLength");
1287 children.insert(
"maxLength");
1288 children.insert(
"enumeration");
1289 children.insert(
"whiteSpace");
1290 children.insert(
"pattern");
1291 children.insert(
"attribute");
1292 children.insert(
"attributeGroup");
1293 children.insert(
"anyAttribute");
1302 std::set<std::string>::iterator it;
1306 std::string tag = *it;
1308 if(tag ==
"attribute")
1314 if(tag ==
"attributeGroup")
1320 if(tag ==
"anyAttribute")
1328 assert(pos != std::string::npos);
1340 return restriction.release();
1359 if(pos != std::string::npos)
1367 std::set<std::string> children;
1368 children.insert(
"minExclusive");
1369 children.insert(
"minInclusive");
1370 children.insert(
"maxExclusive");
1371 children.insert(
"maxInclusive");
1372 children.insert(
"totalDigits");
1373 children.insert(
"fractionDigits");
1374 children.insert(
"length");
1375 children.insert(
"minLength");
1376 children.insert(
"maxLength");
1377 children.insert(
"enumeration");
1378 children.insert(
"whiteSpace");
1379 children.insert(
"pattern");
1388 std::set<std::string>::iterator it;
1394 assert(pos != std::string::npos);
1406 return restriction.release();
1416 reader->setValidationScheme(
false);
1417 reader->setIgnoreWhiteSpaces(
true);
1421 throw Exception((boost::format(
TE_TR(
"Could not read the XSD Schema in file: %1%.")) % path).str());
1424 throw Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % path).str());
1438 for(std::size_t i = 0; i < numberOfNamespaces; ++i)
1440 std::pair<std::string, std::string> ns;
1442 schema->getNamespaces().insert(boost::bimap<std::string, std::string>::value_type(ns.first, ns.second));
1450 if(pos != std::string::npos)
1455 if(pos != std::string::npos)
1462 if(pos != std::string::npos)
1463 schema->setTargetNamespace(reader.
getAttr(pos));
1467 if(pos != std::string::npos)
1468 schema->setVersion(reader.
getAttr(pos));
1477 std::set<std::string> children;
1478 children.insert(
"include");
1479 children.insert(
"import");
1480 children.insert(
"redefine");
1481 children.insert(
"annotation");
1482 children.insert(
"simpleType");
1483 children.insert(
"complexType");
1484 children.insert(
"group");
1485 children.insert(
"attributeGroup");
1486 children.insert(
"element");
1487 children.insert(
"attribute");
1488 children.insert(
"notation");
1490 std::set<std::string>::iterator it;
1494 std::string tag = *it;
1495 if(tag ==
"include")
1507 if(tag ==
"redefine")
1513 if(tag ==
"annotation")
1519 if(tag ==
"simpleType")
1525 if(tag ==
"complexType")
1537 if(tag ==
"attributeGroup")
1543 if(tag ==
"element")
1549 if(tag ==
"attribute")
1555 return schema.release();
1574 assert(pos != std::string::npos);
1575 selector->setXPath(
new std::string(reader.
getAttr(pos)));
1587 return selector.release();
1614 std::set<std::string> children;
1615 children.insert(
"element");
1616 children.insert(
"group");
1617 children.insert(
"choice");
1618 children.insert(
"sequence");
1619 children.insert(
"any");
1621 std::set<std::string>::iterator it;
1625 std::string tag = *it;
1626 if(tag ==
"element")
1634 sequence->addContent(
ReadGroup(reader));
1644 if(tag ==
"sequence")
1651 sequence->addAny(
ReadAny(reader));
1657 return sequence.release();
1690 return sc.release();
1709 if(pos != std::string::npos)
1710 st->setName(
new std::string(reader.
getAttr(pos)));
1722 st->setConstructor(
ReadList(reader));
1730 return st.release();
1749 if(pos != std::string::npos)
1751 std::string value = reader.
getAttr(pos);
1752 std::vector<std::string> tokens;
1754 for(std::size_t i = 0; i < tokens.size(); ++i)
1791 assert(pos != std::string::npos);
1792 unique->setName(
new std::string(reader.
getAttr(pos)));
1805 return unique.release();
1815 return unique.release();
1824 assert(identifiable);
1827 if(pos != std::string::npos)
1828 identifiable->
setId(
new std::string(reader.
getAttr(pos)));
1849 if(pos != std::string::npos)
1854 if(pos != std::string::npos)
1860 std::vector<std::string> tokens;
1862 assert(tokens.size() >= 2);
1869 if(name ==
"minExclusive")
1871 if(name ==
"minInclusive")
1873 if(name ==
"maxExclusive")
1875 if(name ==
"maxInclusive")
1877 if(name ==
"totalDigits")
1879 if(name ==
"fractionDigits")
1881 if(name ==
"length")
1883 if(name ==
"minLength")
1885 if(name ==
"maxLength")
1887 if(name ==
"enumeration")
1889 if(name ==
"whiteSpace")
void setId(std::string *id)
it sets the id.
Specifies the lower bounds for numeric values. (>=)
TEXSDEXPORT void Save(All *all, te::xml::AbstractWriter &writer)
TEXSDEXPORT Element * ReadElement(te::xml::Reader &reader)
virtual std::size_t getAttrPosition(const std::string &name) const =0
It returns the attribute position.
TEXSDEXPORT AttributeGroup * ReadAttributeGroup(te::xml::Reader &reader)
AttributeUse
It specifies how the attribute is used.
TEXSDEXPORT Include * ReadInclude(te::xml::Reader &reader)
It models an XML Schema complexContent element.
Specifies the maximum number of characters or list items allowed.
static const unsigned int unbounded
Identifer for "unbounded" max values.
This class models a XML reader object.
TEXSDEXPORT Extension * ReadExtension(te::xml::Reader &reader)
This class models an object that specifies information to be used by applications.
void ReadOccurs(Occurs *occurs, te::xml::Reader &reader)
This class models an XML Schema all element.
A base class for XSD classes that may allow annotation.
TEXSDEXPORT AnyAttribute * ReadAnyAttribute(te::xml::Reader &reader)
A base class for XSD classes that have occurs attributes.
TEXSDEXPORT Unique * ReadUnique(te::xml::Reader &reader)
The restriction class can be used to define restrictions on a complexContent.
TEXSDEXPORT ComplexContent * ReadComplexContent(te::xml::Reader &reader)
A class that models a XML schema (XSD).
TEXSDEXPORT Group * ReadGroup(te::xml::Reader &reader)
virtual void getNamespace(std::size_t i, std::pair< std::string, std::string > &ns) const =0
TEXSDEXPORT Sequence * ReadSequence(te::xml::Reader &reader)
It models a XML Schema import.
Defines the exact sequence of characters that are acceptable.
TEXSDEXPORT List * ReadList(te::xml::Reader &reader)
This class models the element of a XML Schema.
TEXSDEXPORT Any * ReadAny(te::xml::Reader &reader)
Specifies the exact number of characters or list items allowed.
It models a XML Schema include.
This class models a sequence element in a XML Schema.
TEXSDEXPORT Field * ReadField(te::xml::Reader &reader)
void setMinOccurs(unsigned int minOccurs)
It sets the minOccurs value.
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
TEXSDEXPORT SimpleType * ReadSimpleType(te::xml::Reader &reader)
This class models a XML writer object.
TEXSDEXPORT Restriction4SimpleContent * ReadRestriction4SimpleContent(te::xml::Reader &reader)
#define TE_TR(message)
It marks a string in order to get translated.
void setSource(std::string *source)
It sets the URI reference that specifies the source of the information.
It indicates that the attribute use is required.
It models the unique element in an XML Schema.
The XML processor does not attempt to validate any elements from the specified namespaces.
It models the XML Schema any element.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
virtual boost::int32_t getAttrAsInt32(const std::string &name) const
It returns the attribute value in the case of an element node with valid attributes.
void setMaxOccurs(unsigned int maxOccurs)
It sets the maxOccurs value.
void setLang(std::string *lang)
It sets the language of the information.
It indicates that the attribute attribute must be qualified with the namespace prefix and the no-colo...
It models a XML Schema redefine.
It is used to define a simple type element as a list of values.
TEXSDEXPORT Restriction4ComplexContent * ReadRestriction4ComplexContent(te::xml::Reader &reader)
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Specifies the upper bounds for numeric values. (<)
TEXSDEXPORT Schema * ReadSchema(const std::string &path)
This class models a key element from an XML Schema.
It models an XML anyAttribute element.
This restriction class defines restrictions on a simpleContent.
TEXSDEXPORT Redefine * ReadRedefine(te::xml::Reader &reader)
A class that models a documentation element used to enter text comments in annotations.
void setValue(std::string *doc)
It sets the information associated to the annotation.
It models a XML Schema Complex Type definition.
void ReadIdentifiable(Identifiable *identifiable, te::xml::Reader &reader)
A base class for XSD classes that must provide a unique ID property.
This class models the XML Schema choice element.
It models a XML Schema attribute.
ProcessContents
It enumerates the possible ways that the XML processor should handle validation against the elements ...
QName * CreateQName(const std::string &name)
Specifies the minimum number of characters or list items allowed.
It models the field element of an XML Schema.
It indicates that the attribute cannot be used.
It indicates that the attribute use is optional. This is the default.
TEXSDEXPORT Selector * ReadSelector(te::xml::Reader &reader)
void ReadAnnotated(Annotated *annotated, te::xml::Reader &reader)
TEXSDEXPORT Key * ReadKey(te::xml::Reader &reader)
It models the selector element of an XML Schema.
Specifies the lower bounds for numeric values. (>)
void setAnnotation(Annotation *ann)
It sets the associated annotation.
virtual std::size_t getNumberOfNamespaces() const =0
virtual std::string getAttr(const std::string &name) const =0
It returns the attribute value in the case of an element node with valid attributes.
The XML processor must obtain the schema for the required namespaces and validate the elements (this ...
Specifies how white space (line feeds, tabs, spaces and carriage returns) is handled.
TEXSDEXPORT Import * ReadImport(te::xml::Reader &reader)
void setValue(std::string *value)
It sets the information to be used by the application.
Specifies the maximum number of digits allowed.
Same as strict but; if the schema cannot be obtained, no errors will occur.
TEXSDEXPORT Attribute * ReadAttribute(te::xml::Reader &reader)
TEXSDEXPORT All * ReadAll(te::xml::Reader &reader)
This class models an extension element that can be used to extend an existing simpleType or complexTy...
TEXSDEXPORT Choice * ReadChoice(te::xml::Reader &reader)
A class to be used to represent XML qualified names.
virtual NodeType getNodeType() const =0
It return the type of node read.
This class models a keyref element from a XML Schema element.
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
Specifies the upper bounds for numeric values. (<=)
A class that models an XML Schema simpleContent element.
It defines a simple type as a collection (union) of values from specified simple data types...
It indicates that the attribute attribute is not required to be qualified with the namespace prefix a...
FacetType
It enumerates the available facet types.
The restriction element defines restrictions on a simpleType definition.
void setSource(std::string *source)
It sets the URI that specifies the source of the information.
TEXSDEXPORT SimpleContent * ReadSimpleContent(te::xml::Reader &reader)
TEXSDEXPORT ComplexType * ReadComplexType(te::xml::Reader &reader)
TEXSDEXPORT Union * ReadUnion(te::xml::Reader &reader)
A class that models a XSD annotation element.
TEXSDEXPORT Restriction4SimpleType * ReadRestriction4SimpleType(te::xml::Reader &reader)
virtual bool next()=0
It gets the next event to be read.
It models a XML Schema SimpleType element.
TEXSDEXPORT KeyRef * ReadKeyRef(te::xml::Reader &reader)
FacetType GetFacetType(const std::string &name)
Defines a list of acceptable values.
This class models a group element in a XML Schema.
TEXSDEXPORT Annotation * ReadAnnotation(te::xml::Reader &reader)
Specifies the maximum number of decimal places allowed.