]> git.llucax.com Git - mecon/scripts.git/blobdiff - code2xmi/code2xmi.php
Se agrega tc2120, por ahora la parte del CODEP esta desactivada.
[mecon/scripts.git] / code2xmi / code2xmi.php
index 0fb2ea73bab2405aa94a8fcf203c0f2fe4f397ba..b123a23caae91f4ae6e558e7199bdf391dc3d5e6 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/php4 -qC
+#!/usr/bin/php4 -qC
 <?php 
 /* vim: set binary expandtab tabstop=4 shiftwidth=4 foldmethod=marker:
 -------------------------------------------------------------------------------
@@ -8,6 +8,15 @@ Author : Martin Marrese <m_marrese@argentina.com> <mmarre@mecon.gov.ar>
 $Id$
 -----------------------------------------------------------------------------*/
 
+// CONVERTS A STRING TO XML ENTITIES {{{
+function xmlentities($s) {
+    return str_replace(
+        array('&', '"', '<', '>'),
+        array('&amp;', '&quot;', '&lt;', '&gt;'),
+        $s);
+}
+// }}}
+
 //TAG's XML {{{
 $xmi_start = <<<EOT
 <?xml version="1.0" encoding="UTF-8"?>
@@ -127,7 +136,7 @@ for ($j = 1; $j < count($argv); $j++) {
                                       $options['type'] = $type;
                                       //If there is more documentation, I add it to the main documentation
                                       if (trim($rest)) {
-                                          $options['documentation'].= "Returns: ".trim($rest);  
+                                          $options['documentation'].= "Returns: ".xmlentities(trim($rest))."\n";  
                                       }
                                       $doc_param = 0;
                                       $rest = '';
@@ -141,14 +150,12 @@ for ($j = 1; $j < count($argv); $j++) {
                                           $rest = substr($rest, strpos($rest,' ') + 1);
                                       }
                                       $options['param'][$cont_param]['type'] = $type;
-                                      $options['param'][$cont_param]['documentation'] = trim(substr(trim($rest), strpos(trim($rest), ' ')));
+                                      $options['param'][$cont_param]['documentation'] =
+                                            xmlentities(trim(substr(trim($rest), strpos(trim($rest), ' '))));
                                       $doc_param = 1;
                                       break;
                     default:
-                        $tmp2 = str_replace('"', '&quot;', $tmp2);
-                        $tmp2 = str_replace('<', '&lt;'  , $tmp2);
-                        $tmp2 = str_replace('>', '&gt;'  , $tmp2);
-                        $tmp2 = str_replace('&', '&amp;' , $tmp2);
+                    $tmp2 = xmlentities($tmp2);
                         if (@$doc_param) {
                             $options['param'][$cont_param]['documentation'].= "\n".$tmp2;
                         }