Difference between revisions of "Xml (filter)"

From Mailutils
Jump to navigationJump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
In encode mode, the <tt>xml</tt>  filter converts input stream (which must contain valid UTF-8 characters) into a form suitable for inclusion into a XML or HTML document, i.e. it replaces <tt>&lt;</tt>, <tt>&gt;</tt>, and <tt>&amp;</tt> with <tt>&amp;lt;</tt>, <tt>&amp;gt;</tt>, and <tt>&amp;amp;</tt>, correspondingly, and replaces [http://www.w3.org/TR/xml/#dt-charref invalid characters] with their [http://www.w3.org/TR/xml/#dt-charref numeric character reference] representation.
+
In encode mode, the <tt>xml</tt>  filter converts input stream (which must contain valid UTF-8 characters) into a form suitable for inclusion into a XML or HTML document, i.e. it replaces <tt>&lt;</tt>, <tt>&gt;</tt>, and <tt>&amp;</tt> with <tt>&amp;lt;</tt>, <tt>&amp;gt;</tt>, and <tt>&amp;amp;</tt>, correspondingly, and replaces [http://www.w3.org/TR/xml/#charsets invalid characters] with their [http://www.w3.org/TR/xml/#dt-charref numeric character reference] representation.
  
 
In ''decode'' mode, a reverse operation is performed.
 
In ''decode'' mode, a reverse operation is performed.
Line 7: Line 7:
 
The following object, declared in '''mailutils/filter.h''' describes the filter:
 
The following object, declared in '''mailutils/filter.h''' describes the filter:
  
<source lang="C">
+
<syntaxhighlight lang="C">
 
extern mu_filter_record_t mu_xml_filter;
 
extern mu_filter_record_t mu_xml_filter;
</source>
+
</syntaxhighlight>
  
 
The example below shows how to create an instance of this filter in encode mode for reading:
 
The example below shows how to create an instance of this filter in encode mode for reading:
  
<source lang="C">
+
<syntaxhighlight lang="C">
 
   int rc;          /* Return code */
 
   int rc;          /* Return code */
 
   mu_stream_t flt; /* Filter stream */
 
   mu_stream_t flt; /* Filter stream */
 
   mu_stream_t input; /* Input stream */
 
   mu_stream_t input; /* Input stream */
 
   
 
   
   initialize_input_stream (&stream);
+
   initialize_input_stream (&input);
   rc = mu_filter_stream_create (&flt, input, "xml", MU_FILTER_DECODE, MU_STREAM_READ);
+
   rc = mu_filter_create (&flt, input, "xml", MU_FILTER_DECODE, MU_STREAM_READ);
</source>
+
</syntaxhighlight>
 +
 
 +
== See also ==
 +
 
 +
* [[htmlent]]
  
 
[[Category:Filters]]
 
[[Category:Filters]]
 
[[Category:C API]]
 
[[Category:C API]]

Latest revision as of 13:26, 16 October 2023

In encode mode, the xml filter converts input stream (which must contain valid UTF-8 characters) into a form suitable for inclusion into a XML or HTML document, i.e. it replaces <, >, and & with &lt;, &gt;, and &amp;, correspondingly, and replaces invalid characters with their numeric character reference representation.

In decode mode, a reverse operation is performed.

The filter does not take arguments.

The following object, declared in mailutils/filter.h describes the filter:

extern mu_filter_record_t mu_xml_filter;

The example below shows how to create an instance of this filter in encode mode for reading:

  int rc;          /* Return code */
  mu_stream_t flt; /* Filter stream */
  mu_stream_t input; /* Input stream */
 
  initialize_input_stream (&input);
  rc = mu_filter_create (&flt, input, "xml", MU_FILTER_DECODE, MU_STREAM_READ);

See also