Ah I found it - I don't know how far I got, let me know if you want
more - GMail rocks :)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xslt[
<!ENTITY INDENT "	">
]>
<!--
Author: Rob Rohan ([EMAIL PROTECTED])
File: XMItoCFC.xsl
Date: 2004-10-04
Purpose: To create coldfusion components from an xmi (uml xml) file
it's been tested with argoUML mostly
Copyright: 2004 Rob Rohan (RohanClan)
License: GPL
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xsl:output method="text" indent="yes" encoding="utf-8"/>
<xsl:output method="text" name="textFormat"/>
<xsl:strip-space elements="*"/>
<!-- directory offset for class names (i.e. com.bbb.bbb set this to
booga. and
you'll get booga.com.bbb.bbb) end with a dot -->
<xsl:param name="packageoffset" select="''" />
<!-- where to start writting the cfcs (note must end with a /)-->
<xsl:param name="directorybase" select="'file:///C:/tempcfcgen/'" />
<!-- file extension... -->
<xsl:param name="extension" select="'.cfc'" />
<xsl:template match="/">
<xsl:apply-templates
select="/XMI/XMI.content/Model_Management.Model/Foundation.Core.Namespace.ownedElement/Foundation.Core.Class"
/>
</xsl:template>
<!-- classes -->
<xsl:template
match="/XMI/XMI.content/Model_Management.Model/Foundation.Core.Namespace.ownedElement/Foundation.Core.Class">
<xsl:variable name="fullClassName">
<xsl:call-template name="lookupFQClassName">
<xsl:with-param name="idref" select="@xmi.id" />
</xsl:call-template>
</xsl:variable>
<xsl:result-document
href="{concat($directorybase,translate($fullClassName,'.','/'),$extension)}"
format="textFormat">
<xsl:text><cfcomponent displayname="</xsl:text>
<xsl:call-template name="lookupClassName">
<xsl:with-param name="idref" select="@xmi.id" />
</xsl:call-template>
<xsl:text>"</xsl:text>
<xsl:apply-templates
select="Foundation.Core.GeneralizableElement.generalization/Foundation.Core.Generalization"
/>
<xsl:text>></xsl:text>
<xsl:text>

</xsl:text>
<xsl:apply-templates
select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute"
/>
<xsl:text>
</xsl:text>
<xsl:apply-templates
select="Foundation.Core.Classifier.feature/Foundation.Core.Operation"
/>
<xsl:text></component></xsl:text>
</xsl:result-document>
<!-- <xsl:text>

</xsl:text> -->
</xsl:template>
<!-- generalize -->
<xsl:template
match="Foundation.Core.GeneralizableElement.generalization/Foundation.Core.Generalization">
<xsl:text> extends="</xsl:text>
<xsl:call-template name="lookupGeneralization">
<xsl:with-param name="idref" select="@xmi.idref" />
</xsl:call-template>
<xsl:text>"</xsl:text>
</xsl:template>
<!-- attributes -->
<xsl:template
match="Foundation.Core.Classifier.feature/Foundation.Core.Attribute">
<xsl:text>&INDENT;<cfproperty name="</xsl:text>
<xsl:value-of select="Foundation.Core.ModelElement.name" />
<xsl:text>" type="</xsl:text>
<xsl:call-template name="lookupType">
<xsl:with-param name="idref"
select="Foundation.Core.StructuralFeature.type/Foundation.Core.Classifier/@xmi.idref"
/>
</xsl:call-template>
<xsl:text>"></xsl:text>
<xsl:text>
</xsl:text>
</xsl:template>
<!-- operations -->
<xsl:template
match="Foundation.Core.Classifier.feature/Foundation.Core.Operation">
<xsl:text>&INDENT;<cffuntion returntype="</xsl:text>
<xsl:value-of
select="Foundation.Core.ModelElement.visibility/@xmi.value" />
<xsl:text>" name="</xsl:text>
<xsl:value-of select="Foundation.Core.ModelElement.name" />
<xsl:text>"></xsl:text>
<xsl:text>
</xsl:text>
<xsl:apply-templates
select="Foundation.Core.BehavioralFeature.parameter"/>
<xsl:text>&INDENT;</cffunction></xsl:text>
<xsl:text>

</xsl:text>
</xsl:template>
<!-- parameters -->
<xsl:template match="Foundation.Core.BehavioralFeature.parameter">
<xsl:apply-templates select="Foundation.Core.Parameter"/>
</xsl:template>
<!-- parameter -->
<xsl:template match="Foundation.Core.Parameter">
<xsl:text>&INDENT;&INDENT;<cfargument name="</xsl:text>
<xsl:value-of select="Foundation.Core.ModelElement.name" />
<xsl:text>" type="</xsl:text>
<xsl:call-template name="lookupType">
<xsl:with-param name="idref"
select="Foundation.Core.Parameter.type/Foundation.Core.Classifier/@xmi.idref"/>
</xsl:call-template>
<xsl:text>"></xsl:text>
<xsl:text>
</xsl:text>
</xsl:template>
<!--
//////////////////////////////////////////////////////////////////////////////////////////
-->
<!-- //////////////////////////////////// NAMED TEMPLATES
///////////////////////////////////// -->
<!--
//////////////////////////////////////////////////////////////////////////////////////////
-->
<!-- lookup a data type -->
<xsl:template name="lookupType">
<xsl:param name="idref" select="''" />
<xsl:value-of select="//[EMAIL PROTECTED] =
$idref]/Foundation.Core.ModelElement.name" />
</xsl:template>
<!-- lookup class name -->
<xsl:template name="lookupClassName">
<xsl:param name="idref" select="''" />
<xsl:value-of select="//[EMAIL PROTECTED] =
$idref]/Foundation.Core.ModelElement.name" />
</xsl:template>
<!-- lookup namespace -->
<xsl:template name="lookupNameSpace">
<xsl:param name="idref" select="''" />
<xsl:variable name="namespaceid">
<xsl:value-of select="//[EMAIL PROTECTED] =
$idref]/Foundation.Core.ModelElement.namespace/Foundation.Core.Namespace/@xmi.idref"
/>
</xsl:variable>
<xsl:value-of
select="concat($packageoffset,/XMI/XMI.content/[EMAIL
PROTECTED]
= $namespaceid]/Foundation.Core.ModelElement.name)"
/>
</xsl:template>
<!-- lookup class name -->
<xsl:template name="lookupFQClassName">
<xsl:param name="idref" select="''" />
<xsl:variable name="nspace">
<xsl:call-template name="lookupNameSpace">
<xsl:with-param name="idref" select="$idref" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="class">
<xsl:call-template name="lookupClassName">
<xsl:with-param name="idref" select="$idref" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat($nspace,'.',$class)" />
</xsl:template>
<!-- lookup the class that the calling class is gereralized from.
Meaing this is
called from child classes to get their parent
-->
<xsl:template name="lookupGeneralization">
<xsl:param name="idref" select="''" />
<!-- lookup the parents idref -->
<xsl:variable name="parentidref">
<xsl:value-of select="//[EMAIL PROTECTED] =
$idref]/Foundation.Core.Generalization.parent/Foundation.Core.GeneralizableElement/@xmi.idref"
/>
</xsl:variable>
<xsl:variable name="nspace">
<xsl:call-template name="lookupNameSpace">
<xsl:with-param name="idref"
select="$parentidref"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="classname">
<!-- now, lookup the class name using the ref -->
<xsl:call-template name="lookupClassName">
<xsl:with-param name="idref"
select="$parentidref"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($nspace) > 0">
<xsl:value-of
select="concat($nspace,'.',$classname)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="concat($packageoffset,$classname)" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
On Mon, 28 Feb 2005 12:14:30 -0800, Rob <[EMAIL PROTECTED]> wrote:
> T'was I, and I can't find it anymore :-/
>
> The book XML Cookbook (http://www.oreilly.com/catalog/xsltckbk/) has
> an example of XML->C++ that you can modify if you want, but mine was
> done differently than in that book. If I find it I'll pass it along.
--
~Blog~
http://www.robrohan.com
~The cfml plug-in for eclipse~
http://cfeclipse.tigris.org
~open source xslt IDE~
http://treebeard.sourceforge.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196859
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54