umbrello 26.03.70-1a62d36 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
XMLSchemaWriter Class Reference

`#include <xmlschemawriter.h>`

Inheritance 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 ()
virtual void | writeClass (UMLClassifier *c)=0
Public Member Functions inherited from CodeGenerator
| CodeGenerator ()
virtual | ~CodeGenerator ()
bool | addCodeDocument (CodeDocument *add_object)
bool | removeCodeDocument (CodeDocument *remove_object)
CodeDocumentList * | getCodeDocumentList ()
QString | getUniqueID (CodeDocument *codeDoc)
virtual void | saveToXMI (QXmlStreamWriter &writer)
CodeDocument * | findCodeDocumentByID (const QString &id)
virtual void | writeCodeToFile ()
virtual void | writeCodeToFile (UMLClassifierList &list)
void | setIncludeHeadings (bool i)
bool | includeHeadings () const
void | setHeadingFileDir (const QString &)
QString | headingFileDir () const
void | setForceDoc (bool f)
bool | forceDoc () const
void | setSectionCommentPolicy (CodeGenerationPolicy::WriteSectionCommentsPolicy f)
bool | forceSections () const
virtual QString | getHeadingFile (const QString &file)
QString | findFileName (CodeDocument *codeDocument)
virtual void | loadFromXMI (QDomElement &element)
virtual Uml::ProgrammingLanguage::Enum | language () const =0
CodeDocument * | findCodeDocumentByClassifier (UMLClassifier *classifier)
virtual QStringList | defaultDatatypes () const
virtual bool | isReservedKeyword (const QString &keyword)
virtual QStringList | reservedKeywords () const
virtual void | createDefaultStereotypes ()
virtual void | initFromParentDocument ()=0

## 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 *classifier, bool generated)
void | codeGenerated (UMLClassifier *classifier, 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=QStringLiteral(" *"), int lineWidth=80)
static QString | formatFullDocBlock (const QString &text, const QString &blockHeader=QStringLiteral("/* "), const QString &blockFooter=QStringLiteral(" */"), const QString &linePrefix=QStringLiteral(" *"), 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 *classifier, const QString &ext)
QString | overwritableName (UMLPackage *classifier, 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
UMLDoc * | m_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.

## ◆ findAttributeGroups()

QStringList XMLSchemaWriter::findAttributeGroups | ( | UMLClassifier * | c | ) |

private

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

## ◆ findAttributes()

UMLAttributeList XMLSchemaWriter::findAttributes | ( | UMLClassifier * | c | ) |

private

Find all attributes for this classifier.

## ◆ 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.

## ◆ 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.

## ◆ getElementName()

QString XMLSchemaWriter::getElementName | ( | UMLClassifier * | c | ) |

private

Find the element node name for this classifier.

## ◆ getElementTypeName()

QString XMLSchemaWriter::getElementTypeName | ( | UMLClassifier * | c | ) |

private

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

## ◆ hasBeenWritten()

bool XMLSchemaWriter::hasBeenWritten | ( | UMLClassifier * | c | ) |

private

Quick check to see if we have written the declaration for this classifier 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 classifier 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

## ◆ 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.

## ◆ writeAssociationRoleDecl()

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

private

Writes out an association as an attribute using Vector

## ◆ writeAttributeDecl()

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

private

Write an element attribute.

## ◆ writeAttributeDecls()

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

private

Writes the Attribute declarations.

Parameters

  attribs | List of attributes
  xs | text stream

## ◆ writeAttributeGroupDecl()

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

private

Find all attributes that belong in group.

## ◆ 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).

## ◆ writeClass()

void XMLSchemaWriter::writeClass | ( | UMLClassifier * | c | ) |

virtual

Call this method to generate XMLschema code for a UMLClassifier.

Parameters

  c | the class to generate code for

Implements SimpleCodeGenerator.

## ◆ writeClassifier()

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

private

Writes classifier's documentation then guts.

## ◆ writeComment()

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

private

Writes a comment.

## ◆ writeComplexTypeClassifierDecl()

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

private

Write a <complexType> declaration for this classifier.

## ◆ writeConcreteClassifier()

void XMLSchemaWriter::writeConcreteClassifier | ( | UMLClassifier * | c,
|  | QTextStream & | XMLSchema
| ) |  |

private

## ◆ writeElementDecl()

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

private

Write an element declaration.

## ◆ 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.

## 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:

- umbrello/codegenerators/xml/xmlschemawriter.h
- umbrello/codegenerators/xml/xmlschemawriter.cpp