<commit_before><?
include_once("config.php");
include_once("lib/xmlDbConnection.class.php");

$id = $_GET["id"];

$query = "/ead[@id = '$id']";

$connectionArray{"debug"} = false;

$xmldb = new xmlDbConnection($connectionArray);

$xsl = "stylesheets/marblpdf.xsl";

$xmldb->xquery($query);
//$xmldb->xslTransform($xsl);
$params = array("mode" => "full");
$xmldb->xslBind("stylesheets/marblfa.xsl", $params);
$xmldb->xslBind("stylesheets/htmlpdf.xsl");
$xmldb->transform();

$filename = $xmldb->findNode("eadheader/eadid");
$filename = basename($filename, ".xml");
// if a filename has spaces, replace with underscores
$filename = str_replace(' ', '_', $filename);
$outfile = $tmpdir . $filename . '.fo';
mkdir($tmpdir);
$xmldb->save($outfile);
//print "DEBUG: saving xml (xsl-fo) to $outfile.<br>";

// call fop & generate pdf ...
$pdf  = file_get_contents($fop . $outfile);

header("Content-type: application/pdf");
header("Content-Disposition: filename=$filename.pdf");

print $pdf;

// remove temporary file
unlink($outfile);

?><commit_msg>note for debugging xsl-fo problems<commit_after><?
include_once("config.php");
include_once("lib/xmlDbConnection.class.php");

$id = $_GET["id"];

$query = "/ead[@id = '$id']";

$connectionArray{"debug"} = false;

$xmldb = new xmlDbConnection($connectionArray);

$xsl = "stylesheets/marblpdf.xsl";

$xmldb->xquery($query);
//$xmldb->xslTransform($xsl);
$params = array("mode" => "full");
$xmldb->xslBind("stylesheets/marblfa.xsl", $params);
$xmldb->xslBind("stylesheets/htmlpdf.xsl");
$xmldb->transform();

$filename = $xmldb->findNode("eadheader/eadid");
$filename = basename($filename, ".xml");
// if a filename has spaces, replace with underscores
$filename = str_replace(' ', '_', $filename);
$outfile = $tmpdir . $filename . '.fo';
mkdir($tmpdir);
$xmldb->save($outfile);
//print "DEBUG: saving xml (xsl-fo) to $outfile.<br>";

// call fop & generate pdf ...
$pdf  = file_get_contents($fop . $outfile);

header("Content-type: application/pdf");
header("Content-Disposition: filename=$filename.pdf");

print $pdf;

// remove temporary file  (NOTE: to debug xsl-fo, comment this out and use temporary .fo file with fop)
unlink($outfile);

?>
{'fraction_non_alphanumeric': 0.21069469835466179, 'fraction_numerical': 0.0, 'mean_word_length': 5.8193146417445485, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7256884', 'n_tokens_mistral': 806, 'n_tokens_neox': 777, 'n_words': 158}