home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 February / PCpro_2005_02.ISO / files / opensource / Dia_0.94 / dia-setup-0.94.exe / dia-uml2owl.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-08-20  |  3.9 KB  |  129 lines

  1. <?xml version='1.0'?><!-- -*- mode: indented-text;-*- -->
  2. <xsl:transform
  3.     xmlns:xsl  ="http://www.w3.org/1999/XSL/Transform" version="1.0"
  4.     xmlns:r    ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  5.     xmlns:s    ="http://www.w3.org/2000/01/rdf-schema#"
  6.     xmlns:dia  ="http://www.lysator.liu.se/~alla/dia/"
  7.     xmlns:owl  ="http://www.w3.org/2002/07/owl@@#"
  8.     >
  9.  
  10. <div xmlns="http://www.w3.org/1999/xhtml">
  11. <p>dia2owl -- convert UML diagram from dia to OWL</p>
  12.  
  13. <p>cf <a href="http://www.swi.psy.uva.nl/usr/Schreiber/docs/owl-uml/owl-uml.html">A UML Presentation Syntax for OWL Lite</a>
  14. Author: Guus Schreiber
  15. Created:: April 3, 2002
  16. Last update: April 19, 2002 
  17. </p>
  18.  
  19. <address>Dan Connolly <br class=""/>
  20. $Id: dia-uml2owl.xsl,v 1.1 2003/12/04 07:38:34 lclausen Exp $</address>
  21.  
  22. <p>see log at end</p>
  23.  
  24. <p>Share and Enjoy.
  25.   Copyright (c) 2001 W3C (MIT, INRIA, Keio)
  26.    <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">Open Source license</a>
  27. </p>
  28.  
  29. </div>
  30.  
  31. <xsl:output method="xml" indent="yes"/>
  32.  
  33. <xsl:template match="/">
  34.   <r:RDF>
  35.     <xsl:apply-templates/>
  36.   </r:RDF>
  37. </xsl:template>
  38.  
  39.  
  40. <xsl:template match='dia:object[@type="UML - Class"]'>
  41.   <xsl:variable name="id" select='@id'/>
  42.  
  43.   <!-- hm... dia seems to have odd string quoting -->
  44.   <xsl:variable name="label" select='substring-before(substring-after(dia:attribute[@name="name"]/dia:string, "#"), "#")'/>
  45.  
  46.   <xsl:message>@@found UML Class: <xsl:value-of select='$label'/></xsl:message>
  47.  
  48.   <s:Class r:ID='{$id}'>
  49.     <s:label><xsl:value-of select='$label'/></s:label>
  50.   </s:Class>
  51.  
  52. </xsl:template>
  53.  
  54. <xsl:template match='dia:object[@type="UML - Generalization"]'>
  55.   <xsl:variable name="subjID"
  56.                 select='dia:connections/dia:connection[@handle="1"]/@to'/>
  57.   <xsl:variable name="objID"
  58.                 select='dia:connections/dia:connection[@handle="0"]/@to'/>
  59.  
  60.   <xsl:message>@@found UML Generalization:
  61.     <xsl:value-of select='$subjID'/>
  62.     <xsl:value-of select='$objID'/>
  63.   </xsl:message>
  64.  
  65.   <r:Description r:about='{concat("#", $subjID)}'>
  66.     <s:subClassOf r:resource='{concat("#", $objID)}'/>
  67.   </r:Description>
  68.  
  69. </xsl:template>
  70.  
  71.  
  72. <xsl:template match='dia:object[@type="UML - Association"]'>
  73.   <xsl:variable name="id" select='@id'/>
  74.   <xsl:variable name="label" select='substring-before(substring-after(dia:attribute[@name="name"]/dia:string, "#"), "#")'/>
  75.  
  76.   <xsl:variable name="domainID"
  77.                 select='dia:connections/dia:connection[@handle="1"]/@to'/>
  78.   <xsl:variable name="rangeID"
  79.                 select='dia:connections/dia:connection[@handle="0"]/@to'/>
  80.  
  81.   <!-- these include the funky #string quotes# -->
  82.   <xsl:variable name="domainMult"
  83.                 select='dia:attribute[@name="ends"]/dia:composite[1]/
  84.                          dia:attribute[@name="multiplicity"]/dia:string'/>
  85.   <xsl:variable name="rangeMult"
  86.                 select='dia:attribute[@name="ends"]/dia:composite[2]/
  87.                          dia:attribute[@name="multiplicity"]/dia:string'/>
  88.  
  89.  
  90.   <xsl:message>@@found UML Association: <xsl:value-of select='$label'/>
  91.   </xsl:message>
  92.  
  93.   <r:Property r:ID='{$id}'>
  94.     <s:label><xsl:value-of select='$label'/></s:label>
  95.     <s:domain r:resource='{concat("#", $domainID)}'/>
  96.     <s:range  r:resource='{concat("#", $rangeID)}'/>
  97.   </r:Property>
  98.  
  99.   <xsl:if test='$rangeMult = "#1..*#"'>
  100.     <r:Description r:about='{concat("#", $domainID)}'>
  101.       <owl:hasAtLeastOne r:resource='{concat("#", $id)}'/>
  102.     </r:Description>
  103.   </xsl:if>
  104.  
  105.   <!-- @@ more cardinality stuff? -->
  106.  
  107. </xsl:template>
  108.  
  109.  
  110. <!-- don't pass text thru -->
  111. <xsl:template match="text()|@*">
  112. </xsl:template>
  113.  
  114.  
  115. <!--
  116. $Log: dia-uml2owl.xsl,v $
  117. Revision 1.1  2003/12/04 07:38:34  lclausen
  118. Doc install fix, new XSLT
  119.  
  120. Revision 1.2  2002/07/11 08:01:46  connolly
  121. got the objProp case working
  122.  
  123. Revision 1.1  2002/07/11 07:25:28  connolly
  124. got 1st test case working
  125.  
  126. -->
  127.  
  128. </xsl:transform>
  129.