1414define ('TESTSCHEMA_VERSION ' , getopt ('v: ' )['v ' ]);
1515define ('SCHEMA_DIR ' , realpath (__DIR__ . '/../../../../schema ' ));
1616define ('SCHEMA_FILE ' , SCHEMA_DIR . '/bom- ' . TESTSCHEMA_VERSION . '.xsd ' );
17+ define ('SPDX_FILE ' , SCHEMA_DIR . '/spdx.xsd ' );
18+
1719define ('TESTDATA_DIR ' , realpath (__DIR__ . '/../resources/ ' . TESTSCHEMA_VERSION ));
1820
1921if (empty (TESTSCHEMA_VERSION )) {
@@ -58,7 +60,13 @@ function validateFile(string $file): ?LibXMLError
5860 throw new Exception ("failed loading file: $ file " . PHP_EOL . libxml_get_last_error ()->message );
5961 }
6062
61- $ valid = $ doc ->schemaValidate (SCHEMA_FILE );
63+ $ xsd = str_replace (
64+ 'schemaLocation="http://cyclonedx.org/schema/spdx" ' ,
65+ 'schemaLocation="file:// ' . htmlspecialchars (SPDX_FILE , ENT_XML1 , 'UTF-8 ' ) .'" ' ,
66+ file_get_contents (SCHEMA_FILE )
67+ );
68+
69+ $ valid = $ doc ->schemaValidateSource ($ xsd , LIBXML_SCHEMA_CREATE );
6270 return $ valid
6371 ? null
6472 : libxml_get_last_error ();
@@ -96,4 +104,4 @@ function validateFile(string $file): ?LibXMLError
96104
97105// Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used.
98106// The status 0 is used to terminate the program successfully.
99- exit (min ($ errCnt , 254 ));
107+ exit (min ($ errCnt , 254 ));
0 commit comments