Book a Demo

Author Topic: Transform to XSD - XSDSimpleType  (Read 2114 times)

Michal Podzimek

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Transform to XSD - XSDSimpleType
« on: September 25, 2009, 01:04:31 am »
Hello,
I try to modify standard XSD transformation template. For some special stereotype I would like to generate class with XSDSimpleType. My problem is that I cant set "Type". How can I do it?
The reason for this is that I use special simple stereotype in PIM diagram and the "Type" is specified in Tag.


My code (in that code i set Tag "Type", but it doesnt set Type to XSDSimple Type):

%if elemType != "Class"%
%endTemplate%

Class
{
  name=%qt%%className%%qt%
%if classStereotype=="enumeration"%
  stereotype="enumeration"
%elseIf classStereotype=="CSSimpleType"%
  stereotype="XSDsimpleType"
  Tag
  {
    name="derivation"
    value="restriction"
  }
  Tag
  {
    name="type"
    value=%qt%%classTag:"baseType"%%qt%
  }
  %if classTag:"fractionDigits"!=""%
    Tag
    {
      name="fractionDigits"
      value=%qt%%classTag:"fractionDigits"%%qt%
    }
  %endIf%
%else%
  stereotype="XSDcomplexType"
%endIf%
  %TRANSFORM_CURRENT("name","stereotype")%
  %TRANSFORM_REFERENCE("XSDClass")%
%if elemType=="Class"%
%list="Attribute" @separator="\n" @indent="  "%
%endIf%
}

%list="Connector" @separator="\n" @indent="  "%



At last I would like to generate XSD like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:simpleType name="CS_CodebookCode">
            <xs:restriction base="xs:string">
                  <xs:minLength value="1"/>
                  <xs:maxLength value="8"/>
            </xs:restriction>
      </xs:simpleType>
</xs:schema>



Thank you, for answer.

Michal