Sophie

Sophie

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

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="13. XML Support" />
  <meta name="dc.subject" content="13. XML Support" />
  <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="webandxml.html" title="Chapter Contents" />
  <link rel="prev" href="xslttrans.html" title="XSLT Transformation" />
  <link rel="next" href="xmldom.html" title="Changing XML entities in DOM style" />
  <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>13. XML Support</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="xmltype" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>13. XML Support</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="webandxml.html">Chapter Contents</a> | <a class="link" href="xslttrans.html" title="XSLT Transformation">Prev</a> | <a class="link" href="xmldom.html" title="Changing XML entities in DOM style">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 class="selected">
      <a href="webandxml.html">XML Support</a>
   </div>
    <br />
   <div>
      <a href="forxmlforsql.html">Rendering SQL Queries as XML (FOR XML Clause)</a>
   </div>
   <div>
      <a href="composingxmlinsql.html">XML Composing Functions in SQL Statements (SQLX)</a>
   </div>
   <div>
      <a href="xmlservices.html">Virtuoso XML Services</a>
   </div>
   <div>
      <a href="queryingxmldata.html">Querying Stored XML Data</a>
   </div>
   <div>
      <a href="updategrams.html">Using UpdateGrams to Modify Data</a>
   </div>
   <div>
      <a href="xmltemplates.html">XML Templates</a>
   </div>
   <div>
      <a href="xmlschema.html">XML DTD and XML Schemas</a>
   </div>
   <div>
      <a href="xq.html">XQuery 1.0 Support</a>
   </div>
   <div>
      <a href="xslttrans.html">XSLT Transformation</a>
   </div>
   <div class="selected">
      <a href="xmltype.html">XMLType</a>
   </div>
   <div>
      <a href="xmldom.html">Changing XML entities in DOM style</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="xmltype" />
    <h2>13.10. XMLType</h2>
<p>
XMLType is a predefined type for representing XML entities as UDT objects.
This is compatible with Oracle9i and later.
You can get better performance and flexibility by using use plain built-in functions
that directly operate with XML entities.
All predefined member functions of XMLType for extracting fragments from
an XMLType are actually wrappers for <a href="fn_xpath_eval.html">xpath_eval()</a> built-in function.
You can declare a column of XMLType but the actual type of the created column will be &quot;LONG XML&quot;.
Thus any XML-related feature that can be used for &quot;LONG XML&quot; column will work with XMLType.
E.g. <a href="CREATETABLE.html#sqlrefcreattablewithschema">WITH SCHEMA constraint</a> allows you to force stored values
to match a particular schema; <a href="queryingxmldata.html#usingxmlfreetext">XML free text index</a> can accelerate search for documents by content
etc.
</p>
<p>
XMLType behaves like any user-defined type, with the only difference in type conversion rules.
If an XML entity is passed as an argument instead of an instance of XMLType, a new instance of
XMLType is created by a constructor that takes the entity as an argument.
Similarly, functions that accept XML entities as arguments can also accept an instance of
XMLType as an actual value of argument.
</p>
<p>
The following example creates a table with an XMLType column, put two records there
and performs a simple search:</p>
<div>
      <pre class="screen">
CREATE TABLE Xml_tab ( xmlval XMLType);

INSERT INTO Xml_tab VALUES (
   xmltype(&#39;&lt;?xml version=&quot;1.0&quot;?&gt;
               &lt;EMP&gt;
                  &lt;EMPNO&gt;221&lt;/EMPNO&gt;
                  &lt;ENAME&gt;John&lt;/ENAME&gt;
               &lt;/EMP&gt;&#39;));

INSERT INTO Xml_tab VALUES (
   xmltype(&#39;&lt;?xml version=&quot;1.0&quot;?&gt;
               &lt;PO&gt;
                  &lt;PONO&gt;331&lt;/PONO&gt;
                  &lt;PONAME&gt;PO_1&lt;/PONAME&gt;
               &lt;/PO&gt;&#39;));


-- now extract the numerical values for the employee numbers

SELECT e.xmlval.extract(&#39;//EMPNO/text()&#39;).getNumVal() as empno
   FROM Xml_tab
   WHERE e.xmlval.existsnode(&#39;/EMP/EMPNO&#39;)  = 1;
</pre>
    </div>
<p>To create a new instance of XMLType, the constructor <a href="fn_XMLType.XMLType.html">XMLType()</a>
or a function <a href="fn_createXML.html">createXML()</a> is used.
</p>
<p>
Virtuoso can perform XPATH search in XMLType instances:
<a href="fn_XMLType.extract.html">extract()</a>
and
<a href="fn_XMLType.existsNode.html">existsNode()</a>
member functions are convenient for simple searches and any
built-in XPATH functions like
<a href="fn_xpath_eval.html">xpath_eval()</a> or
<a href="fn_xquery_eval.html">xquery_eval()</a> can handle
XMLType parameters instead of XML entity parameters.
An application can use
<a href="fn_XMLType.getStringVal.html">getStringVal()</a>,
<a href="fn_XMLType.getNumVal.html">getNumVal()</a> and
<a href="fn_XMLType.getClobVal.html">getColbVal()</a>
member functions to convert found node to strings, numbers or an XML source text of the node.
</p>
<p>Instances of the type can store the URL of the XML schema to which they  should conform.
This URL can be specified when an instance is constructed;
Once an instance is created, its schema URL cannot be changed but a modified copy can be created by
<a href="fn_XMLType.createSchemaBasedXML.html">createSchemaBasedXML()</a>
and
<a href="fn_XMLType.createNonSchemaBasedXML.html">createNonSchemaBasedXML()</a>
member functions;
<a href="fn_XMLType.isSchemaBased.html">isSchemaBased()</a>
and <a href="fn_XMLType.getSchemaURL.html">getSchemaURL()</a>
member functions check whether the given instance is schema based or not and
what particular schema is used.
</p>
<p>
An schema based XMLType instance can be validated against its schema;
If it has been validated against its schema once with no errors detected then
a special &quot;VALIDATED&quot; flag is set
in the instance indicating that there is no need to validate it again.
<a href="fn_XMLType.schemaValidate.html">schemaValidate()</a>
member function performs the validation,
<a href="fn_XMLType.isSchemaValidated.html">isSchemaValidated()</a>
queries the &quot;VALIDATED&quot; flag and
<a href="fn_XMLType.setSchemaValidated.html">setSchemaValidated()</a>
changes the &quot;VALIDATED&quot; flag if application needs optimization tricks.
</p>
<p>
In addition, any instance can be validated against an arbitrary schema via member function
<a href="fn_XMLType.isSchemaValid.html">isSchemaValid()</a>.
Built-in function <a href="">xml_validate_schema()</a>
may accept instance of XMLType as its first argument, providing even more
validation functionality.
</p>
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="xslttrans.html" title="XSLT Transformation">Previous</a>
          <br />XSLT Transformation</td>
     <td align="center" width="34%">
          <a href="webandxml.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="xmldom.html" title="Changing XML entities in DOM style">Next</a>
          <br />Changing XML entities in DOM style</td>
    </tr>
    </table>
  </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>