adoSchema::ConvertSchemaFile PHP Метод

ConvertSchemaFile() публичный Метод

Call this method to convert the specified XML schema file 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.
См. также: ConvertSchemaString()
public ConvertSchemaFile ( string $filename, string $newVersion = NULL, string $newFile = NULL ) : string
$filename string Name of XML schema file that will be converted.
$newVersion string DTD version to convert to.
$newFile string File name of (converted) output file.
Результат string Converted XML schema or FALSE if an error occurs.
    function ConvertSchemaFile($filename, $newVersion = NULL, $newFile = NULL)
    {
        // grab current version
        if (!($version = $this->SchemaFileVersion($filename))) {
            return FALSE;
        }
        if (!isset($newVersion)) {
            $newVersion = $this->schemaVersion;
        }
        if ($version == $newVersion) {
            $result = _file_get_contents($filename);
            // remove unicode BOM if present
            if (substr($result, 0, 3) == sprintf('%c%c%c', 239, 187, 191)) {
                $result = substr($result, 3);
            }
        } else {
            $result = $this->TransformSchema($filename, 'convert-' . $version . '-' . $newVersion, 'file');
        }
        if (is_string($result) and is_string($newFile) and $fp = fopen($newFile, 'w')) {
            fwrite($fp, $result);
            fclose($fp);
        }
        return $result;
    }