27 #include "../../xml/Reader.h"
28 #include "../../xml/ReaderFactory.h"
29 #include "../../xml/Writer.h"
30 #include "../../xsd/Attribute.h"
31 #include "../../xsd/Schema.h"
32 #include "../Exception.h"
52 #include <boost/format.hpp>
57 reader->setValidationScheme(
false);
58 reader->setIgnoreWhiteSpaces(
true);
62 throw Exception((boost::format(
TR_SERIALIZATION(
"Could not read the XSD Schema in file: %1%.")) % path).str());
65 throw Exception((boost::format(
TR_SERIALIZATION(
"Error reading the document %1%, the start element wasn't found.")) % path).str());
79 for(std::size_t i = 0; i < numberOfNamespaces; ++i)
81 std::pair<std::string, std::string> ns;
83 schema->getNamespaces().insert(boost::bimap<std::string, std::string>::value_type(ns.first, ns.second));
91 if(pos != std::string::npos)
96 if(pos != std::string::npos)
103 if(pos != std::string::npos)
104 schema->setTargetNamespace(reader.
getAttr(pos));
108 if(pos != std::string::npos)
109 schema->setVersion(reader.
getAttr(pos));
118 std::set<std::string> children;
119 children.insert(
"include");
120 children.insert(
"import");
121 children.insert(
"redefine");
122 children.insert(
"annotation");
123 children.insert(
"simpleType");
124 children.insert(
"complexType");
125 children.insert(
"group");
126 children.insert(
"attributeGroup");
127 children.insert(
"element");
128 children.insert(
"attribute");
129 children.insert(
"notation");
131 std::set<std::string>::iterator it;
135 std::string tag = *it;
148 if(tag ==
"redefine")
154 if(tag ==
"annotation")
160 if(tag ==
"simpleType")
166 if(tag ==
"complexType")
178 if(tag ==
"attributeGroup")
190 if(tag ==
"attribute")
196 return schema.release();
It indicates that the attribute attribute is not required to be qualified with the namespace prefix a...
It indicates that the attribute attribute must be qualified with the namespace prefix and the no-colo...
Support for Schema serialization.
This class models a XML reader object.
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
virtual bool next()=0
It gets the next event to be read.
#define TR_SERIALIZATION(message)
It marks a string in order to get translated. This is a special mark used in the XML module of TerraL...
TESERIALIZATIONEXPORT te::xsd::Annotation * ReadAnnotation(te::xml::Reader &reader)
TESERIALIZATIONEXPORT te::xsd::Element * ReadElement(te::xml::Reader &reader)
TESERIALIZATIONEXPORT te::xsd::Group * ReadGroup(te::xml::Reader &reader)
TESERIALIZATIONEXPORT void Save(const te::fe::Filter *filter, te::xml::Writer &writer)
void ReadIdentifiable(te::xsd::Identifiable *identifiable, te::xml::Reader &reader)
Support for Include serialization.
A class that models a XML schema (XSD).
TESERIALIZATIONEXPORT te::xsd::Schema * ReadSchema(const std::string &path)
Support for Attribute serialization.
Support for Annotation serialization.
TESERIALIZATIONEXPORT te::xsd::Redefine * ReadRedefine(te::xml::Reader &reader)
Support for SimpleType serialization.
TESERIALIZATIONEXPORT te::xsd::Include * ReadInclude(te::xml::Reader &reader)
TESERIALIZATIONEXPORT te::xsd::Attribute * ReadAttribute(te::xml::Reader &reader)
TESERIALIZATIONEXPORT te::xsd::ComplexType * ReadComplexType(te::xml::Reader &reader)
TESERIALIZATIONEXPORT te::xsd::Import * ReadImport(te::xml::Reader &reader)
Utility methods for Schema serialization.
Support for Import serialization.
Support for ComplexType serialization.
virtual NodeType getNodeType() const =0
It return the type of node read.
TESERIALIZATIONEXPORT te::xsd::AttributeGroup * ReadAttributeGroup(te::xml::Reader &reader)
virtual std::size_t getNumberOfNamespaces() const =0
Support for AttributeGroup serialization.
Support for Element serialization.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
TESERIALIZATIONEXPORT te::xsd::SimpleType * ReadSimpleType(te::xml::Reader &reader)
virtual std::size_t getAttrPosition(const std::string &name) const =0
It returns the attribute position.
Support for Redefine serialization.
virtual void getNamespace(std::size_t i, std::pair< std::string, std::string > &ns) const =0
Support for Group serialization.
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.
This class models a XML writer object.