Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 399

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="Function: mime_tree - Virtuoso Functions Guide" />
  <meta name="dc.subject" content="Function: mime_tree - Virtuoso Functions Guide" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="functions.html" title="Chapter Contents" />
  <link rel="prev" href="appendixa.html" title="Appendix" />
  <link rel="next" href="functions.html#.html" title="" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>Function: mime_tree - Virtuoso Functions Guide</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="fn_mime_tree" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>22. Virtuoso Functions Guide - mime_tree</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="functions.html">Chapter Contents</a> | <a class="link" href="fn_mime_part.html" title="mime_part">Prev</a> | <a class="link" href="fn_nntp_auth_get.html" title="nntp_auth_get">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div>
      <a class="selected" href="functions.html">Virtuoso Functions Guide</a>
   </div>
    <br />
   <div>
      <a href="functions.html#admin">Administration</a>
   </div>
   <div>
      <a href="functions.html#aggr">Aggregate Functions</a>
   </div>
   <div>
      <a href="functions.html#array">Array Manipulation</a>
   </div>
   <div>
      <a href="functions.html#bpel">BPEL APIs</a>
   </div>
   <div>
      <a href="functions.html#backup">Backup</a>
   </div>
   <div>
      <a href="functions.html#compression">Compression</a>
   </div>
   <div>
      <a href="functions.html#cursors">Cursor</a>
   </div>
   <div>
      <a href="functions.html#time">Date &amp; Time Manipulation</a>
   </div>
   <div>
      <a href="functions.html#debug">Debug</a>
   </div>
   <div>
      <a href="functions.html#dict">Dictionary Manipulation</a>
   </div>
   <div>
      <a href="functions.html#encoding">Encoding &amp; Decoding</a>
   </div>
   <div>
      <a href="functions.html#file">File Manipulation</a>
   </div>
   <div>
      <a href="functions.html#ft">Free Text</a>
   </div>
   <div>
      <a href="functions.html#hash">Hashing / Cryptographic</a>
   </div>
   <div>
      <a href="functions.html#ldap">LDAP</a>
   </div>
   <div>
      <a href="functions.html#localization">Locale</a>
   </div>
   <div>
      <a class="selected" href="functions.html#mail">Mail</a>
   </div>
   <div class="selected">
    <div>
        <a href="fn_mime_body.html">mime_body</a>
    </div>
    <div>
        <a href="fn_mime_part.html">mime_part</a>
    </div>
    <div>
        <a class="selected" href="fn_mime_tree.html">mime_tree</a>
    </div>
    <div>
        <a href="fn_nntp_auth_get.html">nntp_auth_get</a>
    </div>
    <div>
        <a href="fn_nntp_auth_post.html">nntp_auth_post</a>
    </div>
    <div>
        <a href="fn_nntp_get.html">nntp_get</a>
    </div>
    <div>
        <a href="fn_nntp_post.html">nntp_post</a>
    </div>
    <div>
        <a href="fn_pem_certificates_to_array.html">pem_certificates_to_...</a>
    </div>
    <div>
        <a href="fn_pop3_get.html">pop3_get</a>
    </div>
    <div>
        <a href="fn_smime_decrypt.html">smime_decrypt</a>
    </div>
    <div>
        <a href="fn_smime_encrypt.html">smime_encrypt</a>
    </div>
    <div>
        <a href="fn_smime_sign.html">smime_sign</a>
    </div>
    <div>
        <a href="fn_smime_verify.html">smime_verify</a>
    </div>
    <div>
        <a href="fn_smtp_send.html">smtp_send</a>
    </div>
    <div>
        <a href="fn_uuvalidate.html">uuvalidate</a>
    </div>
   </div>
   <div>
      <a href="functions.html#misc">Miscellaneous</a>
   </div>
   <div>
      <a href="functions.html#number">Number</a>
   </div>
   <div>
      <a href="functions.html#phrz">Phrases</a>
   </div>
   <div>
      <a href="functions.html#rdf">RDF data</a>
   </div>
   <div>
      <a href="functions.html#rmt">Remote SQL Data Source</a>
   </div>
   <div>
      <a href="functions.html#repl">Replication</a>
   </div>
   <div>
      <a href="functions.html#soap">SOAP</a>
   </div>
   <div>
      <a href="functions.html#sql">SQL</a>
   </div>
   <div>
      <a href="functions.html#string">String</a>
   </div>
   <div>
      <a href="functions.html#txn">Transaction</a>
   </div>
   <div>
      <a href="functions.html#type">Type Mapping</a>
   </div>
   <div>
      <a href="functions.html#uddi">UDDI</a>
   </div>
   <div>
      <a href="functions.html#udt">User Defined Types &amp; The CLR</a>
   </div>
   <div>
      <a href="functions.html#vad">VAD</a>
   </div>
   <div>
      <a href="functions.html#jvmpl">Virtuoso Java PL API</a>
   </div>
   <div>
      <a href="functions.html#bif">Virtuoso Server Extension Interface (VSEI)</a>
   </div>
   <div>
      <a href="functions.html#ws">Web &amp; Internet</a>
   </div>
   <div>
      <a href="functions.html#xml">XML</a>
   </div>
   <div>
      <a href="functions.html#XPATH">XPATH &amp; XQUERY</a>
   </div>
    <br />
   <div>
      <a href="functionidx.html">Functions Index</a>
   </div>
    <br />
  </div>
  <div id="text">
    <h2>mime_tree</h2>
    <div class="refpurpose">parses MIME messages into an array structure</div>
    <div class="funcsynopsis">
        <span class="funcdef">array <span class="function">mime_tree</span>
      </span>
        (<span class="paramdef">in <span class="parameter">message_text</span>  string</span>, 
        <span class="paramdefoptional">[in <span class="optional">flag</span> integer ]</span>);
      </div>
  
  
  
	<div class="refsect1">
		<div class="refsect1title">Description</div>
		<p>
This function is intended to parse MIME (RFC2045) messages (coming from a RFC822 or HTTP sources).
It parses the text and produces an array structure representing the structure of the MIME message.
It copies into the structure MIME headers, but for the MIME bodies it only stores start and end offsets,
thus optimizing space usage.
</p>
		<p>
The parameters to mime_tree are:
</p>
<ul>
        <li>message_text (string, required) - contains the text of the message to be parsed.</li>
        <li>flag (integer, optional) - a flag describing the format of the &quot;root&quot; object in the text.</li>
      </ul>
		<p>
If flag is 1, the &quot;root&quot; message follows RFC822. This means mime_tree will unfold the attributes,
will scan for MIME registered header fields and will take their attributes.  Alternately this can be a MIME message
which needs no unfolding and has attributes separated with semicolon.
</p>
		<p>
If flag is 2, the &quot;root&quot; message follows RFC2045. This means mime_tree will scan for MIME attributes.
</p>
		<p>
In either cases mime_tree will look for the Content-Type header field and will parse
the &quot;message/rfc822&quot; and &quot;multipart/digest&quot; MIME bodies as nested messages.
</p>
		<p>
mime_tree will return an array of 3 elements (message descriptor) with the following structure:
</p>

<ul>
        <li>
index 0: an array of attributes, parameters and their values, which can be passed to get_keyword
or get_keyword_ucase functions.
</li>
        <li>
index 1: an array of four elements: (0 - starting index of the body into the source_message text
(for aref), 1 - ending index of the body, 2 - an message descriptor if the body is recognized to
contain a valid RFC822 message; 0 otherwise, 3 - an array of two elements with starting and ending
offset if the body is recognized as a valid RFC822 multipart message and has some things after the
last MIME boundary, 0 otherwise).
</li>
        <li>
index 2: an array of subpart message descriptors, if the MIME message is recognized as multipart
MIME message, 0 otherwise.
</li>
      </ul>
</div>
  <div class="refsect1">
      <div class="refsect1title">Examples</div>
			<p>consider the following message text</p>
			<div>
        <pre class="programlisting">
Form: Somebody &lt;someuser@somehost&gt;
Mime-Version: 1.0
Content-Type: &quot;multipart/mixed&quot;;
	boundary=&quot;--the boundary&quot;
To: self@localhost

This is a multipart MIME message
----the boundary
Content-Type: image/gif; filename=&quot;the_big_picture.gif&quot;

GIF........
----the boundary
Content-Type: message/rfc822

From: Ford@Perfect
To: vogon
Mime-Version: 1.0
Content-Type: multipart/alternate; boundary=&quot;--sub-boundary&quot;

This is some Message
----sub-boundary
Content-Type: text/plain

Hi
----sub-boundary
Content-Type: text/html

&lt;P&gt;Hi&lt;/P&gt;
----sub-boundary--
Some garbage
----the boundary
Content-Type: text/plain

Some additional text
----the boundary--
Some additional garbage
</pre>
      </div>
<p>MIME_TREE(the_text, 1) will produce:</p>
			<div>
        <pre class="programlisting">
--- the main message start
(
 (&quot;From&quot;, &quot;Somebody &lt;someuser@somehost&gt;&quot;,
      &quot;Mime-Version&quot;, &quot;1.0&quot;, &quot;Content-Type&quot;,
      &quot;multipart/mixed&quot;,
      &quot;boundary&quot;, &quot;--the boundary&quot;,
      &quot;To&quot;, &quot;self@localhost&quot;), 		--- main attributes
 (n1, n2, 0, (mg1, mg2)), 		--- main message body
						(&quot;This is a multipart MIME message&quot;)
 ( 					--- Sub-parts array start
  ( 					--- Sub-Part 1
   (&quot;Content-Type&quot;, &quot;image/gif&quot;,
        &quot;filename&quot;,
        &quot;the_big_picture.gif&quot;), 	--- Attributes
   (s2, e2, 0, 0), 			--- body
   0 					--- no sub parts of the GIF
  ),
  (					--- Sub-Part 2
   (&quot;Content-Type&quot;, &quot;message/rfc822&quot;),	--- Attributes
   (s3, e3, 				--- the body offsets
    (					--- the body is recognized as a message,
						so parse it
     (&quot;From&quot;, &quot;Ford@Perfect&quot;, &quot;To&quot;, &quot;vogon&quot;,
          &quot;Mime-Version&quot;,
          &quot;multipart/alternate&quot;,
          &quot;boundary&quot;,
          &quot;--sub-boundary&quot;),		--- The body&#39;s Attributes
     (ss1, se1, 0, (g2, ge2)),		--- the body&#39;s body (&quot;This is some message&quot;).
						The message has the text
						&quot;Some additional garbage&quot;
						marked by g2, ge2 offsets
     (					--- body&#39;s parts
      (					--- body&#39;s SubPart 1
       (&quot;Content-Type&quot;, &quot;text/plain&quot;),	--- attributes
       (ss2, se2, 0, 0),		--- the text &quot;Hi&quot;
       0				--- no subparts
      ),
      ( 				--- body&#39;s SubPart 2
       (&quot;Content-Type&quot;, &quot;text/html&quot;),	--- attributes
       (ss3, se3, 0, 0),		--- the HTML paragraph &quot;Hi&quot;
       0				--- no subparts
      )
     )
    ),					--- end of the body&#39;s structure
    0					--- no trailers
   ),
   0					--- no subparts
  ),
  (					--- SubPart 3
   (&quot;Content-Type&quot;, &quot;text/plain&quot;),	--- attributes
   (s4, e4, 0, (g1, ge1)),		--- the text &quot;Some additional text&quot;
						and &quot;Some additional garbage&quot;
   0					--- no subparts
  )
 )					--- end of subparts array of the main message
)
</pre>
      </div>
			<p>
where the n1, n2, mg1, mg2, s2, e2, s3, e3, ss1, se1, g2, ge2, ss2, se2, ss3, se3, s4, e4, g1, ge1
are offsets, denoting starts and ends of the appropriate pieces within the source message,
which can be used by the subseq function:
</p>
			<div>
        <pre class="programlisting">
subseq (the_text, g1, ge1) returns the string &quot;Some additional garbage&quot;
</pre>
      </div>
	</div>
</div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>