Thanks very much for taking the trouble to reply in such detail. I can understand why this is not something you would want to make a standard feature in XXE. And thanks for the tips on how I might go about writing a customisation.
Cheers, Ian Goldby On 21 Aug 2006, at 09:48, Hussein Shafie wrote: > Ian Goldby wrote: >> >> I'd like to suggest the following for the Users Wish List: >> >> Option to suppress <?xml version="1.0" encoding="UTF-8"?> line >> >> Add an option in Preferences/Save to stop XXE prepending the <?xml >> version="1.0" encoding="UTF-8"?> line to the top of the saved >> document. >> This is to make it easier to edit documents that consist of a >> mixture >> of XHTML and PHP code. PHP chokes on the <?xml version="1.0" >> encoding="UTF-8"?> line. A workaround is to turn off PHP's >> short_open_tag, but many users (especially ISP customers) don't have >> the option of changing PHP's configuration. >> >> The icing on the cake would be to make XXE automatically add a <meta >> content="text/html; charset=utf-8" http-equiv="Content-Type" /> >> line if >> <?xml version="1.0" encoding="UTF-8"?> is suppressed, so that the >> character encoding is preserved. > > --> I understand your problem. In fact with a first line like this: > --- > <?xml version="1.0" encoding="UTF-8"?> > --- > many Web browsers display an XML source code view instead of a normal > HTML page. > > > > --> However there is a big problem implementing what you request: > > * <?xml version="1.0" encoding="UTF-8"?> is there because you have not > chosen a different default encoding for saved file (Options|Options, > Save section). > > If you had chosen "ISO-8859-1", you would have had > <?xml version="1.0" encoding="ISO-8859-1"?> > > * Without <?xml...?> XXE will assume that the XML document being > opened > is encoded using UTF-8 (to make it simple). > > That is, unless the XML document being opened is encoded using UTF-8, > XXE (being an XML editor and not a Web browser which can make use > of the > <meta http-equiv="Content-Type"/>) really, really needs <?xml...?>. > > > > --> What you want is best implemented using a customization of XXE: > > [1] You'll need to force the use UTF-8 using configuration element > <saveOptions encoding="UTF-8"/>. > > [2] You'll write a DocumentHook in Java[tm] and declare it using the > <documentHook> configuration element. > > This documentHook automatically replaces '<?xml version="1.0" > encoding="UTF-8"?>' by '<meta content="text/html; charset=utf-8" > http-equiv="Content-Type" />' in the saved XHTML file. > > > > --> References: > * http://www.xmlmind.com/xmleditor/_distrib/doc/configure/ > saveOptions.html > * http://www.xmlmind.com/xmleditor/_distrib/doc/configure/ > documentHook.html > * http://www.xmlmind.com/xmleditor/_distrib/doc/dev/documenthook.html

