We’ve used php to build up an interface that the client can upload svg graphic, then click the button to do an XSLT transform.
The interface and underlying XSLT worked perfectly fine previously, until recently, the xslt process will always fail and return error like: could not find http://www.w3.org or sth (Cannot remember quite exactly).
Our client uses Adobe Illustrator to create SVG graphics, and then use our tool to do the transform, and the SVG graphics that directly come out of Adobe Illustrator has the following three lines on the top of every SVG file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00
Build0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG
1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
We did some research and we came to conclustion that w3.org is blacklisting our client’s server (Windows Server 2003). The normal workaround is to do a resolver. Since the client will only give us 1 hour or so to do the remote control on their stuff, so I am thinking if there is a simpler way to handle this issue.
One proposed way is we could place a flatfile.dtd on client server, so every incoming SVG file can reference that, and we use the php to manipulate the SVG file, scan the file until it finds the "<!DOCTYPE.." string, then replace the whole string with another "<!DOCTYPE.." in which the url is now pointing the local flatfile.dtd, save the file and then begin the XSLT process. Then after the translation, we do the reverse process, which is to reset the dtd url from our local dtd to the default w3.org one.
I will try do this tomorrow, and our demo is on Friday. So I am just seeking some advice here if this way is realisitic and has it any risks? Or, could any experts give some better alternatives to deal with this issue?
Thanks in advance.
It’s not clear but I think you’re saying you only need a temporary fix for the purposes of a demo? If so, why not add an entry to the server’s host file that maps http://www.w3.org to 127.0.0.1 (localhost) or to the ip of a server that you control? Then you can populate the path of this server with the appropriate dtd file. After the demo, don’t forget to remove the host entry so everything is back as it was.
The nice thing about this is that you don’t have to manipulate the DOCTYPE string in your code since the existing url will resolve to a server that you control.
This solution assumes that you don’t have to dereference any other resources at http://www.w3.org besides this dtd. You should be able to test this on any server that runs your demo though.