wsdlpull svntrunk
Classes | Public Types | List of all members
Schema::SchemaParser Class Reference

#include <SchemaParser.h>

Classes

struct  ImportedSchema
 

Public Types

typedef std::list< ElementElementList
 
typedef std::list< AttributeAttributeList
 
typedef std::list< GroupGroupList
 
typedef std::list< AttributeGroup * > AttributeGroupList
 
typedef std::list< Constraint * > ConstraintList
 
typedef std::list< QnameQNameList
 
typedef std::list< const XSDType * > ConstTypeList
 

Public Member Functions

Constructors and Destructors
 SchemaParser (const std::string &Uri, std::string tns="", std::ostream &log=std::cout, const std::string &confPath="")
 
 SchemaParser (XmlPullParser *parser, std::string tns="", std::ostream &log=std::cout, const std::string &confPath="")
 
 ~SchemaParser ()
 
methods used for parsing
bool parseSchemaTag ()
 
Various Getter methods
const XSDTypegetType (const Qname &type, bool checkImports=true)
 
const XSDTypegetType (int id) const
 
const XSDTypegetType (int id, std::string &nameSpace)
 
ConstTypeListgetAllTypes () const
 
const ElementgetElement (const Qname &element, bool checkImports=true) const
 
const ElementListgetElements () const
 
int getNumElements () const
 
AttributegetAttribute (const Qname &attribute)
 
const AttributeListgetAttributes () const
 
int getNumAttributes () const
 
std::string getNamespace (void) const
 
int getNumTypes () const
 
int getTypeId (const Qname &, bool create=false)
 
bool isBasicType (int sType) const
 
int getBasicContentType (int typeId) const
 
GroupgetGroup (const Qname &name)
 
AttributeGroupgetAttributeGroup (const Qname &name)
 
Methods for handling Imports
bool isImported (const std::string &ns) const
 
const SchemaParsergetImportedSchemaParser (const std::string &ns) const
 
bool addImport (std::string ns, std::string location="")
 
bool addImport (SchemaParser *sp)
 
bool addImports (const std::vector< SchemaParser * > &schemaParsers)
 

Miscellaneous Methods

bool finalize (void)
 
void setWarningLevel (int l)
 
void setSchemaPath (const std::string &s)
 
void setUri (const std::string &u)
 
std::string getTypeName (Schema::Type t) const
 
TypesTablegetTypesTable ()
 
const SchemaParsergetImportedSchema (std::string &nameSpace)
 
std::vector< ImportedSchema > & getImportedSchemas ()
 
std::string getVersion () const
 
bool getElementQualified () const
 
std::string getTnsPrefix (void) const
 

Detailed Description

Definition at line 42 of file SchemaParser.h.

Member Typedef Documentation

◆ ElementList

typedefs

Definition at line 50 of file SchemaParser.h.

◆ AttributeList

Definition at line 51 of file SchemaParser.h.

◆ GroupList

Definition at line 52 of file SchemaParser.h.

◆ AttributeGroupList

Definition at line 53 of file SchemaParser.h.

◆ ConstraintList

Definition at line 54 of file SchemaParser.h.

◆ QNameList

Definition at line 55 of file SchemaParser.h.

◆ ConstTypeList

typedef std::list< const XSDType *> Schema::SchemaParser::ConstTypeList

Definition at line 56 of file SchemaParser.h.

Constructor & Destructor Documentation

◆ SchemaParser() [1/2]

Schema::SchemaParser::SchemaParser ( const std::string &  Uri,
std::string  tns = "",
std::ostream &  log = std::cout,
const std::string &  confPath = "" 
)

The constructor for SchemaParser

Parameters
theURI schema definition file.
targetnamespace
outputstream for any error outputs
confPathThe path where schema files for soap and other namespaces are located. This is required only if you have stored them other than src/schemas on windows. On *nix it is almost never required if you install using the make install

Definition at line 49 of file SchemaParser.cpp.

References XmlPullParser::END_DOCUMENT, FEATURE_PROCESS_NAMESPACES, XmlUtils::fetchUri(), XmlPullParser::getEventType(), XmlPullParser::getName(), XmlPullParser::nextTag(), XmlPullParser::require(), XmlPullParser::setFeature(), XmlPullParser::START_DOCUMENT, and XmlPullParser::START_TAG.

Referenced by addImport().

◆ SchemaParser() [2/2]

Schema::SchemaParser::SchemaParser ( XmlPullParser parser,
std::string  tns = "",
std::ostream &  log = std::cout,
const std::string &  confPath = "" 
)

The constructor for SchemaParser

Parameters
XmlPullParserinstance for the schema definition file.
targetnamespace
outputstream for any error outputs
confPathThe path where schema files for soap and other namespaces are located. This is required only if you have stored them other than src/schemas on windows. On *nix it is almost never required if you install using the make install

Definition at line 32 of file SchemaParser.cpp.

◆ ~SchemaParser()

Schema::SchemaParser::~SchemaParser ( )

The constructor for SchemaParser

Parameters
theURI schema definition file.
targetnamespace
outputstream for any error outputs
confPathThe path where schema files for soap and other namespaces are located. This is required only if you have stored them other than src/schemas on windows. On *nix it is almost never required if you install using the make install

Definition at line 122 of file SchemaParser.cpp.

References Schema::TypesTable::clean().

Member Function Documentation

◆ parseSchemaTag()

bool Schema::SchemaParser::parseSchemaTag ( )

◆ getType() [1/3]

const XSDType * Schema::SchemaParser::getType ( const Qname type,
bool  checkImports = true 
)

◆ getType() [2/3]

const XSDType * Schema::SchemaParser::getType ( int  id) const
Parameters
thetypes unique id
Returns
pointer to the type

Definition at line 1899 of file SchemaParser.cpp.

References Schema::TypesTable::getTypePtr().

◆ getType() [3/3]

const XSDType * Schema::SchemaParser::getType ( int  id,
std::string &  nameSpace 
)
Parameters
thetypes unique id
thenamespace of the type
Returns
pointer to the type

Definition at line 1927 of file SchemaParser.cpp.

References getImportedSchema(), and getType().

◆ getAllTypes()

list< const XSDType * > * Schema::SchemaParser::getAllTypes ( ) const
Returns
a std::list of all types defined in the schema including anonymous types caller MUST free the std::list but not the std::list members

Definition at line 1959 of file SchemaParser.cpp.

References getNumTypes(), getType(), and Schema::XSD_ANYURI.

◆ getElement()

const Element * Schema::SchemaParser::getElement ( const Qname element,
bool  checkImports = true 
) const
Parameters
Qnameof the element
Returns
pointer to a globally defined element in the schema @checkImports set this to false to search for elements defined in this schema

Definition at line 1761 of file SchemaParser.cpp.

References Qname::getLocalName(), Qname::getNamespace(), and Schema::SchemaUri.

Referenced by WsdlPull::Soap::handleElement(), WsdlPull::Soap::isSoapBody(), WsdlPull::Soap::isSoapHeader(), and main().

◆ getElements()

const SchemaParser::ElementList & Schema::SchemaParser::getElements ( ) const
inline

returns the std::list of all the global elements in the schema

Parameters
void
Returns
std::list<Element>

Definition at line 403 of file SchemaParser.h.

Referenced by main().

◆ getNumElements()

int Schema::SchemaParser::getNumElements ( ) const
Returns
number of globally defined elements in the schema

Definition at line 1979 of file SchemaParser.cpp.

◆ getAttribute()

Attribute * Schema::SchemaParser::getAttribute ( const Qname attribute)

getAttribute

Parameters
Qnameof the attribute
Returns
pointer to a globally defined attribute in the schema

Definition at line 1795 of file SchemaParser.cpp.

References Qname::getLocalName(), Qname::getNamespace(), and Schema::SchemaUri.

◆ getAttributes()

const SchemaParser::AttributeList & Schema::SchemaParser::getAttributes ( ) const
inline

returns a std::list of global attributes in the schema

Parameters
void
Returns
std::list<Attribute>

Definition at line 410 of file SchemaParser.h.

◆ getNumAttributes()

int Schema::SchemaParser::getNumAttributes ( ) const
Returns
number of globally defined attributes in the schema

Definition at line 1986 of file SchemaParser.cpp.

◆ getNamespace()

std::string Schema::SchemaParser::getNamespace ( void  ) const
Returns
target namespace of the schema document

Definition at line 1892 of file SchemaParser.cpp.

Referenced by addImport(), addImports(), Schema::SchemaValidator::instance(), main(), and Schema::SchemaValidator::validate().

◆ getNumTypes()

int Schema::SchemaParser::getNumTypes ( ) const
Returns
number of types defined in the schema (includes anonymous types)

Definition at line 1972 of file SchemaParser.cpp.

References Schema::TypesTable::getNumTypes().

Referenced by getAllTypes().

◆ getTypeId()

int Schema::SchemaParser::getTypeId ( const Qname type,
bool  create = false 
)

getTypeId :Search for a type ,if not present create one,checks in imported types as well

Parameters
Qnameof the type
bool:create
Returns
type id

Definition at line 1617 of file SchemaParser.cpp.

References Schema::TypesTable::addExternalTypeId(), addImport(), Qname::getNamespace(), Schema::TypesTable::getTypeId(), Schema::SchemaUri, and Schema::XSD_INVALID.

Referenced by getType(), and main().

◆ isBasicType()

bool Schema::SchemaParser::isBasicType ( int  sType) const

isBasicType

Parameters
uniquetype identifier
Returns
true if its a basic schema type false otherwise

Definition at line 1599 of file SchemaParser.cpp.

References Schema::XSD_ANYURI, and Schema::XSD_INVALID.

Referenced by getTypeName(), Schema::TypeContainer::getValue(), Schema::TypeContainer::rewind(), and Schema::SchemaValidator::validate().

◆ getBasicContentType()

int Schema::SchemaParser::getBasicContentType ( int  typeId) const

getBasicContentType

If the type has a simple content model then this method returns the basic schema type which defines its contents For example calling on a type like below would return Schema::STRING

<xsd:complexType> <xsd:simpleContent> <xsd:extension base = "xsd:std::string"> <xsd:attribute name = "lang" type = "xsd:std::string"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType>

Parameters
uniquetype identifier
Returns
type id of the basic type from which this type is derived or if the typeId is one of the atomic types,the same value is returned If the typeId is a complex type Schema::XSD_INVALID is returned

Definition at line 2114 of file SchemaParser.cpp.

References getBasicContentType(), Schema::XSDType::getContentModel(), Schema::ComplexType::getContentType(), getType(), Schema::XSDType::isSimple(), Schema::Simple, and Schema::XSD_INVALID.

Referenced by getBasicContentType(), Schema::TypeContainer::getValue(), Schema::TypeContainer::print(), Schema::TypeContainer::rewind(), and Schema::SchemaValidator::validate().

◆ getGroup()

Group * Schema::SchemaParser::getGroup ( const Qname name)

getGroup

Parameters
uniquetype identifier
Returns
Group*

Definition at line 1826 of file SchemaParser.cpp.

References Qname::getLocalName(), Qname::getNamespace(), and Schema::SchemaUri.

◆ getAttributeGroup()

AttributeGroup * Schema::SchemaParser::getAttributeGroup ( const Qname name)

getAttributeGroup

Parameters
uniquetype identifier
Returns
AttributeGroup*

Definition at line 1859 of file SchemaParser.cpp.

References Qname::getLocalName(), Qname::getNamespace(), and Schema::SchemaUri.

◆ isImported()

bool Schema::SchemaParser::isImported ( const std::string &  ns) const
inline

isImported true if the schema parser imports a namespace

Definition at line 423 of file SchemaParser.h.

Referenced by Schema::SchemaValidator::validate().

◆ getImportedSchemaParser()

const SchemaParser * Schema::SchemaParser::getImportedSchemaParser ( const std::string &  ns) const
inline

isImported true if the schema parser imports a namespace

Definition at line 429 of file SchemaParser.h.

Referenced by Schema::SchemaValidator::validate().

◆ addImport() [1/2]

bool Schema::SchemaParser::addImport ( std::string  ns,
std::string  location = "" 
)

addImport .Instructs the schema parser to import a namespace

Parameters
namespaceof the schema
(optional)schemaLocation.If this is not passed ,schema file is not processed but any refernces to the namespace are not flagged as errors
Returns
true if the schema was succesfully imported.If location is not passed always returns true

Definition at line 2048 of file SchemaParser.cpp.

References XmlUtils::fetchUri(), Schema::SchemaParser::ImportedSchema::ns, parseSchemaTag(), SchemaParser(), setUri(), and Schema::SchemaParser::ImportedSchema::sParser.

Referenced by addImports(), and getTypeId().

◆ addImport() [2/2]

bool Schema::SchemaParser::addImport ( SchemaParser sp)

addImport . imports the namespace of the schemaparser

Parameters
SchemaParserinstance which has parsed the namespace
Returns
true if the schema was succesfully imported .

Definition at line 2006 of file SchemaParser.cpp.

References getNamespace(), Schema::SchemaParser::ImportedSchema::ns, and Schema::SchemaParser::ImportedSchema::sParser.

◆ addImports()

bool Schema::SchemaParser::addImports ( const std::vector< SchemaParser * > &  schemaParsers)

isImported true if the schema parser imports a namespace

Definition at line 1993 of file SchemaParser.cpp.

References addImport(), and getNamespace().

◆ finalize()

bool Schema::SchemaParser::finalize ( void  )

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 1665 of file SchemaParser.cpp.

References Schema::TypesTable::addExtType(), Schema::TypesTable::detectUndefinedTypes(), Schema::TypesTable::getExtRefName(), Schema::TypesTable::getExtRefType(), Qname::getNamespace(), Schema::TypesTable::getNumExtRefs(), and Schema::TypesTable::printUndefinedTypes().

◆ setWarningLevel()

void Schema::SchemaParser::setWarningLevel ( int  l)
inline

setWarningLevel default is 0 . 1 is wanrning level 2 is information level //quite verbose

Definition at line 417 of file SchemaParser.h.

Referenced by main().

◆ setSchemaPath()

void Schema::SchemaParser::setSchemaPath ( const std::string &  s)
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 440 of file SchemaParser.h.

◆ setUri()

void Schema::SchemaParser::setUri ( const std::string &  u)
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 447 of file SchemaParser.h.

Referenced by addImport().

◆ getTypeName()

std::string Schema::SchemaParser::getTypeName ( Schema::Type  t) const

◆ getTypesTable()

TypesTable * Schema::SchemaParser::getTypesTable ( )
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 454 of file SchemaParser.h.

◆ getImportedSchema()

const SchemaParser * Schema::SchemaParser::getImportedSchema ( std::string &  nameSpace)

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 1941 of file SchemaParser.cpp.

References Schema::SchemaUri.

Referenced by getType().

◆ getImportedSchemas()

std::vector< SchemaParser::ImportedSchema > & Schema::SchemaParser::getImportedSchemas ( )
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 461 of file SchemaParser.h.

◆ getVersion()

std::string Schema::SchemaParser::getVersion ( ) const
inline

getVersion() return the schema version

Definition at line 468 of file SchemaParser.h.

◆ getElementQualified()

bool Schema::SchemaParser::getElementQualified ( ) const
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 475 of file SchemaParser.h.

◆ getTnsPrefix()

std::string Schema::SchemaParser::getTnsPrefix ( void  ) const
inline

finalize : tries to match unresolved types and references with imported schemas you must call this to ensure successful type resolution

Returns
true if all type references are resolved ,false otherwise

Definition at line 483 of file SchemaParser.h.


The documentation for this class was generated from the following files: