umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Member Functions | Private Member Functions | Private Attributes | List of all members
XMLSchemaWriter Class Reference

#include <xmlschemawriter.h>

Inheritance diagram for XMLSchemaWriter:
Collaboration diagram for XMLSchemaWriter:

Public Member Functions

 XMLSchemaWriter ()
 
virtual ~XMLSchemaWriter ()
 
virtual void writeClass (UMLClassifier *c)
 
virtual Uml::ProgrammingLanguage::Enum language () const
 
virtual QStringList reservedKeywords () const
 
- Public Member Functions inherited from SimpleCodeGenerator
 SimpleCodeGenerator (bool createDirHierarchyForPackages=true)
 
virtual ~SimpleCodeGenerator ()
 
void writeCodeToFile (UMLClassifierList &concepts)
 
void writeCodeToFile ()
 
- Public Member Functions inherited from CodeGenerator
 CodeGenerator ()
 
virtual ~CodeGenerator ()
 
bool addCodeDocument (CodeDocument *add_object)
 
bool removeCodeDocument (CodeDocument *remove_object)
 
CodeDocumentListgetCodeDocumentList ()
 
QString getUniqueID (CodeDocument *codeDoc)
 
virtual void saveToXMI (QXmlStreamWriter &writer)
 
CodeDocumentfindCodeDocumentByID (const QString &id)
 
void setIncludeHeadings (bool i)
 
bool includeHeadings () const
 
void setHeadingFileDir (const QString &)
 
QString headingFileDir () const
 
void setForceDoc (bool f)
 
bool forceDoc () const
 
void setForceSections (bool f)
 
bool forceSections () const
 
virtual QString getHeadingFile (const QString &file)
 
QString findFileName (CodeDocument *codeDocument)
 
virtual void loadFromXMI (QDomElement &element)
 
CodeDocumentfindCodeDocumentByClassifier (UMLClassifier *classifier)
 
virtual QStringList defaultDatatypes () const
 
virtual bool isReservedKeyword (const QString &keyword)
 
virtual void createDefaultStereotypes ()
 

Private Member Functions

void writeClassifier (UMLClassifier *c, QTextStream &XMLSchema)
 
void writeAbstractClassifier (UMLClassifier *c, QTextStream &XMLSchema)
 
void writeConcreteClassifier (UMLClassifier *c, QTextStream &XMLSchema)
 
void writeComplexTypeClassifierDecl (UMLClassifier *c, UMLAssociationList associations, UMLAssociationList aggregations, UMLAssociationList compositions, UMLClassifierList superclassifiers, QTextStream &XMLSchema)
 
void writeGroupClassifierDecl (UMLClassifier *c, UMLClassifierList superclassifiers, QTextStream &XMLSchema)
 
bool determineIfHasChildNodes (UMLClassifier *c)
 
void writeElementDecl (const QString &elementName, const QString &elementTypeName, QTextStream &xs)
 
void writeAttributeDecls (UMLAttributeList &attribs, QTextStream &xs)
 
void writeAttributeDecl (UMLAttribute *attrib, QTextStream &xs)
 
UMLAttributeList findAttributes (UMLClassifier *c)
 
QStringList findAttributeGroups (UMLClassifier *c)
 
bool writeAssociationDecls (UMLAssociationList associations, bool noRoleOK, bool didOne, Uml::ID::Type id, QTextStream &xs)
 
void writeAttributeGroupDecl (const QString &elementName, UMLAttributeList &attribs, QTextStream &xs)
 
void writeAssociationRoleDecl (UMLClassifier *c, const QString &multi, QTextStream &xs)
 
QString makeSchemaTag (QString tagName)
 
QString makePackageTag (QString tagName)
 
void writeComment (const QString &text, QTextStream &xs)
 
UMLObjectList findChildObjsInAssociations (UMLClassifier *c, UMLAssociationList associations)
 
QString fixTypeName (const QString &string)
 
QString fixInitialStringDeclValue (QString value, const QString &type)
 
QString getElementName (UMLClassifier *c)
 
QString getElementTypeName (UMLClassifier *c)
 
QString getElementGroupTypeName (UMLClassifier *c)
 
void writeChildObjsInAssociation (UMLClassifier *c, UMLAssociationList assoc, QTextStream &s)
 
bool hasBeenWritten (UMLClassifier *c)
 
void markAsWritten (UMLClassifier *c)
 

Private Attributes

QString schemaNamespaceTag
 basic schemaNamespace tag More...
 
QString packageNamespaceTag
 basic packageNamespace tag More...
 
QString schemaNamespaceURI
 basic schemaNamespace URI More...
 
QString packageNamespaceURI
 basic packageNamespace URI More...
 
QString startline
 a
, used at the end of each line More...
 
UMLClassifierList writtenClassifiers
 a list of UMLClassifiers we have already written More...
 

Additional Inherited Members

- Public Types inherited from CodeGenerator
enum  GenerationState { Generated , Failed , Skipped }
 
- Public Slots inherited from SimpleCodeGenerator
virtual void syncCodeToDocument ()
 
- Public Slots inherited from CodeGenerator
virtual void syncCodeToDocument ()
 
- Signals inherited from CodeGenerator
void codeGenerated (UMLClassifier *concept, bool generated)
 
void codeGenerated (UMLClassifier *concept, CodeGenerator::GenerationState result)
 
void showGeneratedFile (const QString &filename)
 
- Static Public Member Functions inherited from CodeGenerator
static QString cleanName (const QString &name)
 
static QString formatDoc (const QString &text, const QString &linePrefix=QLatin1String(" *"), int lineWidth=80)
 
static QString formatSourceCode (const QString &code, const QString &indentation)
 
static void findObjectsRelated (UMLClassifier *c, UMLPackageList &cList)
 
- Protected Member Functions inherited from SimpleCodeGenerator
QString findFileName (UMLPackage *concept, const QString &ext)
 
QString overwritableName (UMLPackage *concept, const QString &name, const QString &ext)
 
bool hasDefaultValueAttr (UMLClassifier *c)
 
bool hasAbstractOps (UMLClassifier *c)
 
QString indent ()
 
virtual void initFromParentDocument ()
 
- Protected Member Functions inherited from CodeGenerator
QString overwritableName (const QString &name, const QString &extension)
 
bool openFile (QFile &file, const QString &name)
 
void writeListedCodeDocsToFile (CodeDocumentList *docs)
 
virtual void finalizeRun ()
 
- Protected Attributes inherited from SimpleCodeGenerator
QString className_
 
QString fileName_
 
QMap< UMLPackage *, QString > m_fileMap
 
bool m_createDirHierarchyForPackages
 
QString m_indentation
 
int m_indentLevel
 
QString m_endl
 
- Protected Attributes inherited from CodeGenerator
QHash< QString, CodeDocument * > m_codeDocumentDictionary
 
bool m_applyToAllRemaining
 
UMLDocm_document
 

Detailed Description

Class XMLSchemaWriter is a code generator for UMLClassifier objects. Create an instance of this class, and feed it a UMLClassifier when calling writeClass and it will generate a XMLschema source file for that concept

Our basic approach is to map UMLClassifiers (classes/interfaces) into XML elements (or nodes). We declare these element in the schema either as complexType or as groups based on whether they are concrete or abstract in nature. This is not a perfect decision, but that's life with XML Schema... you cant fully represent Objects in the XML world ..yet. -b.t.

Constructor & Destructor Documentation

◆ XMLSchemaWriter()

XMLSchemaWriter::XMLSchemaWriter ( )

Constructor, initialises a couple of variables

◆ ~XMLSchemaWriter()

XMLSchemaWriter::~XMLSchemaWriter ( )
virtual

Destructor, empty.

Member Function Documentation

◆ determineIfHasChildNodes()

bool XMLSchemaWriter::determineIfHasChildNodes ( UMLClassifier c)
private

Find if the classifier would have any Child elements.

Here is the call graph for this function:

◆ findAttributeGroups()

QStringList XMLSchemaWriter::findAttributeGroups ( UMLClassifier c)
private

Discover the string name of all the attribute groups (which are child nodes) of this concept (err.. element). These exist for abstract classes only (which become xs:group nodes).

Here is the call graph for this function:

◆ findAttributes()

UMLAttributeList XMLSchemaWriter::findAttributes ( UMLClassifier c)
private

Find all attributes for this concept.

Here is the call graph for this function:

◆ findChildObjsInAssociations()

UMLObjectList XMLSchemaWriter::findChildObjsInAssociations ( UMLClassifier c,
UMLAssociationList  associations 
)
private

Find and return a list of child UMLObjects pointed to by the associations in this UMLClassifier.

Here is the call graph for this function:

◆ fixInitialStringDeclValue()

QString XMLSchemaWriter::fixInitialStringDeclValue ( QString  value,
const QString &  type 
)
private

Check that initial values of strings DON'T have quotes around them (we get double quoting then)!!

◆ fixTypeName()

QString XMLSchemaWriter::fixTypeName ( const QString &  string)
private

Replaces `string' with `String' and `bool' with `boolean' IF the type is "string" we need to declare it as the XMLSchema Object "String" (there is no string primitive in XMLSchema). Same thing again for "bool" to "boolean".

◆ getElementGroupTypeName()

QString XMLSchemaWriter::getElementGroupTypeName ( UMLClassifier c)
private

Find the group node "type" name. Used for elements which define an interface/are abstract.

Here is the call graph for this function:

◆ getElementName()

QString XMLSchemaWriter::getElementName ( UMLClassifier c)
private

Find the element node name for this concept.

Here is the call graph for this function:

◆ getElementTypeName()

QString XMLSchemaWriter::getElementTypeName ( UMLClassifier c)
private

Find the element node "type" name. Used in the "complexType" which might define that element node.

Here is the call graph for this function:

◆ hasBeenWritten()

bool XMLSchemaWriter::hasBeenWritten ( UMLClassifier c)
private

Quick check to see if we have written the declaration for this concept yet.

◆ language()

Uml::ProgrammingLanguage::Enum XMLSchemaWriter::language ( ) const
virtual

Returns "XMLSchema".

Implements CodeGenerator.

◆ makePackageTag()

QString XMLSchemaWriter::makePackageTag ( QString  tagName)
private

Construct an element tag with the package namespace.

◆ makeSchemaTag()

QString XMLSchemaWriter::makeSchemaTag ( QString  tagName)
private

Construct an element tag with the schema namespace.

◆ markAsWritten()

void XMLSchemaWriter::markAsWritten ( UMLClassifier c)
private

Mark a concept as written, so it is not repeatedly re-declared in the schema.

◆ reservedKeywords()

QStringList XMLSchemaWriter::reservedKeywords ( ) const
virtual

Get list of reserved keywords.

Reimplemented from CodeGenerator.

◆ writeAbstractClassifier()

void XMLSchemaWriter::writeAbstractClassifier ( UMLClassifier c,
QTextStream &  XMLSchema 
)
private
Here is the call graph for this function:

◆ writeAssociationDecls()

bool XMLSchemaWriter::writeAssociationDecls ( UMLAssociationList  associations,
bool  noRoleNameOK,
bool  didFirstOne,
Uml::ID::Type  id,
QTextStream &  xs 
)
private

Searches a list of associations for appropriate ones to write out as attributes. This works well for compositions, aggregations and self-associations but will not work right for plain associations between 2 different classes. all that matters here is roleA, the role served by the children of this class in any composition or aggregation association. In full associations, I have only considered the case of "self" association, so it shouldn't matter if we use role A or B to find the child class as long as we don't use BOTH roles. I bet this will fail badly for someone using a plain association between 2 different classes. THAT should be done, but isnt yet (this is why I have left role b code in for now). -b.t.

Here is the call graph for this function:

◆ writeAssociationRoleDecl()

void XMLSchemaWriter::writeAssociationRoleDecl ( UMLClassifier c,
const QString &  multi,
QTextStream &  xs 
)
private

Writes out an association as an attribute using Vector

Here is the call graph for this function:

◆ writeAttributeDecl()

void XMLSchemaWriter::writeAttributeDecl ( UMLAttribute attrib,
QTextStream &  xs 
)
private

Write an element attribute.

Here is the call graph for this function:

◆ writeAttributeDecls()

void XMLSchemaWriter::writeAttributeDecls ( UMLAttributeList attribs,
QTextStream &  xs 
)
private

Writes the Attribute declarations.

Parameters
attribsList of attributes
xstext stream
Here is the call graph for this function:

◆ writeAttributeGroupDecl()

void XMLSchemaWriter::writeAttributeGroupDecl ( const QString &  elementName,
UMLAttributeList attribs,
QTextStream &  xs 
)
private

Find all attributes that belong in group.

Here is the call graph for this function:

◆ writeChildObjsInAssociation()

void XMLSchemaWriter::writeChildObjsInAssociation ( UMLClassifier c,
UMLAssociationList  assoc,
QTextStream &  xs 
)
private

Find all the child objects in this association and make sure they get written out (if they havent already been).

Here is the call graph for this function:

◆ writeClass()

void XMLSchemaWriter::writeClass ( UMLClassifier c)
virtual

Call this method to generate XMLschema code for a UMLClassifier.

Parameters
cthe class to generate code for

Implements SimpleCodeGenerator.

Here is the call graph for this function:

◆ writeClassifier()

void XMLSchemaWriter::writeClassifier ( UMLClassifier c,
QTextStream &  xs 
)
private

Writes concept's documentation then guts.

Here is the call graph for this function:

◆ writeComment()

void XMLSchemaWriter::writeComment ( const QString &  comment,
QTextStream &  xs 
)
private

Writes a comment.

Here is the call graph for this function:

◆ writeComplexTypeClassifierDecl()

void XMLSchemaWriter::writeComplexTypeClassifierDecl ( UMLClassifier c,
UMLAssociationList  associations,
UMLAssociationList  aggregations,
UMLAssociationList  compositions,
UMLClassifierList  superclasses,
QTextStream &  xs 
)
private

Write a <complexType> declaration for this classifier.

Here is the call graph for this function:

◆ writeConcreteClassifier()

void XMLSchemaWriter::writeConcreteClassifier ( UMLClassifier c,
QTextStream &  XMLSchema 
)
private
Here is the call graph for this function:

◆ writeElementDecl()

void XMLSchemaWriter::writeElementDecl ( const QString &  elementName,
const QString &  elementTypeName,
QTextStream &  xs 
)
private

Write an element declaration.

Here is the call graph for this function:

◆ writeGroupClassifierDecl()

void XMLSchemaWriter::writeGroupClassifierDecl ( UMLClassifier c,
UMLClassifierList  subclasses,
QTextStream &  xs 
)
private

Write a <group> declaration for this classifier. Used for interfaces to classes with inheriting children.

Here is the call graph for this function:

Member Data Documentation

◆ packageNamespaceTag

QString XMLSchemaWriter::packageNamespaceTag
private

basic packageNamespace tag

◆ packageNamespaceURI

QString XMLSchemaWriter::packageNamespaceURI
private

basic packageNamespace URI

◆ schemaNamespaceTag

QString XMLSchemaWriter::schemaNamespaceTag
private

basic schemaNamespace tag

◆ schemaNamespaceURI

QString XMLSchemaWriter::schemaNamespaceURI
private

basic schemaNamespace URI

◆ startline

QString XMLSchemaWriter::startline
private

a
, used at the end of each line

◆ writtenClassifiers

UMLClassifierList XMLSchemaWriter::writtenClassifiers
private

a list of UMLClassifiers we have already written


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