Пример #1
0
                echo DOMMapper::marshal($components);
            } else {
                $item = $_SESSION["itemhandler"]->retrieve($urlparam[3]);
                $xmldom = new DOMDocument();
                if ($mdrecord && strlen($mdrecord) > 0) {
                    $records = $item->getMetaDataRecords();
                    $mdrecord = $records->get($mdrecord);
                    $domelement = $mdrecord->getContent();
                    $xmldom->appendChild($xmldom->importNode($domelement, true));
                    outdom($xmldom);
                } else {
                    $mdrecords = $item->getMetaDataRecords();
                    $mdrecords->remove("escidoc");
                    $outobj = DOMMapper::marshal($mdrecords);
                    $outxml = new DOMDocument();
                    $outxml->loadXML($outobj);
                    outdom($outxml);
                }
            }
        }
    }
} catch (AuthorizationException $e) {
}
function outdom($xmldom)
{
    $xsl = new XSLTProcessor();
    $xsldom = new DOMDocument();
    $xsldom->load("convert-remove-namespace.xslt");
    $xsl->importStyleSheet($xsldom);
    echo $xsl->transformToXML($xmldom);
}
Пример #2
0
        switch ($errcode) {
            case UPLOAD_ERR_INI_SIZE:
                throw new Exception("Filesize exceeds limit " . ini_get('upload_max_filesize') . "!");
            case UPLOAD_ERR_FORM_SIZE:
                throw new Exception("Filesize exceeds limit of HTML form!");
            case UPLOAD_ERR_PARTIAL:
                throw new Exception("Fileupload did not finish!");
            case UPLOAD_ERR_NO_FILE:
                throw new Exception("There was no file. Did you forget to select one?");
            default:
                throw new Exception("An error with unknown code \"" . $errcode . "\" occured.<br>Am I running on a very new PHP version?");
        }
    }
    if ($file['size'] < 1) {
        throw new Exception("Your uploaded file is empty!");
    }
    $xmldom = new DOMDocument();
    $xmldom->load($file['tmp_name']);
    $_SESSION["xml"] = outdom($xmldom);
} catch (Exception $e) {
    $error = $e . getMessage();
}
echo json_encode(array("success" => true, "error" => $error));
function outdom($xmldom)
{
    $xsl = new XSLTProcessor();
    $xsldom = new DOMDocument();
    $xsldom->load("../convert-remove-namespace.xslt");
    $xsl->importStyleSheet($xsldom);
    return $xsl->transformToXML($xmldom);
}