I’m using PHP+curl to retrieve an XSL file, but first I want to do some minimum validation that the file is really a XSL file.
I make sure the file exists, has status code 200 OK, and that it has the correct file extension, but then I want to check the header for the Content-Type. I do this using curl_getinfo() function. All fine.
But XSL files always return “application/xml” or “text/xml” as the Content-Type, which is for XML files. I believe an XSL header should be “application/xslt+xml“. So what’s going on here and how can I make sure it’s an XSL document?
You can check the XSLT namespace in the file.
If PHP version >= 5.1.2, use
SimpleXMLElement::getNamespaces()