]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_xml2enc.html.en
Rebuild
[apache] / docs / manual / mod / mod_xml2enc.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>mod_xml2enc - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.js" type="text/javascript">
13 </script>
14
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body>
17 <div id="page-header">
18 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
19 <p class="apache">Apache HTTP Server Version 2.5</p>
20 <img alt="" src="../images/feather.gif" /></div>
21 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
22 <div id="path">
23 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
24 <div id="page-content">
25 <div id="preamble"><h1>Apache Module mod_xml2enc</h1>
26 <div class="toplang">
27 <p><span>Available Languages: </span><a href="../en/mod/mod_xml2enc.html" title="English">&nbsp;en&nbsp;</a></p>
28 </div>
29 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Enhanced charset/internationalisation support for libxml2-based
30 filter modules</td></tr>
31 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
32 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>xml2enc_module</td></tr>
33 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_xml2enc.c</td></tr>
34 <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Version 2.4 and later.  Available as a third-party module
35 for 2.2.x versions</td></tr></table>
36 <h3>Summary</h3>
37
38     <p>This module provides enhanced internationalisation support for
39     markup-aware filter modules such as <code class="module"><a href="../mod/mod_proxy_html.html">mod_proxy_html</a></code>.
40     It can automatically detect the encoding of input data and ensure
41     they are correctly processed by the <a href="http://xmlsoft.org/">libxml2</a> parser, including converting to Unicode (UTF-8) where
42     necessary.  It can also convert data to an encoding of choice
43     after markup processing, and will ensure the correct <var>charset</var>
44     value is set in the HTTP <var>Content-Type</var> header.</p>
45 </div>
46 <div id="quickview"><h3 class="directives">Directives</h3>
47 <ul id="toc">
48 <li><img alt="" src="../images/down.gif" /> <a href="#xml2encalias">xml2EncAlias</a></li>
49 <li><img alt="" src="../images/down.gif" /> <a href="#xml2encdefault">xml2EncDefault</a></li>
50 <li><img alt="" src="../images/down.gif" /> <a href="#xml2startparse">xml2StartParse</a></li>
51 </ul>
52 <h3>Topics</h3>
53 <ul id="topics">
54 <li><img alt="" src="../images/down.gif" /> <a href="#usage">Usage</a></li>
55 <li><img alt="" src="../images/down.gif" /> <a href="#api">Programming API</a></li>
56 <li><img alt="" src="../images/down.gif" /> <a href="#sniffing">Detecting an Encoding</a></li>
57 <li><img alt="" src="../images/down.gif" /> <a href="#output">Output Encoding</a></li>
58 <li><img alt="" src="../images/down.gif" /> <a href="#alias">Unsupported Encodings</a></li>
59 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
60 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
61 <div class="section">
62 <h2><a name="usage" id="usage">Usage</a></h2>
63     <p>There are two usage scenarios: with modules programmed to work
64     with mod_xml2enc, and with those that are not aware of it:</p>
65     <dl>
66     <dt>Filter modules enabled for mod_xml2enc</dt><dd>
67     <p>Modules such as <code class="module"><a href="../mod/mod_proxy_html.html">mod_proxy_html</a></code> version 3.1
68     and up use the <code>xml2enc_charset</code> optional function to retrieve
69     the charset argument to pass to the libxml2 parser, and may use the
70     <code>xml2enc_filter</code> optional function to postprocess to another
71     encoding.  Using mod_xml2enc with an enabled module, no configuration
72     is necessary: the other module will configure mod_xml2enc for you
73     (though you may still want to customise it using the configuration
74     directives below).</p>
75     </dd>
76     <dt>Non-enabled modules</dt><dd>
77     <p>To use it with a libxml2-based module that isn't explicitly enabled for
78     mod_xml2enc, you will have to configure the filter chain yourself.
79     So to use it with a filter foo provided by a module mod_foo to
80     improve the latter's i18n support with HTML and XML, you could use</p>
81     <pre><code>
82     FilterProvider iconv    xml2enc Content-Type $text/html
83     FilterProvider iconv    xml2enc Content-Type $xml
84     FilterProvider markup   foo Content-Type $text/html
85     FilterProvider markup   foo Content-Type $xml
86     FilterChain     iconv markup
87     </code></pre>
88     <p>mod_foo will now support any character set supported by either
89     (or both) of libxml2 or apr_xlate/iconv.</p>
90     </dd></dl>
91 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
92 <div class="section">
93 <h2><a name="api" id="api">Programming API</a></h2>
94     <p>Programmers writing libxml2-based filter modules are encouraged to
95     enable them for mod_xml2enc, to provide strong i18n support for your
96     users without reinventing the wheel.  The programming API is exposed in
97     <var>mod_xml2enc.h</var>, and a usage example is
98     <code class="module"><a href="../mod/mod_proxy_html.html">mod_proxy_html</a></code>.</p>
99 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
100 <div class="section">
101 <h2><a name="sniffing" id="sniffing">Detecting an Encoding</a></h2>
102     <p>Unlike <code class="module"><a href="../mod/mod_charset_lite.html">mod_charset_lite</a></code>, mod_xml2enc is designed
103     to work with data whose encoding cannot be known in advance and thus
104     configured.  It therefore uses 'sniffing' techniques to detect the
105     encoding of HTTP data as follows:</p>
106     <ol>
107         <li>If the HTTP <var>Content-Type</var> header includes a
108         <var>charset</var> parameter, that is used.</li>
109         <li>If the data start with an XML Byte Order Mark (BOM) or an
110         XML encoding declaration, that is used.</li>
111         <li>If an encoding is declared in an HTML <code>&lt;META&gt;</code>
112         element, that is used.</li>
113         <li>If none of the above match, the default value set by
114         <code class="directive">xml2EncDefault</code> is used.</li>
115     </ol>
116     <p>The rules are applied in order.  As soon as a match is found,
117     it is used and detection is stopped.</p>
118 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
119 <div class="section">
120 <h2><a name="output" id="output">Output Encoding</a></h2>
121 <p><a href="http://xmlsoft.org/">libxml2</a> always uses UTF-8 (Unicode)
122 internally, and libxml2-based filter modules will output that by default.
123 mod_xml2enc can change the output encoding through the API, but there
124 is currently no way to configure that directly.</p>
125 <p>Changing the output encoding should (in theory, at least) never be
126 necessary, and is not recommended due to the extra processing load on
127 the server of an unnecessary conversion.</p>
128 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
129 <div class="section">
130 <h2><a name="alias" id="alias">Unsupported Encodings</a></h2>
131 <p>If you are working with encodings that are not supported by any of
132 the conversion methods available on your platform, you can still alias
133 them to a supported encoding using <code class="directive">xml2EncAlias</code>.</p>
134 </div>
135 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
136 <div class="directive-section"><h2><a name="xml2EncAlias" id="xml2EncAlias">xml2EncAlias</a> <a name="xml2encalias" id="xml2encalias">Directive</a></h2>
137 <table class="directive">
138 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Recognise Aliases for encoding values</td></tr>
139 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>xml2EncAlias <var>charset alias [alias ...]</var></code></td></tr>
140 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
141 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
142 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_xml2enc</td></tr>
143 </table>
144     <p>This server-wide directive aliases one or more encoding to another
145     encoding.  This enables encodings not recognised by libxml2 to be handled
146     internally by libxml2's encoding support using the translation table for
147     a recognised encoding.  This serves two purposes: to support character sets
148     (or names) not recognised either by libxml2 or iconv, and to skip
149     conversion for an encoding where it is known to be unnecessary.</p>
150
151 </div>
152 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
153 <div class="directive-section"><h2><a name="xml2EncDefault" id="xml2EncDefault">xml2EncDefault</a> <a name="xml2encdefault" id="xml2encdefault">Directive</a></h2>
154 <table class="directive">
155 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets a default encoding to assume when absolutely no information
156 can be <a href="#sniffing">automatically detected</a></td></tr>
157 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>xml2EncDefault <var>name</var></code></td></tr>
158 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
159 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
160 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_xml2enc</td></tr>
161 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Version 2.4.0 and later; available as a third-party
162 module for earlier versions.</td></tr>
163 </table>
164     <p>If you are processing data with known encoding but no encoding
165     information, you can set this default to help mod_xml2enc process
166     the data correctly.  For example, to work with the default value
167     of Latin1 (<var>iso-8859-1</var> specified in HTTP/1.0, use</p>
168     <pre class="prettyprint lang-config">xml2EncDefault iso-8859-1</pre>
169
170
171 </div>
172 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
173 <div class="directive-section"><h2><a name="xml2StartParse" id="xml2StartParse">xml2StartParse</a> <a name="xml2startparse" id="xml2startparse">Directive</a></h2>
174 <table class="directive">
175 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Advise the parser to skip leading junk.</td></tr>
176 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>xml2StartParse <var>element [element ...]</var></code></td></tr>
177 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
178 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
179 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_xml2enc</td></tr>
180 </table>
181     <p>Specify that the markup parser should start at the first instance
182     of any of the elements specified.  This can be used as a workaround
183     where a broken backend inserts leading junk that messes up the parser (<a href="http://bahumbug.wordpress.com/2006/10/12/mod_proxy_html-revisited/">example here</a>).</p>
184     <p>It should never be used for XML, nor well-formed HTML.</p>
185
186 </div>
187 </div>
188 <div class="bottomlang">
189 <p><span>Available Languages: </span><a href="../en/mod/mod_xml2enc.html" title="English">&nbsp;en&nbsp;</a></p>
190 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
191 <script type="text/javascript"><!--//--><![CDATA[//><!--
192 var comments_shortname = 'httpd';
193 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_xml2enc.html';
194 (function(w, d) {
195     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
196         d.write('<div id="comments_thread"><\/div>');
197         var s = d.createElement('script');
198         s.type = 'text/javascript';
199         s.async = true;
200         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
201         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
202     }
203     else {
204         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
205     }
206 })(window, document);
207 //--><!]]></script></div><div id="footer">
208 <p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
209 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
210 if (typeof(prettyPrint) !== 'undefined') {
211     prettyPrint();
212 }
213 //--><!]]></script>
214 </body></html>