Loading ...
Sorry, an error occurred while loading the content.

MetaL can generate full Java object classes

Expand Messages
  • Manuel Lemos
    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
    Message 1 of 1 , Dec 24, 2001
    View Source
    • 0 Attachment
      Class: XML writer

      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@...)
    Your message has been successfully submitted and would be delivered to recipients shortly.