company logo

XMLString :: xml2Schema - Provide type definition for XML file

The function provides type definitions from an XML file in the dictionary of the database passed in rDatabase. Data types are derived from XML elements and attributes analyzing the XML string (heuristic type definition) and collecting attributes and subordinated elements for all XML element instances of a given type.

Data type names are created for all element names by preceding element names with "s_". Subordinated elements are added as reference members to the structure. When the element contains attributes, attributes are provided as attribute members of the data type. Element and attribute names are used as member names. For each element type an additional attribute is created with the name __text_data, which contains element data.

Attribute and element names are collected from all elements in the XML file, but not duplicated. Attribute names get a default size of 32 characters. The __text_data attribute gets 1023 characters.

The function returns false when an error has been found and true otherwise.

Return value:  Success ( bool  )

The value is true when the function was executed successfully. Otherwise the value is set to false.

Implementation overview

Implementation details

  1. Provide type definition for XML file
    bool XMLString  :: xml2Schema ( odaba::Database &rDatabase, odaba::String &sPath, odaba::StringCodingTypes eStringCodingType, odaba::String &sName, bool bTemp )

    The function provides type definitions from an XML file in the dictionary of the database passed in rDatabase. The top type name is the name passed in sName. When an empty name is passed, the data type name is the name of the XML file (sPath) without extension.

    When the coding type is defined in the XML file, undefinedCoding may be passed in eStringCodingType. When no coding type coud be determined, UTF8 is assumed.

    In order to create type definitions temporarily, true must be passed in bTemp.

    After creating database definitions, the file path is assigned to the type name option (name passed in sName or file name), which allows opening an XML property handle for accessing the XML file.

    • rDatabase - Database handle

      The database handle refers to an (usually) opened database. Calling functions with invalid database handles may cause an exception. For checking the database handle, isValid() can be called.

    • sPath - File path
    • eStringCodingType - String encoding type

      In case of unknown text encoding type undefinedCoding is used.

    • sName - Name
    • bTemp - Temporary option
  2. to list
  3. Provide type definition for XML string
    bool XMLString  :: xml2Schema ( odaba::Database &rDatabase, odaba::String &sName, bool bTemp )

    The function provides type definitions from the XML string in the dictionary of the database passed in rDatabase. The top type name is the name passed in sName.

    In order to create type definitions temporarily, true must be passed in bTemp.

    For accessing an XML file via property handle, the file path has to be assigned to an option with the name passed in sName.

    • rDatabase - Database handle

      The database handle refers to an (usually) opened database. Calling functions with invalid database handles may cause an exception. For checking the database handle, isValid() can be called.

    • sName - Name
    • bTemp - Temporary option
  4. to list