Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

metal-dev · MetaL Development

The Yahoo! Groups Product Blog

Check it out!

Group Information

? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 67 - 96 of 555   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#67 From: Manuel Lemos <mlemos@...>
Date: Mon Dec 24, 2001 4:42 pm
Subject: MetaL can generate full Java object classes
mallemos
Send Email Send Email
 
Hello,

Although this was done more than one week ago, I have been very busy
with other developments and could not announce before that MetaL is now
capable of generating classes of objects like they were already being
generated for PHP. This means that the classes that were  developed with
MetaL and some were released to the public in the PHP Classes
repository, can already be released wherever in form of Java code.

This was a very important step forward in the MetaL development because
unlike PHP, Java requires variables to be declared, and MetaL is now
capable to figure the types of the variables you use in class functions
and generate automatically classes code that declare such variables
although you don't need to declare them explicitly in MetaL code. This
means that now the whole MetaL engine is capable of supporting any
strong typing language like Java, but also others.

Other important capability, that MetaL is also able to keep track of the
exceptions that each class function throws. This is not very important
for PHP, but it is for Java.

See the attached examples of MetaL code and the code that was generated
by the MetaL compiler for PHP and Java. Notice also that despite Java
does not support it like PHP, MetaL is capable of doing some magic with
Java code by providing capabilities that currently it does not have,
like for instance switch/case constructs with String values (Java only
supports integers).

Another interesting consequence is that now it is also possible to
generate automatic documentation for classes for PHP and Java. This
means that the resulting document will show data types and example code
in the target language that was choosen. See also the generated HTML
example documentation for the same MetaL class. Also, unlike JavaDoc and
PHPDoc (AFAIK) MetaL is also able to generating documentation in
different idioms from the same MetaL class source code.

Since the latest changes broke almost all MetaL code to adapt it to deal
with Java limitations, I have not updated the CVS repository.

Well, for now I just need to write some conformance tests the certify
that the generated code works seeminglessly with all supported
languages. Then I also want to support the same features for generating
Perl code. Then I will finally be ready to Open MetaL as a full source
code project.

Until then,
Merry X-Mas to everybody,
Manuel Lemos
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
      @(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos Exp $
   -->
<input>

  <object>
   <name>xml_writer_class</name>
   <class>class</class>
   <attributes>

    <class>

     <documentation>
      <idiom>en</idiom>
      <purpose>Composing and generating XML documents.</purpose>
      <usage>The class has several independent functions that should be used
       to compose the structure of a XML document.  When the structure is
       fully composed the <functionlink>write</functionlink> should be used
       to output the document in the XML format.</usage>
      <example>Here follows an example of typical use of this
class:<pre><examplecode>

       <comment>First create an object of the class.</comment>
       <set> <xmlwriterobject /> <createxmlwriterobject /> </set>

       <comment>Now, start defining the XML document from the root tag.</comment>
       <void><addxmlwritertag>
        <arguments>
         <tag><string>myxmldocument</string></tag>
         <attributes><hash /></attributes>
         <parent><emptystring /></parent>
         <path><variable>root</variable></path>
         <indent><true /></indent>
        </arguments>
       </addxmlwritertag></void>

       <comment>Then define the rest of the document tags and data.</comment>
       <void><addxmlwritertag>
        <arguments>
         <tag><string>name</string></tag>
         <attributes><hash /></attributes>
         <parent><variable>root</variable></parent>
         <path><variable>toptag</variable></path>
         <indent><false /></indent>
        </arguments>
       </addxmlwritertag></void>
       <void><addxmlwriterdata>
        <arguments>
         <data><string>John Doe</string></data>
         <parent><variable>toptag</variable></parent>
         <path><variable>path</variable></path>
        </arguments>
       </addxmlwriterdata></void>

       <comment>Tags may have attributes.</comment>
       <set> <hashvariable>attributes</hashvariable> <hash /> </set>
       <setentry>
        <hashvariable>attributes</hashvariable>
        <string>country</string>
        <string>us</string>
       </setentry>
       <void><addxmlwritertag>
        <arguments>
         <tag><string>address</string></tag>
         <attributes><variable>attributes</variable></attributes>
         <parent><variable>root</variable></parent>
         <path><variable>toptag</variable></path>
         <indent><true /></indent>
        </arguments>
       </addxmlwritertag></void>

       <comment>Tags and the correspondent data may be added with a single
function call.</comment>
       <void><addxmlwriterdatatag>
        <arguments>
         <tag><string>street</string></tag>
         <attributes><hash /></attributes>
         <parent><variable>toptag</variable></parent>
         <path><variable>datatag</variable></path>
         <data><string>Wall Street, 1641</string></data>
        </arguments>
       </addxmlwriterdatatag></void>
       <void><addxmlwriterdatatag>
        <arguments>
         <tag><string>zip</string></tag>
         <attributes><hash /></attributes>
         <parent><variable>toptag</variable></parent>
         <path><variable>datatag</variable></path>
         <data><string>NY 72834</string></data>
        </arguments>
       </addxmlwriterdatatag></void>

       <comment>When you are done with the XML document definition, generate
it.</comment>
       <if>
        <istrue>
         <writexml>
          <arguments>
           <output><variable>output</variable></output>
          </arguments>
         </writexml>
        </istrue>
        <then>

         <comment>If the document was generated successfully, you may not output
it.</comment>
<!--
         <cgiresponseheader>
          <header><string>Content-Type: text/xml; charset="</string><join
/><xmlwriterobjectvariable>outputencoding</xmlwriterobjectvariable><join
/><string>"</string></header>
         </cgiresponseheader>
         <cgiresponseheader>
          <header><string>Content-Length: </string><join
/><converttostring><length><variable>output</variable></length></converttostring\
></header>
         </cgiresponseheader>
-->
         <variable>output</variable>

        </then>
        <else>
         <comment>If there was an error, output it as well.</comment>
<!--
         <cgiresponseheader>
          <header><string>Content-Type: text/plain</string></header>
         </cgiresponseheader>
-->
         <group><string>Error: </string><join
/><xmlwriterobjectvariable>error</xmlwriterobjectvariable></group>
        </else>
       </if>

      </examplecode></pre></example>
     </documentation>

     <file><installpath />/library/xml/xml_writer_class<languageextension
/></file>
     <basepath><openpath /></basepath>
     <tag>METAL_LIBRARY_XML_XML_WRITER_CLASS</tag>
     <version>@(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos
Exp $</version>
     <copyright>Copyright © (C) Manuel Lemos 2001</copyright>
     <title>XML writer</title>
     <author>Manuel Lemos</author>
     <authoraddress>mlemos@...</authoraddress>

     <variable>
      <name>structure</name>
      <type>HASH</type>
      <value></value>
      <protected />
     </variable>

     <variable>
      <name>nodes</name>
      <type>HASH</type>
      <value></value>
      <protected />
     </variable>

     <variable>
      <name>outputencoding</name>
      <type>STRING</type>
      <value>utf-8</value>
      <documentation>
       <idiom>en</idiom>
       <purpose>Define the character set encoding of the output
        document.</purpose>
       <usage>Currently the class supports only the encodings <tt>utf-8</tt>
        or <tt>iso-8859-1</tt>.</usage>
      </documentation>
     </variable>

     <variable>
      <name>inputencoding</name>
      <type>STRING</type>
      <value>iso-8859-1</value>
      <documentation>
       <idiom>en</idiom>
       <purpose>Define the character set encoding of the of the data values
        passed to the function <functionlink>adddata</functionlink> or the
        attribute values passed to the function
        <functionlink>addtag</functionlink>.</purpose>
       <usage>Currently the class supports only the encodings <tt>utf-8</tt>
        or <tt>iso-8859-1</tt>.</usage>
      </documentation>
     </variable>

     <variable>
      <name>linebreak</name>
      <type>STRING</type>
      <value>
</value>
      <documentation>
       <idiom>en</idiom>
       <purpose>Characters to be used when breaking lines of the output XML
        document.</purpose>
       <usage>Use either <stringvalue>
</stringvalue>,
        <stringvalue>
</stringvalue> or
        <stringvalue>
</stringvalue>.</usage>
      </documentation>
     </variable>

     <variable>
      <name>indenttext</name>
      <type>STRING</type>
      <value> </value>
      <documentation>
       <idiom>en</idiom>
       <purpose>Characters to be used when indenting the lines of the output
        XML document.</purpose>
       <usage>Use either one or more spaces or tab characters.</usage>
      </documentation>
     </variable>

     <variable>
      <name>error</name>
      <type>STRING</type>
      <value></value>
      <documentation>
       <idiom>en</idiom>
       <purpose>Contains the error message that explains the reason of
        failure of certain class functions.</purpose>
       <usage>Check this variable when a given class function fails.</usage>
      </documentation>
     </variable>

     <function>
      <name>escapedata</name>
      <type>STRING</type>
      <protected />
      <argument>
       <name>data</name>
       <type>STRING</type>
      </argument>
      <do>
       <set> <variable>position</variable> <zero /> </set>
       <set> <variable>length</variable>
<length><argument>data</argument></length> </set>
       <set> <variable>escapeddata</variable> <emptystring /> </set>
       <loop>
        <while>
         <variable>position</variable> <less /> <variable>length</variable>
        </while>
        <do>
         <set>
          <variable>character</variable>
          <substring>
           <argument>data</argument>
           <variable>position</variable>
           <one />
          </substring>
         </set>

         <set>
          <variable>code</variable>
          <code><variable>character</variable></code>
         </set>

         <switch>
          <value><integervariable>code</integervariable></value>

          <case>
           <value>34</value>
           <do>
            <set>
             <variable>character</variable>
             <string>&quot;</string>
            </set>
            <break />
           </do>
          </case>

          <case>
           <value>38</value>
           <do>
            <set>
             <variable>character</variable>
             <string>&amp;</string>
            </set>
            <break />
           </do>
          </case>

          <case>
           <value>39</value>
           <do>
            <set>
             <variable>character</variable>
             <string>&apos;</string>
            </set>
            <break />
           </do>
          </case>

          <case>
           <value>60</value>
           <do>
            <set>
             <variable>character</variable>
             <string>&lt;</string>
            </set>
            <break />
           </do>
          </case>

          <case>
           <value>62</value>
           <do>
            <set>
             <variable>character</variable>
             <string>&gt;</string>
            </set>
            <break />
           </do>
          </case>

          <default>
           <do>
            <if>
             <istrue>
              <variable>code</variable> <less /> <integer>32</integer>
             </istrue>
             <then>

              <set>
               <variable>character</variable>
               <group>
                 <string>&#</string>
                <join />
                 <converttostring><variable>code</variable></converttostring>
                <join />
                 <string>;</string>
               </group>
              </set>

             </then>
            </if>
            <break />
           </do>
          </default>

         </switch>

         <concatenate>
          <string><variable>escapeddata</variable></string>
          <append><variable>character</variable></append>
         </concatenate>

         <increment><variable>position</variable></increment>

        </do>
       </loop>

       <return><variable>escapeddata</variable></return>
      </do>
     </function>

     <function>
      <name>encodedata</name>
      <type>BOOLEAN</type>
      <protected />
      <documentation>
       <idiom>en</idiom>
       <purpose>Encodes text in a suitable form for outputting as XML data
        parts or tag attributes.</purpose>
       <usage>Pass text data in the encoding type defined by the
        <variablelink>inputencoding</variablelink> variable and expect the
        encoded result in the encoding type defined by the
        <variablelink>outputencoding</variablelink> variable.</usage>
       <returnvalue>Success boolean flag.  If this flag is
        <tt><booleanvalue>0</booleanvalue></tt> then the
        <variablelink>error</variablelink> variable contains the error
        message that explains the failure.</returnvalue>
      </documentation>
      <argument>
       <name>data</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Input text data in the encoding type defined by the
         <variablelink>inputencoding</variablelink> variable.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>encodeddata</name>
       <type>STRING</type>
       <out />
       <documentation>
        <idiom>en</idiom>
        <purpose>Encoded result data in the encoding type defined by the
         <variablelink>outputencoding</variablelink> variable.</purpose>
       </documentation>
      </argument>
      <do>
       <if>
        <istrue>
         <this>inputencoding</this> <equalstrings /> <this>outputencoding</this>
        </istrue>
        <then>
         <set>
          <argument>encodeddata</argument>
          <callthis>
           <function>escapedata</function>
           <arguments>
            <data><argument>data</argument></data>
           </arguments>
          </callthis>
         </set>
        </then>
        <else>
         <switch>
          <value><lowercase><this>outputencoding</this></lowercase></value>

          <case>
           <value>utf-8</value>
           <do>
            <if>
             <istrue>
              <lowercase><this>inputencoding</this></lowercase> <equalstrings />
<string>iso-8859-1</string>
             </istrue>
             <then>
              <utf8encode>
               <data><callthis>
                <function>escapedata</function>
                <arguments>
                 <data><argument>data</argument></data>
                </arguments>
               </callthis></data>
               <encoded><argument>encodeddata</argument></encoded>
              </utf8encode>
             </then>
             <else>
              <set>
               <this>error</this>
               <group>
                 <string>can not encode iso-8859-1 data in </string>
                <join />
                 <this>outputencoding</this>
               </group>
              </set>
              <return><false /></return>
             </else>
            </if>
            <break />
           </do>
          </case>

          <case>
           <value>iso-8859-1</value>
           <do>
            <if>
             <istrue>
              <lowercase><this>inputencoding</this></lowercase> <equalstrings />
<string>utf-8</string>
             </istrue>
             <then>
              <utf8decode>
               <decoded><stringvariable>decoded</stringvariable></decoded>
               <data><argument>data</argument></data>
              </utf8decode>
              <set>
               <argument>encodeddata</argument>
               <callthis>
                <function>escapedata</function>
                <arguments>
                 <data><variable>decoded</variable></data>
                </arguments>
               </callthis>
              </set>
             </then>
             <else>
              <set>
               <this>error</this>
               <group>
                 <string>can not encode utf-8 data in </string>
                <join />
                 <this>outputencoding</this>
               </group>
              </set>
              <return><false /></return>
             </else>
            </if>
            <break />
           </do>
          </case>

          <default>
           <do>
            <set>
             <this>error</this>
             <group>
               <string>can not encode data in </string>
              <join />
               <this>inputencoding</this>
             </group>
            </set>
            <return><false /></return>
           </do>
          </default>

         </switch>

        </else>
       </if>
       <return><true /></return>
      </do>
     </function>

     <function>
      <name>writetag</name>
      <type>BOOLEAN</type>
      <protected />
      <argument>
       <name>output</name>
       <type>STRING</type>
       <inout />
      </argument>
      <argument>
       <name>path</name>
       <type>STRING</type>
      </argument>
      <argument>
       <name>indent</name>
       <type>STRING</type>
      </argument>
      <do>
       <set>
        <variable>tag</variable>
        <stringentry>
         <hashentry>
          <this>structure</this>
          <argument>path</argument>
         </hashentry>
         <string>Tag</string>
        </stringentry>
       </set>
       <concatenate>
        <string><argument>output</argument></string>
        <append><group>
          <string><</string>
         <join />
          <variable>tag</variable>
        </group></append>
       </concatenate>
       <set>
        <variable>attributecount</variable>
        <count><hashentry>
         <hashentry>
          <this>structure</this>
          <argument>path</argument>
         </hashentry>
         <string>Attributes</string>
        </hashentry></count>
       </set>
       <if>
        <istrue>
         <variable>attributecount</variable> <more /> <zero />
        </istrue>
        <then>
         <set>
          <variable>attributes</variable>
          <hashentry>
           <hashentry>
            <this>structure</this>
            <argument>path</argument>
           </hashentry>
           <string>Attributes</string>
          </hashentry>
         </set>
         <reset>
          <hash><variable>attributes</variable></hash>
          <cursor>cursor</cursor>
          <key><stringvariable>key</stringvariable></key>
          <end><booleanvariable>end</booleanvariable></end>
         </reset>
         <loop>
          <while>
           <not><variable>end</variable></not>
          </while>
          <do>
           <concatenate>
            <string><argument>output</argument></string>
            <append><group>
              <string> </string>
             <join />
              <variable>key</variable>
             <join />
              <string>="</string>
             <join />
              <stringentry>
               <hashvariable>attributes</hashvariable>
               <variable>key</variable>
              </stringentry>
             <join />
              <string>"</string>
            </group></append>
           </concatenate>
           <next>
            <hash><variable>attributes</variable></hash>
            <cursor>cursor</cursor>
            <key><variable>key</variable></key>
            <end><variable>end</variable></end>
           </next>
          </do>
         </loop>
        </then>
       </if>
       <concatenate>
        <string><argument>output</argument></string>
        <append><string>></string></append>
       </concatenate>
       <set>
        <variable>doindent</variable>
        <booleanentry>
         <hashentry>
          <this>structure</this>
          <argument>path</argument>
         </hashentry>
         <string>Indent</string>
        </booleanentry>
       </set>
       <set>
        <variable>elementindent</variable>
        <conditional>
         <istrue>
          <variable>doindent</variable>
         </istrue>
         <then>
           <this>linebreak</this>
          <join />
           <argument>indent</argument>
          <join />
           <this>indenttext</this>
         </then>
         <else>
          <emptystring />
         </else>
        </conditional>
       </set>
       <set>
        <variable>elements</variable>
        <integerentry>
         <hashentry>
          <this>structure</this>
          <argument>path</argument>
         </hashentry>
         <string>Elements</string>
        </integerentry>
       </set>
       <set>
        <variable>element</variable>
        <zero />
       </set>
       <loop>
        <while>
         <variable>element</variable> <less /> <variable>elements</variable>
        </while>
        <do>
         <set>
          <variable>elementpath</variable>
          <group>
            <argument>path</argument>
           <join />
            <string>,</string>
           <join />
            <converttostring><variable>element</variable></converttostring>
          </group>
         </set>
         <concatenate>
          <string><argument>output</argument></string>
          <append><variable>elementindent</variable></append>
         </concatenate>
         <if>
          <istrue>
           <entrydefined>
            <this>nodes</this>
            <variable>elementpath</variable>
           </entrydefined>
          </istrue>
          <then>
           <if>
            <isfalse>
             <callthis>
              <function>writetag</function>
              <arguments>
               <output><argument>output</argument></output>
               <path><variable>elementpath</variable></path>
               <indent><argument>indent</argument><join
/><this>indenttext</this></indent>
              </arguments>
             </callthis>
            </isfalse>
            <then>
             <return><false /></return>
            </then>
           </if>
          </then>
          <else>
           <concatenate>
            <string><argument>output</argument></string>
            <append><stringentry>
             <this>structure</this>
             <stringvariable>elementpath</stringvariable>
            </stringentry></append>
           </concatenate>
          </else>
         </if>
         <increment><variable>element</variable></increment>
        </do>
       </loop>
       <concatenate>
        <string><argument>output</argument></string>
        <append><group>
          <conditional>
           <istrue>
            <variable>doindent</variable>
           </istrue>
           <then>
             <this>linebreak</this>
            <join />
             <argument>indent</argument>
           </then>
           <else>
            <emptystring />
           </else>
          </conditional>
         <join />
          <string></</string>
         <join />
          <variable>tag</variable>
         <join />
          <string>></string>
        </group></append>
       </concatenate>
       <return><true /></return>
      </do>
     </function>

     <function>
      <name>write</name>
      <type>BOOLEAN</type>
      <documentation>
       <idiom>en</idiom>
       <purpose>Generate the XML document.</purpose>
       <usage>Pass a reference to a string variable that will hold the
        resulting XML document.</usage>
       <returnvalue>Success boolean flag.  If this flag is
        <tt><booleanvalue>0</booleanvalue></tt> then the
        <variablelink>error</variablelink> variable contains the error
        message that explains the failure.</returnvalue>
      </documentation>
      <argument>
       <name>output</name>
       <type>STRING</type>
       <out />
       <documentation>
        <idiom>en</idiom>
        <purpose>Reference to a variable that will hold the resulting XML
         document.</purpose>
       </documentation>
      </argument>
      <do>
       <if>
        <istrue>
         <this>error</this> <differentstrings /> <emptystring />
        </istrue>
        <then>
         <return><false /></return>
        </then>
       </if>
       <if>
        <isfalse>
         <entrydefined>
          <this>structure</this>
          <string>0</string>
         </entrydefined>
        </isfalse>
        <then>
         <set>
          <this>error</this>
          <string>XML document structure is empty</string>
         </set>
         <return><false /></return>
        </then>
       </if>
       <set>
        <argument>output</argument>
        <group>
          <string><?xml version="1.0" encoding="</string>
         <join />
          <this>outputencoding</this>
         <join />
          <string>"?></string>
         <join />
          <this>linebreak</this>
        </group>
       </set>
       <return><callthis>
        <function>writetag</function>
        <arguments>
         <output><argument>output</argument></output>
         <path><string>0</string></path>
         <indent><emptystring /></indent>
        </arguments>
       </callthis></return>
      </do>
     </function>

     <function>
      <name>addtag</name>
      <type>BOOLEAN</type>
      <documentation>
       <idiom>en</idiom>
       <purpose>Add a tag to the XML document structure.</purpose>
       <usage>Specify the tag definition and the parent XML document element
        where the tag will be added.</usage>
       <returnvalue>Success boolean flag.  If this flag is
        <tt><booleanvalue>0</booleanvalue></tt> then the
        <variablelink>error</variablelink> variable contains the error
        message that explains the failure. This return value may be
        safely ignored if the function call arguments are correctly
        defined.</returnvalue>
      </documentation>
      <argument>
       <name>tag</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Name of the tag to be added.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>attributes</name>
       <type>HASH</type>
       <defaultvalue></defaultvalue>
       <documentation>
        <idiom>en</idiom>
        <purpose>Associative array that defined the list of attributes of
         the tag, if any.  The indexes of the array entries are the names of
         the attributes and the values array entries are the attribute
         values defined in encoding type specified by the
         <variablelink>inputencoding</variablelink> variable.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>parent</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Path of the parent XML document tag element within each
         which the new tag is being added.  If the new tag is the document
         root tag, the parent path is <tt><stringvalue></stringvalue></tt>.
         The path of previously added tags is returned by the <argumentlink>
          <function>addtag</function>
          <argument>path</argument>
         </argumentlink> argument of previous calls to this
         function.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>path</name>
       <type>STRING</type>
       <out />
       <documentation>
        <idiom>en</idiom>
        <purpose>Reference to a variable that will hold the path of the
         XML document tag element that is added by this function.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>indent</name>
       <type>BOOLEAN</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Flag that determines if the elements to be added within
         this tag will be outputted in individual indented lines.</purpose>
       </documentation>
      </argument>
      <do>
       <if>
        <istrue>
         <this>error</this> <differentstrings /> <emptystring />
        </istrue>
        <then>
         <return><false /></return>
        </then>
       </if>
       <set>
        <argument>path</argument>
        <conditional>
         <istrue>
          <argument>parent</argument> <equalstrings /> <emptystring />
         </istrue>
         <then>
          <string>0</string>
         </then>
         <else>
          <group>
            <argument>parent</argument>
           <join />
            <string>,</string>
           <join />
            <converttostring><integerentry>
             <hashentry>
              <this>structure</this>
              <argument>parent</argument>
             </hashentry>
             <string>Elements</string>
            </integerentry></converttostring>
          </group>
         </else>
        </conditional>
       </set>
       <if>
        <istrue>
         <entrydefined>
          <this>structure</this>
          <argument>path</argument>
         </entrydefined>
        </istrue>
        <then>
         <set>
          <this>error</this>
          <group>
            <string>tag with path </string>
           <join />
            <argument>path</argument>
           <join />
            <string> is already defined</string>
          </group>
         </set>
         <return><false /></return>
        </then>
       </if>

       <set> <variable>encodedattributes</variable> <hash /> </set>
       <reset>
        <hash><argument>attributes</argument></hash>
        <cursor>cursor</cursor>
        <key><stringvariable>attribute_name</stringvariable></key>
        <end><booleanvariable>end</booleanvariable></end>
       </reset>
       <loop>
        <while>
         <not><variable>end</variable></not>
        </while>
        <do>
         <setentry>
          <hashvariable>encodedattributes</hashvariable>
          <variable>attribute_name</variable>
          <emptystring />
         </setentry>
         <if>
          <isfalse>
           <callthis>
            <function>encodedata</function>
            <arguments>
             <data><stringentry>
              <argument>attributes</argument>
              <variable>attribute_name</variable>
             </stringentry></data>
             <encodeddata><variable>encoded_data</variable></encodeddata>
            </arguments>
           </callthis>
          </isfalse>
          <then>
           <return><false /></return>
          </then>
         </if>
         <setentry>
          <hashvariable>encodedattributes</hashvariable>
          <variable>attribute_name</variable>
          <variable>encoded_data</variable>
         </setentry>
         <next>
          <hash><argument>attributes</argument></hash>
          <cursor>cursor</cursor>
          <key><variable>attribute_name</variable></key>
          <end><variable>end</variable></end>
         </next>
        </do>
       </loop>

       <hashreset>
        <hash><this>structure</this></hash>
        <index><argument>path</argument></index>
        <values>
         <string>Tag</string> <argument>tag</argument>
         <string>Attributes</string> <variable>encodedattributes</variable>
         <string>Elements</string> <zero />
         <string>Indent</string> <argument>indent</argument>
        </values>
       </hashreset>
       <setentry>
        <this>nodes</this>
        <argument>path</argument>
        <true />
       </setentry>
       <if>
        <istrue>
         <argument>parent</argument> <differentstrings /> <emptystring />
        </istrue>
        <then>
         <setentry>
          <hashentryindex>
           <this>structure</this>
           <argument>parent</argument>
          </hashentryindex>
          <string>Elements</string>
          <group>
            <integerentry>
             <hashentry>
              <this>structure</this>
              <argument>parent</argument>
             </hashentry>
             <string>Elements</string>
            </integerentry>
           <plus />
            <one />
          </group>
         </setentry>
        </then>
       </if>
       <return><true /></return>
      </do>
     </function>

     <function>
      <name>adddata</name>
      <type>BOOLEAN</type>
      <documentation>
       <idiom>en</idiom>
       <purpose>Add a data part to the XML document structure.</purpose>
       <usage>Specify the data text and the parent XML document element
        where the tag will be added.</usage>
       <returnvalue>Success boolean flag.  If this flag is
        <tt><booleanvalue>0</booleanvalue></tt> then the
        <variablelink>error</variablelink> variable contains the error
        message that explains the failure. This return value may be
        safely ignored if the function call arguments are correctly
        defined.</returnvalue>
      </documentation>
      <argument>
       <name>data</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Data text to be added.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>parent</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Path of the parent XML document tag element within each
         which the new data part is being added.  The path of previously
         added tags is returned by the <argumentlink>
          <function>addtag</function>
          <argument>path</argument>
         </argumentlink> argument of previous calls to the
         <functionlink>addtag</functionlink> function.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>path</name>
       <type>STRING</type>
       <out />
       <documentation>
        <idiom>en</idiom>
        <purpose>Reference to a variable that will hold the path of the
         XML document data part element that is added by this
         function.</purpose>
       </documentation>
      </argument>
      <do>
       <if>
        <istrue>
         <this>error</this> <differentstrings /> <emptystring />
        </istrue>
        <then>
         <return><false /></return>
        </then>
       </if>
       <if>
        <isfalse>
         <entrydefined>
          <this>structure</this>
          <argument>parent</argument>
         </entrydefined>
        </isfalse>
        <then>
         <set>
          <this>error</this>
          <group>
            <string>the parent tag path</string>
           <join />
            <argument>path</argument>
           <join />
            <string>is not defined</string>
          </group>
         </set>
         <return><false /></return>
        </then>
       </if>
       <set>
        <argument>path</argument>
        <group>
          <argument>parent</argument>
         <join />
          <string>,</string>
         <join />
          <converttostring><integerentry>
           <hashentry>
            <this>structure</this>
            <argument>parent</argument>
           </hashentry>
           <string>Elements</string>
          </integerentry></converttostring>
        </group>
       </set>
       <if>
        <isfalse>
         <callthis>
          <function>encodedata</function>
          <arguments>
           <data><argument>data</argument></data>
           <encodeddata><variable>encoded_data</variable></encodeddata>
          </arguments>
         </callthis>
        </isfalse>
        <then>
         <return><false /></return>
        </then>
       </if>
       <setentry>
        <this>structure</this>
        <argument>path</argument>
        <variable>encoded_data</variable>
       </setentry>
       <setentry>
        <hashentryindex>
         <this>structure</this>
         <argument>parent</argument>
        </hashentryindex>
        <string>Elements</string>
        <group>
          <integerentry>
           <hashentry>
            <this>structure</this>
            <argument>parent</argument>
           </hashentry>
           <string>Elements</string>
          </integerentry>
         <plus />
          <one />
        </group>
       </setentry>
       <return><true /></return>
      </do>
     </function>

     <function>
      <name>adddatatag</name>
      <type>BOOLEAN</type>
      <documentation>
       <idiom>en</idiom>
       <purpose>Add a tag with data to the XML document structure.</purpose>
       <usage>Specify the tag definition, the text data and the parent XML
        document element where the tag will be added.</usage>
       <returnvalue>Success boolean flag.  If this flag is
        <tt><booleanvalue>0</booleanvalue></tt> then the
        <variablelink>error</variablelink> variable contains the error
        message that explains the failure. This return value may be safely
        ignored if the function call arguments are correctly
defined.</returnvalue>
      </documentation>
      <argument>
       <name>tag</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Name of the tag to be added.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>attributes</name>
       <type>HASH</type>
       <defaultvalue></defaultvalue>
       <documentation>
        <idiom>en</idiom>
        <purpose>Associative array that defined the list of attributes of
         the tag, if any.  The indexes of the array entries are the names of
         the attributes and the values array entries are the attribute
         values defined in encoding type specified by the
         <variablelink>inputencoding</variablelink> variable.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>data</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Data text to be added.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>parent</name>
       <type>STRING</type>
       <documentation>
        <idiom>en</idiom>
        <purpose>Path of the parent XML document tag element within each
         which the new tag is being added. The path of previously added
         tags is returned by the <argumentlink>
                                  <function>addtag</function>
                                  <argument>path</argument>
                                 </argumentlink> argument of previous
         calls to the <functionlink>addtag</functionlink> function.</purpose>
       </documentation>
      </argument>
      <argument>
       <name>path</name>
       <type>STRING</type>
       <out />
       <documentation>
        <idiom>en</idiom>
        <purpose>Reference to a variable that will hold the path of the
         XML document tag element that is added by this function.</purpose>
       </documentation>
      </argument>
      <do>
       <return>
         <callthis>
          <function>addtag</function>
          <arguments>
           <tag><argument>tag</argument></tag>
           <attributes><argument>attributes</argument></attributes>
           <parent><argument>parent</argument></parent>
           <path><argument>path</argument></path>
           <indent><false /></indent>
          </arguments>
         </callthis>
        <and />
         <callthis>
          <function>adddata</function>
          <arguments>
           <data><argument>data</argument></data>
           <parent><argument>path</argument></parent>
           <path><variable>datapath</variable></path>
          </arguments>
         </callthis>
       </return>
      </do>
     </function>

    </class>

   </attributes>
  </object>

  <function>
   <name>xmlwriterclasscall</name>
   <object>xml_writer_class</object>
   <call>call</call>
   <arguments>
    <object><xmlwriterobject /></object>
   </arguments>
  </function>

  <function>
   <name>xmlwriterobjectvariable</name>
   <object>xml_writer_class</object>
   <call>objectvariable</call>
   <arguments>
    <object><xmlwriterobject /></object>
   </arguments>
  </function>

  <function>
   <name>createxmlwriterobject</name>
   <object>xml_writer_class</object>
   <call>new</call>
   <arguments>
   </arguments>
  </function>

  <function>
   <name>writexml</name>
   <object>xml_writer_class</object>
   <call>call</call>
   <arguments>
    <object><xmlwriterobject /></object>
    <function>write</function>
   </arguments>
  </function>

  <function>
   <name>addxmlwritertag</name>
   <object>xml_writer_class</object>
   <call>call</call>
   <arguments>
    <object><xmlwriterobject /></object>
    <function>addtag</function>
   </arguments>
  </function>

  <function>
   <name>addxmlwriterdata</name>
   <object>xml_writer_class</object>
   <call>call</call>
   <arguments>
    <object><xmlwriterobject /></object>
    <function>adddata</function>
   </arguments>
  </function>

  <function>
   <name>addxmlwriterdatatag</name>
   <object>xml_writer_class</object>
   <call>call</call>
   <arguments>
    <object><xmlwriterobject /></object>
    <function>adddatatag</function>
   </arguments>
  </function>

  <function>
   <name>outputxmlwriterclass</name>
   <object>xml_writer_class</object>
   <call>output</call>
   <arguments></arguments>
  </function>

</input>
<?php
if(!defined("METAL_LIBRARY_XML_XML_WRITER_CLASS"))
{
	 define("METAL_LIBRARY_XML_XML_WRITER_CLASS",1);

/*
  *
  * Copyright © (C) Manuel Lemos 2001
  *
  * @(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos Exp $
  *
  */

class xml_writer_class
{
	 /*
	  * Protected variables
	  *
	  */
	 var $structure=array();
	 var $nodes=array();

	 /*
	  * Public variables
	  *
	  */
	 var $outputencoding="utf-8";
	 var $inputencoding="iso-8859-1";
	 var $linebreak="\n";
	 var $indenttext=" ";
	 var $error="";


	 /*
	  * Protected functions
	  *
	  */
	 Function escapedata($data)
	 {
		 $position=0;
		 $length=strlen($data);
		 $escapeddata="";
		 for(;$position<$length;)
		 {
			 $character=substr($data,$position,1);
			 $code=Ord($character);
			 switch($code)
			 {
				 case 34:
					 $character=""";
					 break;
				 case 38:
					 $character="&";
					 break;
				 case 39:
					 $character="'";
					 break;
				 case 60:
					 $character="<";
					 break;
				 case 62:
					 $character=">";
					 break;
				 default:
					 if($code<32)
						 $character=("&#".strval($code).";");
					 break;
			 }
			 $escapeddata.=$character;
			 $position++;
		 }
		 return $escapeddata;
	 }

	 Function encodedata($data,&$encodeddata)
	 {
		 if(!strcmp($this->inputencoding,$this->outputencoding))
			 $encodeddata=$this->escapedata($data);
		 else
		 {
			 switch(strtolower($this->outputencoding))
			 {
				 case "utf-8":
					 if(!strcmp(strtolower($this->inputencoding),"iso-8859-1"))
						 $encodeddata=utf8_encode($this->escapedata($data));
					 else
					 {
						 $this->error=("can not encode iso-8859-1 data in ".$this->outputencoding);
						 return 0;
					 }
					 break;
				 case "iso-8859-1":
					 if(!strcmp(strtolower($this->inputencoding),"utf-8"))
					 {
						 $decoded=utf8_decode($data);
						 $encodeddata=$this->escapedata($decoded);
					 }
					 else
					 {
						 $this->error=("can not encode utf-8 data in ".$this->outputencoding);
						 return 0;
					 }
					 break;
				 default:
					 $this->error=("can not encode data in ".$this->inputencoding);
					 return 0;
			 }
		 }
		 return 1;
	 }

	 Function writetag(&$output,$path,$indent)
	 {
		 $tag=$this->structure[$path]["Tag"];
		 $output.=("<".$tag);
		 $attributecount=count($this->structure[$path]["Attributes"]);
		 if($attributecount>0)
		 {
			 $attributes=$this->structure[$path]["Attributes"];
			 Reset($attributes);
			 $end=(GetType($key=Next($attributes))!="string");
			 for(;!$end;)
			 {
				 $output.=(" ".$key."=\"".$attributes[$key]."\"");
				 $end=(GetType($key=Next($attributes))!="string");
			 }
		 }
		 $output.=">";
		 $doindent=$this->structure[$path]["Indent"];
		 $elementindent=(($doindent) ? $this->linebreak.$indent.$this->indenttext :
"");
		 $elements=$this->structure[$path]["Elements"];
		 $element=0;
		 for(;$element<$elements;)
		 {
			 $elementpath=($path.",".strval($element));
			 $output.=$elementindent;
			 if(IsSet($this->nodes[$elementpath]))
			 {
				 if(!$this->writetag($output,$elementpath,$indent.$this->indenttext))
					 return 0;
			 }
			 else
				 $output.=$this->structure[$elementpath];
			 $element++;
		 }
		 $output.=((($doindent) ? $this->linebreak.$indent : "")."</".$tag.">");
		 return 1;
	 }

	 /*
	  * Public functions
	  *
	  */
	 Function write(&$output)
	 {
		 if(strcmp($this->error,""))
			 return 0;
		 if(!IsSet($this->structure["0"]))
		 {
			 $this->error="XML document structure is empty";
			 return 0;
		 }
		 $output=("<?xml version=\"1.0\"
encoding=\"".$this->outputencoding."\"?>".$this->linebreak);
		 return $this->writetag($output,"0","");
	 }

	 Function addtag($tag,$attributes,$parent,&$path,$indent)
	 {
		 if(strcmp($this->error,""))
			 return 0;
		 $path=((!strcmp($parent,"")) ? "0" :
($parent.",".strval($this->structure[$parent]["Elements"])));
		 if(IsSet($this->structure[$path]))
		 {
			 $this->error=("tag with path ".$path." is already defined");
			 return 0;
		 }
		 $encodedattributes=array();
		 Reset($attributes);
		 $end=(GetType($attribute_name=Next($attributes))!="string");
		 for(;!$end;)
		 {
			 $encodedattributes[$attribute_name]="";
			 if(!$this->encodedata($attributes[$attribute_name],$encoded_data))
				 return 0;
			 $encodedattributes[$attribute_name]=$encoded_data;
			 $end=(GetType($attribute_name=Next($attributes))!="string");
		 }
		 $this->structure[$path]=array(
			 "Tag"=>$tag,
			 "Attributes"=>$encodedattributes,
			 "Elements"=>0,
			 "Indent"=>$indent
		 );
		 $this->nodes[$path]=1;
		 if(strcmp($parent,""))
			
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
		 return 1;
	 }

	 Function adddata($data,$parent,&$path)
	 {
		 if(strcmp($this->error,""))
			 return 0;
		 if(!IsSet($this->structure[$parent]))
		 {
			 $this->error=("the parent tag path".$path."is not defined");
			 return 0;
		 }
		 $path=($parent.",".strval($this->structure[$parent]["Elements"]));
		 if(!$this->encodedata($data,$encoded_data))
			 return 0;
		 $this->structure[$path]=$encoded_data;
		
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
		 return 1;
	 }

	 Function adddatatag($tag,$attributes,$data,$parent,&$path)
	 {
		 return $this->addtag($tag,$attributes,$parent,$path,0) &&
$this->adddata($data,$path,$datapath);
	 }
};

}
?>
/*
  *
  * Copyright © (C) Manuel Lemos 2001
  *
  * @(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos Exp $
  *
  */

import java.util.Hashtable;

public class xml_writer_class
{
	 protected Hashtable structure=new Hashtable();
	 protected Hashtable nodes=new Hashtable();

	 public String outputencoding="utf-8";
	 public String inputencoding="iso-8859-1";
	 public String linebreak="\n";
	 public String indenttext=" ";
	 public String error="";

	 protected String escapedata(String data)
	 {
		 int position;
		 int length;
		 String escapeddata;
		 String character;
		 int code;

		 position=0;
		 length=data.length();
		 escapeddata="";
		 for(;position<length;)
		 {
			 character=data.substring(position,position+1-1);
			 code=java.lang.Character.getNumericValue(character.charAt(0));
			 switch(code)
			 {
				 case 34:
					 character=""";
					 break;
				 case 38:
					 character="&";
					 break;
				 case 39:
					 character="'";
					 break;
				 case 60:
					 character="<";
					 break;
				 case 62:
					 character=">";
					 break;
				 default:
					 if(code<32)
						 character=("&#"+java.lang.String.valueOf(code)+";");
					 break;
			 }
			 escapeddata.concat(character);
			 position++;
		 }
		 return escapeddata;
	 }

	 protected boolean encodedata(String data, String encodeddata) throws
java.io.UnsupportedEncodingException
	 {
		 String _switch_value;
		 String decoded;

		 if(this.inputencoding.equals(this.outputencoding))
			 encodeddata=this.escapedata(data);
		 else
		 {
			 _switch_value=this.outputencoding.toLowerCase();
			 switch(_switch_value.equals("utf-8") ? 0 :
(_switch_value.equals("iso-8859-1") ? 1 : 2))
			 {
				 case 0:
					 if(this.inputencoding.toLowerCase().equals("iso-8859-1"))
						 encodeddata=new String(this.escapedata(data).getBytes("UTF8"));
					 else
					 {
						 this.error=("can not encode iso-8859-1 data in "+this.outputencoding);
						 return false;
					 }
					 break;
				 case 1:
					 if(this.inputencoding.toLowerCase().equals("utf-8"))
					 {
						 decoded=new String(data.getBytes(),"UTF8");
						 encodeddata=this.escapedata(decoded);
					 }
					 else
					 {
						 this.error=("can not encode utf-8 data in "+this.outputencoding);
						 return false;
					 }
					 break;
				 default:
					 this.error=("can not encode data in "+this.inputencoding);
					 return false;
			 }
		 }
		 return true;
	 }

	 protected boolean writetag(String output, String path, String indent)
	 {
		 String tag;
		 int attributecount;
		 Hashtable attributes;
		 String key;
		 boolean end;
		 Object cursor;
		 boolean doindent;
		 String elementindent;
		 int elements;
		 int element;
		 String elementpath;

		 tag=((String)((Hashtable)this.structure.get(path)).get("Tag"));
		 output.concat(("<"+tag));
		
attributecount=((Hashtable)((Hashtable)this.structure.get(path)).get("Attributes\
")).size();
		 if(attributecount>0)
		 {
			
attributes=((Hashtable)((Hashtable)this.structure.get(path)).get("Attributes"));
			 cursor=(Object)attributes.keys();
			 end=!((java.util.Enumeration)cursor).hasMoreElements();
			 key=end ? null : (String)((java.util.Enumeration)cursor).nextElement();
			 for(;!end;)
			 {
				 output.concat((" "+key+"=\""+((String)attributes.get(key))+"\""));
				 end=!((java.util.Enumeration)cursor).hasMoreElements();
				 key=end ? null : (String)((java.util.Enumeration)cursor).nextElement();
			 }
		 }
		 output.concat(">");
		
doindent=((Boolean)((Hashtable)this.structure.get(path)).get("Indent")).booleanV\
alue();
		 elementindent=((doindent) ? this.linebreak+indent+this.indenttext : "");
		
elements=((Integer)((Hashtable)this.structure.get(path)).get("Elements")).intVal\
ue();
		 element=0;
		 for(;element<elements;)
		 {
			 elementpath=(path+","+java.lang.String.valueOf(element));
			 output.concat(elementindent);
			 if(this.nodes.containsKey(elementpath))
			 {
				 if(!this.writetag(output,elementpath,indent+this.indenttext))
					 return false;
			 }
			 else
				 output.concat(((String)this.structure.get(elementpath)));
			 element++;
		 }
		 output.concat((((doindent) ? this.linebreak+indent : "")+"</"+tag+">"));
		 return true;
	 }

	 public boolean write(String output)
	 {
		 if(!this.error.equals(""))
			 return false;
		 if(!this.structure.containsKey("0"))
		 {
			 this.error="XML document structure is empty";
			 return false;
		 }
		 output=("<?xml version=\"1.0\"
encoding=\""+this.outputencoding+"\"?>"+this.linebreak);
		 return this.writetag(output,"0","");
	 }

	 public boolean addtag(String tag, Hashtable attributes, String parent, String
path, boolean indent) throws java.io.UnsupportedEncodingException
	 {
		 Hashtable encodedattributes;
		 String attribute_name;
		 boolean end;
		 Object cursor;
		 String encoded_data=null;

		 if(!this.error.equals(""))
			 return false;
		 path=((parent.equals("")) ? "0" :
(parent+","+java.lang.String.valueOf(((Integer)((Hashtable)this.structure.get(pa\
rent)).get("Elements")).intValue())));
		 if(this.structure.containsKey(path))
		 {
			 this.error=("tag with path "+path+" is already defined");
			 return false;
		 }
		 encodedattributes=new Hashtable();
		 cursor=(Object)attributes.keys();
		 end=!((java.util.Enumeration)cursor).hasMoreElements();
		 attribute_name=end ? null :
(String)((java.util.Enumeration)cursor).nextElement();
		 for(;!end;)
		 {
			 encodedattributes.put(attribute_name,"");
			 if(!this.encodedata(((String)attributes.get(attribute_name)),encoded_data))
				 return false;
			 encodedattributes.put(attribute_name,encoded_data);
			 end=!((java.util.Enumeration)cursor).hasMoreElements();
			 attribute_name=end ? null :
(String)((java.util.Enumeration)cursor).nextElement();
		 }
		 {
			 Hashtable _hashtable=new Hashtable(4);

			 _hashtable.put("Tag",tag);
			 _hashtable.put("Attributes",encodedattributes);
			 _hashtable.put("Elements",new Integer(0));
			 _hashtable.put("Indent",new Boolean(indent));
			 this.structure.put(path,_hashtable);
		 }
		 this.nodes.put(path,new Boolean(true));
		 if(!parent.equals(""))
			 ((Hashtable)this.structure.get(parent)).put("Elements",new
Integer((((Integer)((Hashtable)this.structure.get(parent)).get("Elements")).intV\
alue()+1)));
		 return true;
	 }

	 public boolean adddata(String data, String parent, String path) throws
java.io.UnsupportedEncodingException
	 {
		 String encoded_data=null;

		 if(!this.error.equals(""))
			 return false;
		 if(!this.structure.containsKey(parent))
		 {
			 this.error=("the parent tag path"+path+"is not defined");
			 return false;
		 }
		
path=(parent+","+java.lang.String.valueOf(((Integer)((Hashtable)this.structure.g\
et(parent)).get("Elements")).intValue()));
		 if(!this.encodedata(data,encoded_data))
			 return false;
		 this.structure.put(path,encoded_data);
		 ((Hashtable)this.structure.get(parent)).put("Elements",new
Integer((((Integer)((Hashtable)this.structure.get(parent)).get("Elements")).intV\
alue()+1)));
		 return true;
	 }

	 public boolean adddatatag(String tag, Hashtable attributes, String data, String
parent, String path) throws java.io.UnsupportedEncodingException
	 {
		 String datapath=null;

		 return this.addtag(tag,attributes,parent,path,false) &&
this.adddata(data,path,datapath);
	 }
};

Class: XML writer



  • Summary
    • Name

      XML writer

      Author

      Manuel Lemos (mlemos@...)

      Copyright

      Copyright © (C) Manuel Lemos 2001

      Version

      @(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos Exp $

      Purpose

      Composing and generating XML documents.

      Usage

      The class has several independent functions that should be used to compose the structure of a XML document. When the structure is fully composed the write should be used to output the document in the XML format.

      Example

      Here follows an example of typical use of this class:

      <?php
      	
      	/*
      	 *  First create an object of the class.
      	 */
      	$xml_writer_object=new xml_writer_class;
      	
      	/*
      	 *  Now, start defining the XML document from the root tag.
      	 */
      	$xml_writer_object->addtag("myxmldocument",array(),"",$root,1);
      	
      	/*
      	 *  Then define the rest of the document tags and data.
      	 */
      	$xml_writer_object->addtag("name",array(),$root,$toptag,0);
      	$xml_writer_object->adddata("John Doe",$toptag,$path);
      	
      	/*
      	 *  Tags may have attributes.
      	 */
      	$attributes=array();
      	$attributes["country"]="us";
      	$xml_writer_object->addtag("address",$attributes,$root,$toptag,1);
      	
      	/*
      	 *  Tags and the correspondent data may be added with a single function call.
      	 */
      	$xml_writer_object->adddatatag("street",array(),"Wall Street, 1641",$toptag,$datatag);
      	$xml_writer_object->adddatatag("zip",array(),"NY 72834",$toptag,$datatag);
      	
      	/*
      	 *  When you are done with the XML document definition, generate it.
      	 */
      	if($xml_writer_object->write($output))
      	{
      		
      		/*
      		 *  If the document was generated successfully, you may not output it.
      		 */
      		echo $output;
      	}
      	else
      	{
      		
      		/*
      		 *  If there was an error, output it as well.
      		 */
      		echo ("Error: ".$xml_writer_object->error);
      	}
      ?>

      Table of contents


  • Variables
    • outputencoding

    • inputencoding

    • linebreak

    • indenttext

    • error

    • Table of contents

    • outputencoding
    • Type

      string

      Default value

      "utf-8"

      Purpose

      Define the character set encoding of the output document.

      Usage

      Currently the class supports only the encodings utf-8 or iso-8859-1.

      Variables

    • inputencoding
    • Type

      string

      Default value

      "iso-8859-1"

      Purpose

      Define the character set encoding of the of the data values passed to the function adddata or the attribute values passed to the function addtag.

      Usage

      Currently the class supports only the encodings utf-8 or iso-8859-1.

      Variables

    • linebreak
    • Type

      string

      Default value

      "\n"

      Purpose

      Characters to be used when breaking lines of the output XML document.

      Usage

      Use either "\n", "\r\n" or "\r".

      Variables

    • indenttext
    • Type

      string

      Default value

      " "

      Purpose

      Characters to be used when indenting the lines of the output XML document.

      Usage

      Use either one or more spaces or tab characters.

      Variables

    • error
    • Type

      string

      Default value

      ""

      Purpose

      Contains the error message that explains the reason of failure of certain class functions.

      Usage

      Check this variable when a given class function fails.

      Variables

      Table of contents


  • Functions
    • write

    • addtag

    • adddata

    • adddatatag

    • Table of contents

    • write
    • Synopsis

      bool write(

      )

      Purpose

      Generate the XML document.

      Usage

      Pass a reference to a string variable that will hold the resulting XML document.

      Arguments

        output - Reference to a variable that will hold the resulting XML document.

      Return value

      Success boolean flag. If this flag is 0 then the error variable contains the error message that explains the failure.

      Functions

    • addtag
    • Synopsis

      bool addtag(

      )

      Purpose

      Add a tag to the XML document structure.

      Usage

      Specify the tag definition and the parent XML document element where the tag will be added.

      Arguments

        tag - Name of the tag to be added.

        attributes - Associative array that defined the list of attributes of the tag, if any. The indexes of the array entries are the names of the attributes and the values array entries are the attribute values defined in encoding type specified by the inputencoding variable.

        parent - Path of the parent XML document tag element within each which the new tag is being added. If the new tag is the document root tag, the parent path is "". The path of previously added tags is returned by the path argument of previous calls to this function.

        path - Reference to a variable that will hold the path of the XML document tag element that is added by this function.

        indent - Flag that determines if the elements to be added within this tag will be outputted in individual indented lines.

      Return value

      Success boolean flag. If this flag is 0 then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

    • adddata
    • Synopsis

      bool adddata(

      )

      Purpose

      Add a data part to the XML document structure.

      Usage

      Specify the data text and the parent XML document element where the tag will be added.

      Arguments

        data - Data text to be added.

        parent - Path of the parent XML document tag element within each which the new data part is being added. The path of previously added tags is returned by the path argument of previous calls to the addtag function.

        path - Reference to a variable that will hold the path of the XML document data part element that is added by this function.

      Return value

      Success boolean flag. If this flag is 0 then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

    • adddatatag
    • Synopsis

      bool adddatatag(

      )

      Purpose

      Add a tag with data to the XML document structure.

      Usage

      Specify the tag definition, the text data and the parent XML document element where the tag will be added.

      Arguments

        tag - Name of the tag to be added.

        attributes - Associative array that defined the list of attributes of the tag, if any. The indexes of the array entries are the names of the attributes and the values array entries are the attribute values defined in encoding type specified by the inputencoding variable.

        data - Data text to be added.

        parent - Path of the parent XML document tag element within each which the new tag is being added. The path of previously added tags is returned by the path argument of previous calls to the addtag function.

        path - Reference to a variable that will hold the path of the XML document tag element that is added by this function.

      Return value

      Success boolean flag. If this flag is 0 then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

      Table of contents


Manuel Lemos (mlemos@...)

Class: XML writer



  • Summary
    • Name

      XML writer

      Author

      Manuel Lemos (mlemos@...)

      Copyright

      Copyright © (C) Manuel Lemos 2001

      Version

      @(#) $Id: xmlwriterclass.class,v 1.28 2001/12/12 06:41:30 mlemos Exp $

      Purpose

      Composing and generating XML documents.

      Usage

      The class has several independent functions that should be used to compose the structure of a XML document. When the structure is fully composed the write should be used to output the document in the XML format.

      Example

      Here follows an example of typical use of this class:

      {
      	Object xml_writer_object;
      	String root=null;
      	String toptag=null;
      	String path=null;
      	Hashtable attributes;
      	String datatag=null;
      	String output=null;
      	
      	
      	/*
      	 *  First create an object of the class.
      	 */
      	xml_writer_object=new xml_writer_class;
      	
      	/*
      	 *  Now, start defining the XML document from the root tag.
      	 */
      	xml_writer_object.addtag("myxmldocument",new Hashtable(),"",root,true);
      	
      	/*
      	 *  Then define the rest of the document tags and data.
      	 */
      	xml_writer_object.addtag("name",new Hashtable(),root,toptag,false);
      	xml_writer_object.adddata("John Doe",toptag,path);
      	
      	/*
      	 *  Tags may have attributes.
      	 */
      	attributes=new Hashtable();
      	attributes.put("country","us");
      	xml_writer_object.addtag("address",attributes,root,toptag,true);
      	
      	/*
      	 *  Tags and the correspondent data may be added with a single function call.
      	 */
      	xml_writer_object.adddatatag("street",new Hashtable(),"Wall Street, 1641",toptag,datatag);
      	xml_writer_object.adddatatag("zip",new Hashtable(),"NY 72834",toptag,datatag);
      	
      	/*
      	 *  When you are done with the XML document definition, generate it.
      	 */
      	if(xml_writer_object.write(output))
      	{
      		
      		/*
      		 *  If the document was generated successfully, you may not output it.
      		 */
      		System.out.print(output);
      	}
      	else
      	{
      		
      		/*
      		 *  If there was an error, output it as well.
      		 */
      		System.out.print(("Error: "+xml_writer_object.error));
      	}
      }
      

      Table of contents


  • Variables
    • outputencoding

    • inputencoding

    • linebreak

    • indenttext

    • error

    • Table of contents

    • outputencoding
    • Type

      String

      Default value

      "utf-8"

      Purpose

      Define the character set encoding of the output document.

      Usage

      Currently the class supports only the encodings utf-8 or iso-8859-1.

      Variables

    • inputencoding
    • Type

      String

      Default value

      "iso-8859-1"

      Purpose

      Define the character set encoding of the of the data values passed to the function adddata or the attribute values passed to the function addtag.

      Usage

      Currently the class supports only the encodings utf-8 or iso-8859-1.

      Variables

    • linebreak
    • Type

      String

      Default value

      "\n"

      Purpose

      Characters to be used when breaking lines of the output XML document.

      Usage

      Use either "\n", "\r\n" or "\r".

      Variables

    • indenttext
    • Type

      String

      Default value

      " "

      Purpose

      Characters to be used when indenting the lines of the output XML document.

      Usage

      Use either one or more spaces or tab characters.

      Variables

    • error
    • Type

      String

      Default value

      ""

      Purpose

      Contains the error message that explains the reason of failure of certain class functions.

      Usage

      Check this variable when a given class function fails.

      Variables

      Table of contents


  • Functions
    • write

    • addtag

    • adddata

    • adddatatag

    • Table of contents

    • write
    • Synopsis

      bool write(

      )

      Purpose

      Generate the XML document.

      Usage

      Pass a reference to a string variable that will hold the resulting XML document.

      Arguments

        output - Reference to a variable that will hold the resulting XML document.

      Return value

      Success boolean flag. If this flag is false then the error variable contains the error message that explains the failure.

      Functions

    • addtag
    • Synopsis

      bool addtag(

      )

      Purpose

      Add a tag to the XML document structure.

      Usage

      Specify the tag definition and the parent XML document element where the tag will be added.

      Arguments

        tag - Name of the tag to be added.

        attributes - Associative array that defined the list of attributes of the tag, if any. The indexes of the array entries are the names of the attributes and the values array entries are the attribute values defined in encoding type specified by the inputencoding variable.

        parent - Path of the parent XML document tag element within each which the new tag is being added. If the new tag is the document root tag, the parent path is "". The path of previously added tags is returned by the path argument of previous calls to this function.

        path - Reference to a variable that will hold the path of the XML document tag element that is added by this function.

        indent - Flag that determines if the elements to be added within this tag will be outputted in individual indented lines.

      Return value

      Success boolean flag. If this flag is false then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

    • adddata
    • Synopsis

      bool adddata(

      )

      Purpose

      Add a data part to the XML document structure.

      Usage

      Specify the data text and the parent XML document element where the tag will be added.

      Arguments

        data - Data text to be added.

        parent - Path of the parent XML document tag element within each which the new data part is being added. The path of previously added tags is returned by the path argument of previous calls to the addtag function.

        path - Reference to a variable that will hold the path of the XML document data part element that is added by this function.

      Return value

      Success boolean flag. If this flag is false then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

    • adddatatag
    • Synopsis

      bool adddatatag(

      )

      Purpose

      Add a tag with data to the XML document structure.

      Usage

      Specify the tag definition, the text data and the parent XML document element where the tag will be added.

      Arguments

        tag - Name of the tag to be added.

        attributes - Associative array that defined the list of attributes of the tag, if any. The indexes of the array entries are the names of the attributes and the values array entries are the attribute values defined in encoding type specified by the inputencoding variable.

        data - Data text to be added.

        parent - Path of the parent XML document tag element within each which the new tag is being added. The path of previously added tags is returned by the path argument of previous calls to the addtag function.

        path - Reference to a variable that will hold the path of the XML document tag element that is added by this function.

      Return value

      Success boolean flag. If this flag is false then the error variable contains the error message that explains the failure. This return value may be safely ignored if the function call arguments are correctly defined.

      Functions

      Table of contents


Manuel Lemos (mlemos@...)

#68 From: Manuel Lemos <mlemos@...>
Date: Fri Jan 4, 2002 7:55 am
Subject: Proof of concept done for Java
mallemos
Send Email Send Email
 
Hello,

Finally I made the proof of concept of MetaL by generating a class and a
test script from MetaL code in either PHP and Java. The code in both
languages performed the same task that was to generate a XML document
dynamically with tags and data defined in the test script.

This is a very important milestone as soon I will be able to release
MetaL to the general public as an Open Source project. The last step is
to make the proof of concept also with Perl. That should be easier than
with Java because Perl seems to be more flexible.

Anyway, I expect that to happen until the end of the month. For now I
will be taking 2 weeks off to give priority to some other projects of
mine.

Regards,
Manuel Lemos

#69 From: Manuel Lemos <mlemos@...>
Date: Fri Sep 13, 2002 8:50 am
Subject: Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/12/2002 12:29 PM, Marcus and Aviva wrote:
> Anyone working on some XSLT or other system to generate PHP code? In
> particular with respect to generating database schemas with PHP object
> wrappers. Database schema generators are already appearing (esp. Java),
> but no one seems to be working on a tool to generate the  corresponding
> PHP classes either through the native PHP database functions or some
> intermediate layer (Binary Cloud, Metabase, PHPDo).
>
> Are you or anyone you know undertaking such a project? Do you/they want
> any help?

Coincidentally I am starting to work on a module for the MetaL compiler
engine that is meant to generate object persistent layers eventually to
SQL databases.

Like you mentioned it will pick component descriptions and generate
database schemas for SQL table mappings including any intermediate
tables that are needed for many to many relationships. It will also
generate classes in MetaL code that can be generated to any of the
supported languages.

PHP is naturally the most well supported language in the MetaL
development, but it can also generate Java and Perl. The advantage of
PHP in this case as since I rely on Metabase, the generated code will be
database agnostic, ie, it will work well with all supported databases.

And then, you may ask: what is MetaL?

Is is a meta-programming engine that makes possible to generate the same
program in different target languages from a language independent
program definition based in XML.

It is not yet released, but I planned to make it Open Source. I just did
not do it yet because I did not had the time to document it minimally,
but since now I need to develop this object persistence module to
develop the paid services sub-systems that I am working on for the PHP
Classes site, I have a good motivation to work on MetaL more.

Anyway, if you have tried some of my classes from the PHP Classes site,
you have most likely used MetaL generated code without knowing.

For more information, take a look at this page:

http://www.meta-language.net/


--

Regards,
Manuel Lemos

#70 From: Alex Black <enigma@...>
Date: Fri Sep 13, 2002 6:21 pm
Subject: Re: Re: Anyone working on XMI to PHP code generation?
zeomis
Send Email Send Email
 
ola,

hopefully this isn't butting in manuel :)

>> Anyone working on some XSLT or other system to generate PHP code? In
>> particular with respect to generating database schemas with PHP object
>> wrappers.

Manuel is doing a project called MetaL which is effectively an XML code
representation -> PHP (or whatever other language).

binarycloud has a means of:
     -writing an "entity definition" XML
     -ripping:
         -schema (XML in metabase format)
         -"data access class" - binarycloud entity record class.

So, depending on what you're trying to do, Metal may be what you're looking
for, or that part of binarycloud may be what you're looking for.

> Database schema generators are already appearing (esp. Java),
>> but no one seems to be working on a tool to generate the  corresponding
>> PHP classes either through the native PHP database functions or some
>> intermediate layer (Binary Cloud, Metabase, PHPDo).

Yes we have it!

>> Are you or anyone you know undertaking such a project? Do you/they want
>> any help?

> Coincidentally I am starting to work on a module for the MetaL compiler
> engine that is meant to generate object persistent layers eventually to
> SQL databases.

Yep cool :)

> Like you mentioned it will pick component descriptions and generate
> database schemas for SQL table mappings including any intermediate
> tables that are needed for many to many relationships. It will also
> generate classes in MetaL code that can be generated to any of the
> supported languages.

That's very cool. At the moment we do not have extremely sophisticated
schema generation capabilities based on entity definitions - we will. That's
where we could use some help.

> Anyway, if you have tried some of my classes from the PHP Classes site,
> you have most likely used MetaL generated code without knowing.

Yep :)

When Manuel releases metal open source, I want to try and get standard metal
templates working with binarycloud :)

> For more information, take a look at this page:
>
> http://www.meta-language.net/
>


_alex

#71 From: Manuel Lemos <mlemos@...>
Date: Mon Sep 16, 2002 4:55 am
Subject: Re: [metabase-dev] Re: Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/13/2002 03:21 PM, Alex Black wrote:
>>>Anyone working on some XSLT or other system to generate PHP code? In
>>>particular with respect to generating database schemas with PHP object
>>>wrappers.
>>
>
> Manuel is doing a project called MetaL which is effectively an XML code
> representation -> PHP (or whatever other language).
>
> binarycloud has a means of:
>     -writing an "entity definition" XML
>     -ripping:
>         -schema (XML in metabase format)
>         -"data access class" - binarycloud entity record class.
>
> So, depending on what you're trying to do, Metal may be what you're looking
> for, or that part of binarycloud may be what you're looking for.

I have studied several object-relational (O/R) data abstraction layers
(DAL), some more complete than others. I mostly disliked those that rely
on fat base classes or try to do more than just doing object persistence
and do other things like user interface handling.

I liked most of those that just generate code but still it seems that
some generate all the code that you possibly can use but in real
applications you may not need all the methods. So, this is a point to
keep in mind: generate only the code that the developer will hint that
is necessary.

The one that impressed me most is PragmaTier. It generates DAL code in
components that contain the definition of related entities to be
persisted via SQL databases. They have a Component Definition language
that seems very easy but is in some custom format, so it is not XML.

http://www.pragmatier.com/

I also looked at you entity persistence layer. It seems more or less
like what I would like but definitly without those database schema
definitions because that is precisely what I want to avoid to manage
manually.

Too bad that the methods documentation is missing. Do you plan to
document that soon?


>>Database schema generators are already appearing (esp. Java),
>>
>>>but no one seems to be working on a tool to generate the  corresponding
>>>PHP classes either through the native PHP database functions or some
>>>intermediate layer (Binary Cloud, Metabase, PHPDo).
>>
>
> Yes we have it!

My plan is to generate Metabase specific code for DAL classes. However,
I would like to keep an open evolution path to generate database
specific stored procedure based code to be abstracted by a MetaL
compiler module that will provide the support for generating stored
procedures for the most used databases that support them and will work
as an alternative to Metabase specific client code that will still be
generated for databases that do not support stored procedures.

This way it will achieve maximum performance while keeping the high
level of the abstraction. Anyway, this is just a bold idea that it will
probably take a long time to happen because it is not a priority.


>>>Are you or anyone you know undertaking such a project? Do you/they want
>>>any help?
>>
>
>>Coincidentally I am starting to work on a module for the MetaL compiler
>>engine that is meant to generate object persistent layers eventually to
>>SQL databases.
>
>
> Yep cool :)
>
>
>>Like you mentioned it will pick component descriptions and generate
>>database schemas for SQL table mappings including any intermediate
>>tables that are needed for many to many relationships. It will also
>>generate classes in MetaL code that can be generated to any of the
>>supported languages.
>
>
> That's very cool. At the moment we do not have extremely sophisticated
> schema generation capabilities based on entity definitions - we will. That's
> where we could use some help.

Yes, at least some brainstorming would be helpful. What I have in mind
is definining a very simple XML format that will resemble the component
definition language of Pragmatier. It may be as simple as BinaryCloud
entity definition format without the database schema specific tags.

Anyway, my main goal is to complete the software project development
cycle. I have defined some XML formats for project specification, risk
analysis, sub-system architecture, use case and actor definition. Now I
want to some how to evolve and document project key abstractions to
define the component structure. The entity abstractions will be defined
via the component format that will be used to generate the DAL classe,
but I still haven't all figured out.


>>Anyway, if you have tried some of my classes from the PHP Classes site,
>>you have most likely used MetaL generated code without knowing.
>
>
> Yep :)
>
> When Manuel releases metal open source, I want to try and get standard metal
> templates working with binarycloud :)

I was considering to move all the stuff to a project in the tigris.org .
I wanted to ask you about how smooth the transition may occur. Do you
have access to the project CVS repository maybe via SSH, so you can
manipulate it directly if necessary? Since it is all related, I may move
Metabase over there too, but I need to know if I will still have direct
control over CVS files.


>>For more information, take a look at this page:
>>
>>http://www.meta-language.net/
>

--

Regards,
Manuel Lemos

#72 From: Manuel Lemos <mlemos@...>
Date: Mon Sep 16, 2002 7:19 pm
Subject: Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/14/2002 12:11 AM, Marcus and Aviva wrote:
>> Coincidentally I am starting to work on a module for the MetaL
>> compiler engine that is meant to generate object persistent layers
>> eventually to SQL databases.
>>
>> Like you mentioned it will pick component descriptions and generate
>> database schemas for SQL table mappings including any intermediate
>> tables that are needed for many to many relationships. It will also
>> generate classes in MetaL code that can be generated to any of the
>> supported languages.
>
> In what format is the model defined?

It is not defined yet because I am just starting to work on it.


>> And then, you may ask: what is MetaL?
>
>
> I did not get to any example source code.

Actually when you see the MetaL ingredients and recipe steps you will
see a file icon at the bottom that you can click to open some MetaL XML
source files.


> I read through the slides. I am only currently interested in getting
> from MOF or XMI files (from UML tools) to SQL with PHP wrappers. I am
> more than half way to producing such a system as part of other work.

I understand that maybe you want to use MOF and XMI to integrate with
some tool that generates project files in such formats, right? If so,
what tools are you using? Rational Rose?

Anyway, I looked superficially at those formats and I did not like them
much because they rely on non-SML conformant structure as they use
attributes in XML tags. I wish XML designers avoided that because you
can't extend XML attributes as you can't use XML tags in attributes.

Anyway, it is very likely that I define a new format, maybe inspired in
Binary Cloud entity definition and also on Pragmatier component
definition language that is not XML but it is very easy to adapt and it
already addresses the issues of defining persistence layers to generate
classes automatically from such definitions.

Anyway, if you are looking for something already developed in PHP, you
may want to take a look at Binary Cloud that already has components for
generating code to manage entities.



> Thank you Manuel. I kind of thought you might be the one to reply. ;-)

I hope that means something good .

--

Regards,
Manuel Lemos

#73 From: Manuel Lemos <mlemos@...>
Date: Tue Sep 17, 2002 2:18 am
Subject: Re: [metabase-dev] Re: Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/16/2002 05:34 AM, alex black wrote:
  >>I liked most of those that just generate code but still it seems that
  >>some generate all the code that you possibly can use but in real
  >>applications you may not need all the methods. So, this is a point to
  >>keep in mind: generate only the code that the developer will hint that
  >>is necessary.
  >
  >
  > That's what we do in BC. There's a base of methods but nothing beyond
that.
  > We don't try to do your job for you, we just make it easier to get
set up.

I don't know if you got what I mean. I meant all DAL code is generated
by MetaL, so I plan to not need any base classes to inherit from. Each
entity will be implemented by one class only. It only will have methods
that the application needs. For instance, if the application does not a
delete method, it will not have a delete method. So, no useless code
will be generated.



  >>I also looked at you entity persistence layer. It seems more or less
  >>like what I would like but definitly without those database schema
  >>definitions because that is precisely what I want to avoid to manage
  >>manually.
  >
  >
  > What definition file did you look at?

One from the specifications book.


  > The point of entity definitions is that they are a superset of the
  > information you need for a particular task - the entity definition
  > represents all information you need to have about a set of fields in any
  > context.

I would not attach component properties to specific database table
fields. It may turn out that you decide to map things differently for a
specific component, or even use a different persistence layer other than
a SQL database. I think it would be better to specify the database
mappings if necessary in some other file. The Pragmatier format seems
more elegant.


  > So there's some DB schema stuff in there if you're usig a SQL database,
  > there's bits of information about default presentation, and of course
a lot
  > of field metadata.
  >
  > I think keeping all of that information in once place makes it _very_
easy
  > to manage the whole system and make updates, etc.
  >
  > We generate .schema files from entity definitions automatically - so you
  > only have to write one file.

Well, you seem to have to define database fields by hand anyway which
should be a thing that you needed to avoid in first place, IMHO.


  >>Too bad that the methods documentation is missing. Do you plan to
  >>document that soon?
  >
  >
  > There will be a complete code audit before binarycloud r2 RC1 is
released -
  > so all of that stuff will be added/checked/etc.

Any target dates?


  >>>That's very cool. At the moment we do not have extremely sophisticated
  >>>schema generation capabilities based on entity definitions - we will.
  >>
  > That's
  >
  >>>where we could use some help.
  >>
  >>Yes, at least some brainstorming would be helpful. What I have in mind
  >>is definining a very simple XML format that will resemble the component
  >>definition language of Pragmatier. It may be as simple as BinaryCloud
  >>entity definition format without the database schema specific tags.
  >
  >
  > Well, those are necessary if you're in SQL-land. I don't think you
want to
  > leave everything to a "generator" - I would prefer to have the option of
  > control over specific things in the DB. Admittadly we could leave
sequence
  > and index definition/generation to a tool... but even in that case
one could
  > make counter-arguments.

That seems contradicting the goal of persistency layers. The way I see
it, persistency layers are meant to avoid having you to code any SQL by
hand. Sure you may parameterize certain things like filter criteria and
so, but not schema management or standard Add/List/Update/Delete
operations. The way I see it, you just define properties, types, keys,
relationships and probably not much else, and the generator should
generate schemas and DAL classes code for you.

I don't see any particular situation where you need to specify for
instance table names because the generated DAL code will already  know
where are things, unless you want to map legacy databases where the
tables and fields you need to map are those that already exist and so
are not created by the schema generator.


  >>Anyway, my main goal is to complete the software project development
  >>cycle. I have defined some XML formats for project specification, risk
  >>analysis, sub-system architecture, use case and actor definition. Now I
  >>want to some how to evolve and document project key abstractions to
  >>define the component structure. The entity abstractions will be defined
  >>via the component format that will be used to generate the DAL classe,
  >>but I still haven't all figured out.
  >
  >
  > Cool, I think some of that could be integrated with binarycloud to all of
  > our benefit.

Unless I am see your entity package incorrectly, this is probably
something you already have. I would have to see more documentation of
that package.


  >>I was considering to move all the stuff to a project in the tigris.org .
  >>I wanted to ask you about how smooth the transition may occur. Do you
  >>have access to the project CVS repository maybe via SSH, so you can
  >>manipulate it directly if necessary? Since it is all related, I may move
  >>Metabase over there too, but I need to know if I will still have direct
  >>control over CVS files.
  >
  >
  > You don't have direct control over the top level repository.
  >
  > That also made me nervous at first but they are _EXTREMELY_ cool people,
  > I've had nothing but good experiences with them. If I need something, I
  > ask... and they get it done quick. Very cool.
  >
  > I needed an MBOX export of the list archives for MARC, jason @
collabNet had
  > it done in ~3 hours.

humm... I think it is better to stick to my own CVS repository then.


--

Regards,
Manuel Lemos

#74 From: Manuel Lemos <mlemos@...>
Date: Tue Sep 17, 2002 3:58 am
Subject: Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/16/2002 09:21 PM, Marcus and Aviva wrote:
>> I understand that maybe you want to use MOF and XMI to integrate with
>> some tool that generates project files in such formats, right? If so,
>> what tools are you using? Rational Rose?
>
>
> None yet. I am moving our own formats into these formats for future
> compatibility with this these tools. This type of tool is very expensive
> (of the order of 20000 ukpounds for a three seat set-up) and so not
> something we want to jump into until the pieces are in place. PHP is not
> the only language that we use, but it is a pretty key component.

You may want to try this program: http://uml.sourceforge.net/ . It
supports XMI and generates Java and C++. It does not update previously
generated classes though. But it is already very good for a Open Source
UML modeller.


>> Anyway, I looked superficially at those formats and I did not like
>> them much because they rely on non-SML conformant structure as they
>> use attributes in XML tags. I wish XML designers avoided that because
>> you can't extend XML attributes as you can't use XML tags in attributes.
>
>
> I have only just started looking at XMI. You have hit me in my
> abbreviation impairment spot. What is SML? I agree with you on the dead

SML is Simplified XML or Minimal XML. It does not use tag attributes or
characters entities.


> end nature of attributes, but although rather final they are easy to
> parse. And easier on the human eye. What particular problem did you have
> (with XMI) or was it general distaste?

That is just one problem. Another problem, which may not quite be of XMI
but of UML is that your project does not start in use cases. So, you do
not start modelling from graphics but rather from some text document
specification that includes requirements and eventually risk analisis.

Only then, you start modelling your system in use cases actors and
eventually distributing them among sub-systems that you divide according
to a convinient architecture.

You can use UML to document this, but UML is just a graphical help. If
the UML editor does not support a detailed level of documentation that
is insuficient.

That is why I defined my own XML formats to document project
description, requirements, risks, sub-system architecture, actors, use
cases with scenario flow step description and so on. I could not be sure
   if XMI supports all this. What I could realized is that in the worst
case I can generate or update XMI files from my XML formats for the
usual incremental project design workflow.


>> Anyway, if you are looking for something already developed in PHP, you
>> may want to take a look at Binary Cloud that already has components
>> for generating code to manage entities.
>
>
> Binary Cloud is the front runner.
>
> I don't yet want to port current projects from our own persistence
> mechanism, even at the expense of reinventing the wheel a little, unless
> there is a big and immediate win.

Yes, it would not be advisable to redo what already works suitably.


> Current plan...
> 1) Refactor current project to use XMI for the DB schemas.
> 2) Switch from our current homebrew XML/PHP to this system.
> 3) Buy some flash UML tool and never write a line of code again!
>
> :-)

That is just for modelling entities. You still have to write code for
business components, even if you can do that from inside the UML tool
you buy.


>>> Thank you Manuel. I kind of thought you might be the one to reply. ;-)
>>
>> I hope that means something good .
>
> Of course it does.

:-)


--

Regards,
Manuel Lemos

#75 From: Alex Black <enigma@...>
Date: Tue Sep 17, 2002 5:55 pm
Subject: Re: [binarycloud-dev] RE: [metabase-dev] Re: Anyone working on XMI to PHP code generation?
zeomis
Send Email Send Email
 
> Never used this tool, but I have heard good thingd about it. So it may
> or may not do what you guys need: http://argouml.tigris.org/

PoseidonURL is very good, based on Argo.

No class generation...

I'm inclined to use a charting tool like OmniG to create UML diagrams that
people just use as guides.

> Then another general comment. Something that may also make sense is take
> a common open format and if you don't like its internal formatting (like
> non SML etc.) write an XSL to convert to your format.

We have that in binarycloud, works REALLY WELL.

> Anyways hopefully my comment were useful, since I did not really dive
> deep into what you guys are talking about.

:)

_a

#76 From: Manuel Lemos <mlemos@...>
Date: Wed Sep 18, 2002 3:11 am
Subject: Re: [metabase-dev] Re: Anyone working on XMI to PHP code generation?
mallemos
Send Email Send Email
 
Hello,

On 09/17/2002 03:52 AM, Lukas Smith wrote:
>>You may want to try this program: http://uml.sourceforge.net/ . It
>>supports XMI and generates Java and C++. It does not update previously
>>generated classes though. But it is already very good for a Open
>
> Source
>
>>UML modeller.
>>
>
>
> Never used this tool, but I have heard good thingd about it. So it may
> or may not do what you guys need: http://argouml.tigris.org/

Yes, I tried that in the past but I gave up because just for modelling
it seemed very complete but I dropped it because it was not good for
documentation which is what I was looking for then. It also did not look
like it would be able to save as XMI, but I don't know about that today.


> Then another general comment. Something that may also make sense is take
> a common open format and if you don't like its internal formatting (like
> non SML etc.) write an XSL to convert to your format.

Yes, that is a possibility. Anyway what I am looking for now is
something that generates DAL classes and database schemas from component
descriptions so I never have to write any more SQL for implementing
persistence layers. This provides a huge speedup to medium to large
sized applications.


--

Regards,
Manuel Lemos

#77 From: Manuel Lemos <mlemos@...>
Date: Fri Sep 27, 2002 9:10 am
Subject: MetaL released for evaluation
mallemos
Send Email Send Email
 
Hello,

Finally I made time to put together a release of MetaL for public
evaluation.

I am not yet announcing this widely because I need some feedback on the
material that I just made available. So, please go to MetaL site and
evaluate specifically the MetaL FAQ page and the archives available for
download and let me know if all is easy to understand and if is there
any information that you feel that is missing:

http://www.meta-language.net/

--

Regards,
Manuel Lemos

#78 From: Manuel Lemos <mlemos@...>
Date: Fri Nov 1, 2002 10:05 am
Subject: MetaL data persistence layer module released
mallemos
Send Email Send Email
 
Hello,

Finally I was able to make a initial release of MetaL persistence module.

There is a more detailed news release in the page below, but basically
this a new meta-meta-programming module for the MetaL compiler engine
that is able to generate an API that implements a persistence layer to
store and retrieve objects in persistence storage.

It takes a description of classes of entity objects in XML and generates
all the classes and schemas that are needed to provide the persistence
API. There is much more detail in the news page below.

Anyway, this module is an alpha stage. I just released it now because I
would like some feedback on the usage of the module from people that
know data persistence layers and make some criticisms so I can spot any
design issues early in the development of this module.

Currently, I have provide a sample component than you can try simply by
going into metal/test/persistence and do:

php -q build.php some.component

I have provided an example component that could be the what a normal
Content Management System needs in terms of objects that need to be
persisted. In the same directory take a look at cms.component . Build it
with the command line:

php -q build.php cms.component

You will see that inside a directory named install it created several
classes: a factory class, a few classes for each one defined in the
cms.component XML file, a schema installation class and a database
schema definition in a XML format.

Although there could be other types of persistent storage (XML files,
LDAP, etc..), currently MetaL persistence layer only generates code to
interface to SQL based relational databases.

Currently it uses Metabase API to interface with databases. PEAR::MDB is
expected to work with Metabase API wrapper. It could use other database
API and maybe in the future it will, but for now Metabase is very
adequate because it is portable (many databases supported with the same
code) and provides schema management with schema definitions in XML.

Anyway, if you are interested in these subjects, please take a look and
follow up to MetaL mailing list (metal-dev@yahoogroups.com) or mail me
privately (mlemos@...).

http://www.meta-language.net/news-2002-11-01-persistence.html

--

Regards,
Manuel Lemos

#79 From: Manuel Lemos <mlemos@...>
Date: Thu Dec 5, 2002 5:14 pm
Subject: ANNOUNCE: Metastorage object persistence API generator
mallemos
Send Email Send Email
 
Hello,

Finally I made time to release a full blown application based on MetaL
compiler persistence module.

Here is the release announcement that may also be found on the site:

http://www.meta-language.net/news-2002-12-05-metastorage.html

     _________________________________________________________________

Released Metastorage generator
Manuel Lemos, 2002-12-05 16:11:44 GMT

Metastorage is an application that is capable of generating
persistence layer APIs. It takes a component definition defined in the
Component Persistence Markup Language (CPML), a XML based format, and
generates classes and storage schemas in a given target programming
language.

Using CPML, developers can focus their efforts on the modeling of data
structures that hold the information and the relationships between the
entities that their applications deal with. Metastorage takes care of
generating all the necessary code to store and retrieve such data
structures from persistent storage containers like relational
databases.

The main goal of Metastorage is to drastically reduce the time to
develop applications that traditionally use on SQL based relational
databases.

The generated APIs consist of a sets of classes that provide an Object
Oriented interface to the objects of the classes modeled using CPML.

The generated APIs are also capable of installing the data schema in
the persistence container, which in the case of a relational database
is the set of tables that will hold the persistent objects. This
completely eliminates the need to write any SQL queries manually.
CPML is independent of the type of persistent container. This means
that while it can be used to model classes of persistent objects that
may be stored in relational databases, such objects may as well be
stored in other types of persistence containers.

For instance, if an application needs to move a directory of objects
with user information from a relational database to a LDAP server to
increase the application scalability, the same CPML component
definition would be used. Metastorage would then generate classes
objects that implement the same API for interfacing with a LDAP server
that is compatible with the API generated to interface with relational
databases. This make the migration process easier and with reduced
risks.

Another possible benefit of the persistence container independence of
the APIs generated by Metastorage, is the case where an application
may need to run in environments where a SQL based database server is
not available. In that case the same API could be generated to store
persistent objects in flat file databases or plain XML files.

For now, the current version of Metastorage only supports the
generation of PHP code based on the database independent Metabase API.
This means that it may also interface with PEAR::MDB database
abstraction layer using its built-in Metabase API wrapper. In
consequence, many types of relational databases are already supported.

Since this is the first release of Metastorage, there is plenty of
room for improvement in the possibilities of the generated persistence
APIs and the level of optimization of the generated code. In the
future it will be supported other languages besides PHP, other
database APIs besides Metabase and other persistence containers
besides relational databases.

Metastorage is based on MetaL compiler persistence module. Like MetaL,
Metastorage is Open Source and is distributed with BSD like software
license. Downloadable archives and documentation with an example of
component definition are available from the MetaL site.


--

Regards,
Manuel Lemos

#80 From: Alessander Thomaz <kappuera@...>
Date: Thu Dec 5, 2002 5:25 pm
Subject: Re: ANNOUNCE: Metastorage object persistence API generator
kappuera@...
Send Email Send Email
 
Fala Manuel,
Nossa...
foi bom me mandar esse email...
lembrei que tenho que traduzir a apresentação do metal..

vou ver se consigo essa semana,
ou antes da proxima reuniao que é semana que vem..

alguma coisa que queira inserir na apresentação?

[]'s Alessander


At 15:14 05/12/02 -0200, you wrote:
>Hello,
>
>Finally I made time to release a full blown application based on MetaL
>compiler persistence module.
>
>Here is the release announcement that may also be found on the site:
>
>http://www.meta-language.net/news-2002-12-05-metastorage.html
>
>     _________________________________________________________________
>
>Released Metastorage generator
>Manuel Lemos, 2002-12-05 16:11:44 GMT
>
>Metastorage is an application that is capable of generating
>persistence layer APIs. It takes a component definition defined in the
>Component Persistence Markup Language (CPML), a XML based format, and
>generates classes and storage schemas in a given target programming
>language.
>
>Using CPML, developers can focus their efforts on the modeling of data
>structures that hold the information and the relationships between the
>entities that their applications deal with. Metastorage takes care of
>generating all the necessary code to store and retrieve such data
>structures from persistent storage containers like relational
>databases.
>
>The main goal of Metastorage is to drastically reduce the time to
>develop applications that traditionally use on SQL based relational
>databases.
>
>The generated APIs consist of a sets of classes that provide an Object
>Oriented interface to the objects of the classes modeled using CPML.
>
>The generated APIs are also capable of installing the data schema in
>the persistence container, which in the case of a relational database
>is the set of tables that will hold the persistent objects. This
>completely eliminates the need to write any SQL queries manually.
>CPML is independent of the type of persistent container. This means
>that while it can be used to model classes of persistent objects that
>may be stored in relational databases, such objects may as well be
>stored in other types of persistence containers.
>
>For instance, if an application needs to move a directory of objects
>with user information from a relational database to a LDAP server to
>increase the application scalability, the same CPML component
>definition would be used. Metastorage would then generate classes
>objects that implement the same API for interfacing with a LDAP server
>that is compatible with the API generated to interface with relational
>databases. This make the migration process easier and with reduced
>risks.
>
>Another possible benefit of the persistence container independence of
>the APIs generated by Metastorage, is the case where an application
>may need to run in environments where a SQL based database server is
>not available. In that case the same API could be generated to store
>persistent objects in flat file databases or plain XML files.
>
>For now, the current version of Metastorage only supports the
>generation of PHP code based on the database independent Metabase API.
>This means that it may also interface with PEAR::MDB database
>abstraction layer using its built-in Metabase API wrapper. In
>consequence, many types of relational databases are already supported.
>
>Since this is the first release of Metastorage, there is plenty of
>room for improvement in the possibilities of the generated persistence
>APIs and the level of optimization of the generated code. In the
>future it will be supported other languages besides PHP, other
>database APIs besides Metabase and other persistence containers
>besides relational databases.
>
>Metastorage is based on MetaL compiler persistence module. Like MetaL,
>Metastorage is Open Source and is distributed with BSD like software
>license. Downloadable archives and documentation with an example of
>component definition are available from the MetaL site.
>
>
>--
>
>Regards,
>Manuel Lemos
>
>
>
>
>To unsubscribe from this group, send an email to:
>metal-dev-unsubscribe@yahoogroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

_______________________________________________________________________
Yahoo! Encontros
O lugar certo para encontrar a sua alma gêmea.
http://br.encontros.yahoo.com/

#81 From: Alessander Thomaz <kappuera@...>
Date: Thu Dec 5, 2002 5:33 pm
Subject: Re: ANNOUNCE: Metastorage object persistence API generator
kappuera@...
Send Email Send Email
 
Sorry,
This email not is public list, are is private to manuel lemos.

Best Resgards,
Alessander Thomaz


At 15:25 05/12/02 -0200, you wrote:
>Fala Manuel,
>Nossa...
>foi bom me mandar esse email...
>lembrei que tenho que traduzir a apresentação do metal..
>
>vou ver se consigo essa semana,
>ou antes da proxima reuniao que é semana que vem..
>
>alguma coisa que queira inserir na apresentação?
>
>[]'s Alessander
>
>
>At 15:14 05/12/02 -0200, you wrote:
> >Hello,
> >
> >Finally I made time to release a full blown application based on MetaL
> >compiler persistence module.
> >
> >Here is the release announcement that may also be found on the site:
> >
> >http://www.meta-language.net/news-2002-12-05-metastorage.html
> >
> >     _________________________________________________________________
> >
> >Released Metastorage generator
> >Manuel Lemos, 2002-12-05 16:11:44 GMT
> >
> >Metastorage is an application that is capable of generating
> >persistence layer APIs. It takes a component definition defined in the
> >Component Persistence Markup Language (CPML), a XML based format, and
> >generates classes and storage schemas in a given target programming
> >language.
> >
> >Using CPML, developers can focus their efforts on the modeling of data
> >structures that hold the information and the relationships between the
> >entities that their applications deal with. Metastorage takes care of
> >generating all the necessary code to store and retrieve such data
> >structures from persistent storage containers like relational
> >databases.
> >
> >The main goal of Metastorage is to drastically reduce the time to
> >develop applications that traditionally use on SQL based relational
> >databases.
> >
> >The generated APIs consist of a sets of classes that provide an Object
> >Oriented interface to the objects of the classes modeled using CPML.
> >
> >The generated APIs are also capable of installing the data schema in
> >the persistence container, which in the case of a relational database
> >is the set of tables that will hold the persistent objects. This
> >completely eliminates the need to write any SQL queries manually.
> >CPML is independent of the type of persistent container. This means
> >that while it can be used to model classes of persistent objects that
> >may be stored in relational databases, such objects may as well be
> >stored in other types of persistence containers.
> >
> >For instance, if an application needs to move a directory of objects
> >with user information from a relational database to a LDAP server to
> >increase the application scalability, the same CPML component
> >definition would be used. Metastorage would then generate classes
> >objects that implement the same API for interfacing with a LDAP server
> >that is compatible with the API generated to interface with relational
> >databases. This make the migration process easier and with reduced
> >risks.
> >
> >Another possible benefit of the persistence container independence of
> >the APIs generated by Metastorage, is the case where an application
> >may need to run in environments where a SQL based database server is
> >not available. In that case the same API could be generated to store
> >persistent objects in flat file databases or plain XML files.
> >
> >For now, the current version of Metastorage only supports the
> >generation of PHP code based on the database independent Metabase API.
> >This means that it may also interface with PEAR::MDB database
> >abstraction layer using its built-in Metabase API wrapper. In
> >consequence, many types of relational databases are already supported.
> >
> >Since this is the first release of Metastorage, there is plenty of
> >room for improvement in the possibilities of the generated persistence
> >APIs and the level of optimization of the generated code. In the
> >future it will be supported other languages besides PHP, other
> >database APIs besides Metabase and other persistence containers
> >besides relational databases.
> >
> >Metastorage is based on MetaL compiler persistence module. Like MetaL,
> >Metastorage is Open Source and is distributed with BSD like software
> >license. Downloadable archives and documentation with an example of
> >component definition are available from the MetaL site.
> >
> >
> >--
> >
> >Regards,
> >Manuel Lemos
> >
> >
> >
> >
> >To unsubscribe from this group, send an email to:
> >metal-dev-unsubscribe@yahoogroups.com
> >
> >
> >
> >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>_______________________________________________________________________
>
>Yahoo! Encontros
>
>O lugar certo para encontrar a sua alma gêmea.
>
>http://br.encontros.yahoo.com/
>
>
>
>To unsubscribe from this group, send an email to:
>metal-dev-unsubscribe@yahoogroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

_______________________________________________________________________
Busca Yahoo!
O melhor lugar para encontrar tudo o que você procura na Internet
http://br.busca.yahoo.com/

#82 From: Manuel Lemos <mlemos@...>
Date: Mon Dec 9, 2002 3:47 pm
Subject: Metastorage generates Entity-Relationship class diagrams in UML
mallemos
Send Email Send Email
 
Hello,

As announced last week, Metastorage is an application that generates
customizable APIs made of classes that store and retrieve objects stored
in persistent storage containers like for instance relational databases.
The generated code uses Metabase API and consequently supports PEAR::MDB
via Metabase API wrapper.

In addition to that, the current version is also capable of generating
automatically Entity-Relationship graphs using UML to present diagrams
of the generated classes.

The generated Entity-Relationship graphs are described in the DOT
language format. This format is used by the Graphviz software package
from AT&T research labs. The DOT file can be rendered in many common
image formats using Graphviz tools to generate a graph image.

An example of an Entity-Relationship UML diagram generated by the
program from a component example definition is included in the
Metastorage documentation.

Here you may find the complete announcement with example graphics and
the relevant links:

http://www.meta-language.net/news-2002-12-09-metastorage.html

--

Regards,
Manuel Lemos

#83 From: Jason Hines <jch@...>
Date: Sat Dec 14, 2002 9:38 pm
Subject: MetaStorage example application
oweff
Send Email Send Email
 
Is there an example available anywhere that demonstrates how the
generated data classes / factory class should be interfaced within an
external PHP script?  The documentation does not illustrate this.

My first inclination would be something like:

include("cms.php");
include("article.php");
$article = new articleclass();
//print_r($article);

Thanks.
jason

#84 From: Manuel Lemos <mlemos@...>
Date: Sun Dec 15, 2002 12:17 am
Subject: Re: MetaStorage example application
mallemos
Send Email Send Email
 
Hello,

On 12/14/2002 07:38 PM, Jason Hines wrote:
> Is there an example available anywhere that demonstrates how the
> generated data classes / factory class should be interfaced within an
> external PHP script?  The documentation does not illustrate this.

Yes, you are right, the documentation needs to be improved on this
aspect. I will try to provide something in that direction soon.


> My first inclination would be something like:
>
> include("cms.php");
> include("article.php");

Yes...

> $article = new articleclass();

No, objects should be created by the factory class, calling functions
defined the component XML definition. These functions can be to create a
new object from scratch or to create objects retrieved from the
persistence contains which in the current Metastorage version can only
be a relational database.

I will provide a better example later, but a possible script to create
and persist an article object would look like this:

require("cms.php");
require("article.php");

$factory=&new cmsclass;
$factory->connection="mysql://localhost/cms";
$factory->includepath="metabase/relative/path/to/script";

if($factory->initialize())
{
	 $article=$factory->createarticle();
	 if($article!=null)
	 {
		 $article->title="My first article";
		 $article->persistarticle();
	 }
	 $factory->finalize();
}

if(strlen($factory->error))
	 echo "Error: ".$factory->error;



--

Regards,
Manuel Lemos

#85 From: "wgollino <wgollino@...>" <wgollino@...>
Date: Tue Dec 31, 2002 3:21 pm
Subject: metastorage persist code
wgollino
Send Email Send Email
 
First of all, I have to say that I really like the metastorage app.
Anything that makes work simpler is a Good Idea :)

I've trying to test some metastorage generated classes, and I'm
encountering a data consistency problem. I'm using the metastorage
tarball from the website, not CVS.

When I call the persist method on an object, and then try to retrieve
all the objects, the newly added object hasn't been saved yet:

$factory=....(init code)

// create a new User object
$user=$factory->createUser();
$user->username="abc";
$user->persist();

// list all User objects
$users=$factory->getAllUsers();
foreach($users as $u) print "id=$u->id, username=$u->username<br>";
$factory->finalize();
print "done";

-------------------------
output:

id=3, username=abc
id=4, username=abc
id=5, username=abc
id=6, username=
done

-------------------------

The next time I run the script, id=6 will have a username and id=7
will now be blank. It seems that the object doesn't actually get saved
until finalize() is called on the factory. If I call finalize() and
re-initialize the factory between the persist() and getAllUsers()
calls, it works properly and all the User objects are properly
retrieved.

Is there a way of avoiding having to re-initialize the factory between
calls?

Thanks,

Wil

#86 From: Manuel Lemos <mlemos@...>
Date: Tue Dec 31, 2002 9:18 pm
Subject: Re: metastorage persist code
mallemos
Send Email Send Email
 
Hello,

On 12/31/2002 01:21 PM, wgollino  wrote:
> First of all, I have to say that I really like the metastorage app.
> Anything that makes work simpler is a Good Idea :)
>
> I've trying to test some metastorage generated classes, and I'm
> encountering a data consistency problem. I'm using the metastorage
> tarball from the website, not CVS.
>
> When I call the persist method on an object, and then try to retrieve
> all the objects, the newly added object hasn't been saved yet:
>
> $factory=....(init code)
>
> // create a new User object
> $user=$factory->createUser();

Here is the problem. PHP object assignment creates a new object. Change
this to:

$user=&$factory->createUser();


> Is there a way of avoiding having to re-initialize the factory between
> calls?

Initializing the factory is only needed once per script. It is meant to
setup the database connection so you can't get away with it. I could
make it a constructor but you would still need to call finalize at the
script end because PHP 4 does not support destructors except when using
some ugly hacks.

Hopefully when PHP 5 is out I can make Metastorage generate optionally
optimized code that is nicer.

Happy new year 2003 to everybody.

--

Regards,
Manuel Lemos

#87 From: "wgollino <wgollino@...>" <wgollino@...>
Date: Fri Jan 3, 2003 4:14 pm
Subject: Re: metastorage persist code
wgollino
Send Email Send Email
 
Hi,

That solved the problem. Thanks!

- Willie Gollino

--- In metal-dev@yahoogroups.com, Manuel Lemos <mlemos@a...> wrote:
> Hello,
>
> On 12/31/2002 01:21 PM, wgollino  wrote:
> > First of all, I have to say that I really like the metastorage
app.
> > Anything that makes work simpler is a Good Idea :)
> >
> > I've trying to test some metastorage generated classes, and I'm
> > encountering a data consistency problem. I'm using the metastorage
> > tarball from the website, not CVS.
> >
> > When I call the persist method on an object, and then try to
retrieve
> > all the objects, the newly added object hasn't been saved yet:
> >
> > $factory=....(init code)
> >
> > // create a new User object
> > $user=$factory->createUser();
>
> Here is the problem. PHP object assignment creates a new object.
Change
> this to:
>
> $user=&$factory->createUser();
>
>
> > Is there a way of avoiding having to re-initialize the factory
between
> > calls?
>
> Initializing the factory is only needed once per script. It is
meant to
> setup the database connection so you can't get away with it. I
could
> make it a constructor but you would still need to call finalize at
the
> script end because PHP 4 does not support destructors except when
using
> some ugly hacks.
>
> Hopefully when PHP 5 is out I can make Metastorage generate
optionally
> optimized code that is nicer.
>
> Happy new year 2003 to everybody.
>
> --
>
> Regards,
> Manuel Lemos

#88 From: Mike Carter <mcarter@...>
Date: Fri Jan 17, 2003 4:22 pm
Subject: RE: File - CVS instructions
mcarter@...
Send Email Send Email
 
Hi,

> -----Original Message-----
> From: metal-dev Moderator [mailto:metal-dev-owner@yahoogroups.com]
>
> MetaL code repository is available by CVS at: cvs.meta-language.net

Due to the company network I am unable to access non "standard" ports due to
the firewall.

This has prevented me from connecting to CVS outside the buidling. As a work
around I wondered if there was a CVS frontend available, or if it is planned
anytime soon?

At least then I could see what has been updated and maybe download it via
that interface - like the PEAR project works.

Regards,


Mike Carter

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

#89 From: Steve Fisk <sfisk@...>
Date: Fri Jan 17, 2003 5:29 pm
Subject: RE: Metastorage
sfisk@...
Send Email Send Email
 
Thanks for your correspondence - I feel a lot happier about the whole thing
now - it has just taken a whole day of reading the manual, your replies and
cms.component to get to grips with most things and why you use them where
you do - two little things still have me a bit befuddled.

Mike has verbally told me that you can have several components that talk to
the same database provided every class within the component is in the same
component as one it depends on or has to talk to.  How do you set the create
database option to only create one database and not one for every component?

Finally - I don't really understand how the addtocollection type function
works - it might be because it's last thing on a Friday and my brain is
fried but would you mind running over it with me and then I can get my
thinking gear around it at some point on Monday?

I appreciate your help up to now and thanks in advance for this

Regards

Steve Fisk

Web Application Developer
KOA Solutions Ltd
Tel : 01925 758229
FAX : 01925 758023

This message is confidential.

Unless you are the named addressee or their delegated representative you may
not use, disclose, or copy the contents of the e-mail.

If you are not the named addressee please notify the sender immediately and
delete the material from your computer.

Any views or opinions contained in this e-mail are solely those of the
author unless expressly stated otherwise

-----Original Message-----
From: Manuel Lemos [mailto:mlemos@...]
Sent: 17 January 2003 02:44
To: Steve Fisk
Subject: Re: Metastorage

Hello,

On 01/16/2003 04:14 PM, Steve Fisk wrote:
> Is there a set of functions that you would recommend in each class and
> some that are more specific to Factory?  We are starting to understand
> things a little better now – think we have figured out how the
> collection tags work - but are still not sure which functions it is
> important to have in each class and which in the factory class.  Have
> you got any suggestions to that effect or any more detailed examples
> than cms.component that we could look at?

It is actually very simple. Either the factory or the classes will only
have the functions that you declare in the component definition.

The factory will have functions that create object either from scratch
or retrieving them from the database, like create a new object of this
class or get me all objects of this class.

The classes will have functions that to execute actions on objects that
are already created like save this object to the database or get me all
objects of some class collection that relate to this object.


--

Regards,
Manuel Lemos


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.437 / Virus Database: 245 - Release Date: 06/01/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.437 / Virus Database: 245 - Release Date: 06/01/2003


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

#90 From: Manuel Lemos <mlemos@...>
Date: Sat Jan 18, 2003 1:57 am
Subject: Re: RE: File - CVS instructions
mallemos
Send Email Send Email
 
Hello,

On 01/17/2003 02:22 PM, Mike Carter wrote:
>>MetaL code repository is available by CVS at: cvs.meta-language.net
>
>
> Due to the company network I am unable to access non "standard" ports due to
> the firewall.
>
> This has prevented me from connecting to CVS outside the buidling. As a work
> around I wondered if there was a CVS frontend available, or if it is planned
> anytime soon?
>
> At least then I could see what has been updated and maybe download it via
> that interface - like the PEAR project works.

A CVS frontend is just for browsing. It is not convinient for dowloading
the latest developments of of the project in a single archive.

I will look for the possibility of generating daily .tar.gz and .zip
archives that you may download via the Web.

--

Regards,
Manuel Lemos

#91 From: Manuel Lemos <mlemos@...>
Date: Sat Jan 18, 2003 2:16 am
Subject: Re: RE: Metastorage
mallemos
Send Email Send Email
 
Hello,

On 01/17/2003 03:29 PM, Steve Fisk wrote:
> Thanks for your correspondence - I feel a lot happier about the whole thing
> now - it has just taken a whole day of reading the manual, your replies and
> cms.component to get to grips with most things and why you use them where
> you do - two little things still have me a bit befuddled.
>
> Mike has verbally told me that you can have several components that talk to
> the same database provided every class within the component is in the same
> component as one it depends on or has to talk to.  How do you set the create
> database option to only create one database and not one for every component?

Metastorage generates classes for creating or updating the database
schemas. You can run the installschema type function as many times as
you want. But on the first time, only the first class you call install
schema may actually create the database, so you have to set the variable
createdatabase to 0 for the other classes.


> Finally - I don't really understand how the addtocollection type function
> works - it might be because it's last thing on a Friday and my brain is
> fried but would you mind running over it with me and then I can get my
> thinking gear around it at some point on Monday?

Don't worry, software modelling is really abstract and so it requires a
lot of concentration.

addtocollection type functions are meant to add objects to a collection
of an object of a given class. For instance, in the cms.component
example, you have articles and categories of articles.

To add a article object to a given category object, there is the
addarticle function of the category class that is of type addtocollection.

So, at run time if you have an category object in variable $c and a
article object in variable $a, you just execute $c->addarticle($a) and,
assuming that it succeded, from them on the article in $a will belong to
the collection named articles of the category object in $c.

Since the articles collection of the categories class references a
member of the article class named categories that is also a collection
pointing back to the categories class, the category object in $c is also
implicitly added to the categories collection of the article object in $a.

This a many to many relationship. An article can be in many categories
and a category may have many articles. Although you should not be
concerned with the actual implementation, this kind of relationship is
implemented with an additional database table that contain references to
   the objects of both classes that relate to each other via these
collections.

--

Regards,
Manuel Lemos


>>Is there a set of functions that you would recommend in each class and
>>some that are more specific to Factory?  We are starting to understand
>>things a little better now – think we have figured out how the
>>collection tags work - but are still not sure which functions it is
>>important to have in each class and which in the factory class.  Have
>>you got any suggestions to that effect or any more detailed examples
>>than cms.component that we could look at?
>
>
> It is actually very simple. Either the factory or the classes will only
> have the functions that you declare in the component definition.
>
> The factory will have functions that create object either from scratch
> or retrieving them from the database, like create a new object of this
> class or get me all objects of this class.
>
> The classes will have functions that to execute actions on objects that
> are already created like save this object to the database or get me all
> objects of some class collection that relate to this object.

#92 From: Manuel Lemos <mlemos@...>
Date: Mon Jan 20, 2003 5:29 am
Subject: Metastorage project progress tracking XML-RSS feed
mallemos
Send Email Send Email
 
Hello,

I have just made available a XML-RSS news feed to help keep tracking the
progress of the Metastorage progress.

This is a 3 in 1 file: ChangeLog, TODO list and NEWS feed that you can
grab with any RSS feed reader with one detail: feed readers will not
distinguish todo from done items. So, you would better keep an eye on
this page with a XML capable browser that highlights the done items to
distinguish them from the done items because I used special tags from
the XML-RSS progress that I created (although I have not yet documented).

http://www.meta-language.net/metastorage-progress.xml

As you may see, the latest developments include the ability to define
entity classes in separate files and also the availability of daily
snapshot archives of the CVS repository that are now available from the
download page for those that can't access the CVS repository for some
reason. The CVS repository also includes MetaL and Metabase that are
necessary to use Metastorage.

http://www.meta-language.net/download.html#snapshots

These are not major new features and so they are not yet announced in
the main site news feed. They will be announce in the next major release.

http://www.meta-language.net/news.xml

Stay tuned.

--

Regards,
Manuel Lemos

#93 From: Mike Carter <mcarter@...>
Date: Mon Jan 20, 2003 10:06 am
Subject: RE: Metastorage project progress tracking XML-RSS fee d
mcarter@...
Send Email Send Email
 
> -----Original Message-----
> From: Manuel Lemos [mailto:mlemos@...]
>
> As you may see, the latest developments include the ability to define
> entity classes in separate files and also the availability of daily

Brilliant :-) Thanks for the effort over the weekend!


> snapshot archives of the CVS repository that are now
> available from the
> download page for those that can't access the CVS repository for some
> reason. The CVS repository also includes MetaL and Metabase that are
> necessary to use Metastorage.
>
> http://www.meta-language.net/download.html#snapshots

Nice.  Thankyou Manuel.

Regards,

Mike C

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

#94 From: Mike Carter <mcarter@...>
Date: Tue Jan 21, 2003 2:16 pm
Subject: HTML forms and Metastorage
mcarter@...
Send Email Send Email
 
Hi all?

I was wondering if anybody has bothered to work on a way of generating
default HTML form templates based on component class schemas - as a nice way
of getting simple admin screens knocked out ready for some input to be put
into the newly generated database by MetaStorage/MetaBase ?

The templates may (or should?) also contain the relevant code to bind the
HTML form fields with the MetaStorage class functions to enable getting
things running as quickly as possible after designing the XML schema.

Any suggestions or thoughts?  It may be possible to alter an existing class
to work with MetaStorage...?

Bye,

--
Mike Carter [web developer]
tel: 01925 758229 // fax: 01925 758023 // web: www.koa.uk.com

This message is confidential.
Unless you are the named addressee or their delegated representative you may
not use, disclose, or copy the contents of the e-mail. If you are not the
named addressee please notify the sender immediately and delete the material
from your computer. Any views or opinions contained in this e-mail are
solely those of the author unless expressly stated otherwise

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

#95 From: Steve Fisk <sfisk@...>
Date: Tue Jan 21, 2003 3:01 pm
Subject: Anyone know what this means?
sfisk@...
Send Email Send Email
 

Have got 4 classes in my component file – RecordEntry is the first one I declare in the XML and I use it to declare a collection thus:

 

<collection>

<name>RecordEntries</name>

<class>RecordEntry</class>

<reference>Member</reference>

</collection>

 

Error: it was specified a collection reference (Member) to non-existing class (RecordEntry) variable or collection for collection with the name "RecordEntries"

(File "medicalRecord.component", Line 131, Column 0, Byte 2037).

 

Anyone know what I’ve done wrong?

 

Cheers

 

Steve Fisk
Web Application Developer

KOA Solutions Ltd
Tel : 01925 758229
FAX : 01925 758023

This message is confidential.

Unless you are the named addressee or their delegated representative you may not use, disclose, or copy the contents of the e-mail.

If you are not the named addressee please notify the sender immediately and delete the material from your computer.

Any views or opinions contained in this e-mail are solely those of the author unless expressly stated otherwise

 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 10/01/2003


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

#96 From: Manuel Lemos <mlemos@...>
Date: Tue Jan 21, 2003 3:54 pm
Subject: Re: Anyone know what this means?
mallemos
Send Email Send Email
 
Hello,

On 01/21/2003 01:01 PM, Steve Fisk wrote:
> Have got 4 classes in my component file – RecordEntry is the first one I
> declare in the XML and I use it to declare a collection thus:
>
> <collection>
> <name>RecordEntries</name>
> <class>RecordEntry</class>
> <reference>Member</reference>
> </collection>
>
>
>
> Error: it was specified a collection reference (Member) to non-existing
> class (RecordEntry) variable or collection for collection with the name
> "RecordEntries"
>
> (File "medicalRecord.component", Line 131, Column 0, Byte 2037).
>
>
>
> Anyone know what I’ve done wrong?

This means that there seems to be no variable or collection in the class
   RecordEntry with the name Member. Keep in mind that all names are case
sensitive. So, Member is different than member.



--

Regards,
Manuel Lemos

Messages 67 - 96 of 555   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help