adoSchema::ConvertSchemaString PHP Method

ConvertSchemaString() public method

Call this method to convert a string containing an XML schema to a different AXMLS DTD version. For instance, to convert a schema created for an pre-1.0 version for AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version parameter is specified, the schema will be converted to the current DTD version. If the newFile parameter is provided, the converted schema will be written to the specified file.
See also: ConvertSchemaFile()
public ConvertSchemaString ( string $schema, string $newVersion = NULL, string $newFile = NULL ) : string
$schema string String containing XML schema that will be converted.
$newVersion string DTD version to convert to.
$newFile string File name of (converted) output file.
return string Converted XML schema or FALSE if an error occurs.
    function ConvertSchemaString($schema, $newVersion = NULL, $newFile = NULL)
    {
        // grab current version
        if (!($version = $this->SchemaStringVersion($schema))) {
            return FALSE;
        }
        if (!isset($newVersion)) {
            $newVersion = $this->schemaVersion;
        }
        if ($version == $newVersion) {
            $result = $schema;
        } else {
            $result = $this->TransformSchema($schema, 'convert-' . $version . '-' . $newVersion);
        }
        if (is_string($result) and is_string($newFile) and $fp = fopen($newFile, 'w')) {
            fwrite($fp, $result);
            fclose($fp);
        }
        return $result;
    }