23 require_once
'ImportSource.php';
33 private $datas = array();
41 $this->filename = $filename;
47 public function parse()
49 $this->xml = simplexml_load_file($this->filename, null, LIBXML_NOCDATA);
52 $licenses = $this->xml->xpath(
"License");
54 $copyrights = $this->xml->xpath(
"Copyright");
71 $line = strtok((
string) $filesNode, $separator);
73 while ($line !==
false) {
74 if(! array_key_exists($line, $this->datas))
79 $line = strtok($separator);
90 foreach ($licenses as $licenseNode)
92 $attributes = $licenseNode->attributes();
93 $licenseName = (string) $attributes[
"name"];
94 $licenseId = $attributes[
"spdxidentifier"] !== NULL ? (string) $attributes[
"spdxidentifier"] : $licenseName;
95 $licenseText = (string) $licenseNode->xpath(
"Content")[0];
97 $item->setLicenseCandidate($licenseName, $licenseText,
false);
98 $item->setCustomText((
string) $licenseNode);
100 foreach ($licenseNode->xpath(
"Files") as $filesNode)
103 foreach ($files as $file)
105 $this->datas[$file]->addLicenseInfoInFile($item);
116 foreach ($copyrights as $copyrightNode)
118 foreach ($copyrightNode->xpath(
"Files") as $filesNode)
121 foreach ($files as $file) {
122 foreach ($copyrightNode->xpath(
"Content") as $content) {
123 $this->datas[$file]->addCopyrightText((
string)$content);
136 foreach ($this->datas as $fileName => $data)
138 $allFiles[$fileName] = $fileName;
158 return $this->datas[$fileid];
parseLicenseInformation($licenses)
splitFilesList($filesNode)
parseCopyrightInformation($copyrights)