Sophie

Sophie

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

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.subject" content="SQL" />
  <meta name="dc.subject" content="SQL Reference" />
  <meta name="dc.subject" content="Select" />
  <meta name="dc.subject" content="Update" />
  <meta name="dc.subject" content="delete" />
  <meta name="dc.subject" content="Select Statement" />
  <meta name="dc.subject" content="SQL Syntax" />
  <meta name="dc.subject" content="Syntax" />
  <meta name="dc.title" content="8. SQL Reference" />
  <meta name="dc.subject" content="8. SQL Reference" />
  <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="sqlreference.html" title="Chapter Contents" />
  <link rel="prev" href="CREATEVIEW.html" title="CREATE VIEW Statement" />
  <link rel="next" href="DROPXMLSCHEMA.html" title="DROP XML SCHEMA Statement" />
  <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>8. SQL Reference</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="SQL; SQL Reference; Select; Update; delete; Select Statement; SQL Syntax; Syntax; " />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="CREATEXMLSCHEMA" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>8. SQL Reference</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="sqlreference.html">Chapter Contents</a> | <a class="link" href="CREATEVIEW.html" title="CREATE VIEW Statement">Prev</a> | <a class="link" href="DROPXMLSCHEMA.html" title="DROP XML SCHEMA Statement">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="sqlreference.html">SQL Reference</a>
   </div>
    <br />
   <div>
      <a href="sqlrefDATATYPES.html">Datatypes</a>
   </div>
   <div>
      <a href="udt.html">User Defined Types</a>
   </div>
   <div>
      <a href="sqlrefxmldatatype.html">XML Column Type</a>
   </div>
   <div>
      <a href="catidentifiers.html">Identifier Case &amp; Quoting</a>
   </div>
   <div>
      <a href="wideidentifiers.html">Wide Character Identifiers</a>
   </div>
   <div>
      <a href="QUALIFIEDNAMES.html">Qualified Names</a>
   </div>
   <div>
      <a href="litsbraceescs.html">Literals, Brace Escapes</a>
   </div>
   <div>
      <a href="CREATETABLE.html">CREATE TABLE Statement</a>
   </div>
   <div>
      <a href="DROPTABLE.html">DROP TABLE Statement</a>
   </div>
   <div>
      <a href="CREATEINDEX.html">CREATE INDEX Statement</a>
   </div>
   <div>
      <a href="DROPINDEX.html">DROP INDEX Statement</a>
   </div>
   <div>
      <a href="ALTERTABLE.html">ALTER TABLE Statement</a>
   </div>
   <div>
      <a href="CREATEVIEW.html">CREATE VIEW Statement</a>
   </div>
   <div class="selected">
      <a href="CREATEXMLSCHEMA.html">CREATE XML SCHEMA Statement</a>
   </div>
   <div>
      <a href="DROPXMLSCHEMA.html">DROP XML SCHEMA Statement</a>
   </div>
   <div>
      <a href="sequenceobjects.html">Sequence Objects</a>
   </div>
   <div>
      <a href="insertSTMT.html">INSERT Statement</a>
   </div>
   <div>
      <a href="updatestmt.html">UPDATE Statement</a>
   </div>
   <div>
      <a href="SELECTSTMT.html">SELECT Statement</a>
   </div>
   <div>
      <a href="COMMIT_ROLLBACK.html">COMMIT WORK, ROLLBACK WORK Statement</a>
   </div>
   <div>
      <a href="CHECKPOINT.html">CHECKPOINT, SHUTDOWN Statement</a>
   </div>
   <div>
      <a href="spasviewsandtables.html">Stored Procedures as Views &amp; Derived Tables</a>
   </div>
   <div>
      <a href="GRANT.html">GRANT, REVOKE Statement</a>
   </div>
   <div>
      <a href="SETstmt.html">SET Statement</a>
   </div>
   <div>
      <a href="anytimequeries.html">Anytime Queries</a>
   </div>
   <div>
      <a href="besteffortunion.html">Best Effort Union</a>
   </div>
   <div>
      <a href="aggregates.html">Standard and User-Defined Aggregate Functions</a>
   </div>
   <div>
      <a href="sqloptimizer.html">Virtuoso SQL Optimization</a>
   </div>
   <div>
      <a href="sqlinverse.html">SQL Inverse Functions</a>
   </div>
   <div>
      <a href="GRAMMAR.html">SQL Grammar</a>
   </div>
   <div>
      <a href="BITMAPINDICES.html">Bitmap Indices</a>
   </div>
   <div>
      <a href="transitivityinsQL.html">Transitivity in SQL</a>
   </div>
   <div>
      <a href="sqlreffastphrasematch.html">Fast Phrase Match Processor</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="CREATEXMLSCHEMA" />
    <h2>8.14. CREATE XML SCHEMA Statement</h2>
		<div>
      <pre class="programlisting">
&lt;xml schema definition&gt; ::=
    CREATE XML SCHEMA &lt;text of schema&gt;
</pre>
    </div>
<p>
Virtuoso supports registering XML Schemas for use in
<a href="CREATETABLE.html#sqlrefcreattablewithschema">WITH SCHEMA</a>
constraint for column values. The statement contains the whole text of the schema as a
string constant, i.e. enclosed in single quotes. This is not the best possible syntax,
because single quotes inside the text of schema should be carefully quoted, but this is
de-facto standard. If the schema contains number of single quotes (e.g. attributes are
in single quotes instead of typically used double quotes), try a system stored procedure
<span class="computeroutput">
DB.DBA.SYS_CREATE_XML_SCHEMA (text_of_schema);
</span>
that will have the same effect, but is not portable.
</p>
<p>
In principle, you can register any valid XMLSchema, but some features can cause prohibitive loss of performance.
It is strongly advised to compose the schema as a &quot;standalone&quot; document that has no references to
external DTDs or external generic entities. It is also strongly advised to avoid xs:include and
xs:import directives. The only sort of external references that does not affect performance is
xs:include or xs:import of a registered &quot;sibling&quot; schema. They say that a schema X is a &quot;sibling&quot; of schema Y
if their target namespace URIs have identical protocol names and host names and differs only in local path,
and schema X imports Y using relative (not absolute!) URI that contain only relative path,
(no protocol and no host).
</p>
<a name="ex_CREATEXMLSCHEMA" />
    <div class="example">
      <div class="exampletitle">Registering Sibling Schemas</div>
<p>Two sibling schemas are registered here.
First statement registers an XMLSchema for &quot;http://www.example.com/parts&quot; target namespace.
Second statement registers an XMLSchema for &quot;http://www.example.com/jobs&quot; target namespace
that imports the first schema using relative URI.
The rest of statements demonstrate a single WITH SCHEMA constraint that
inspect elements of these two target namespaces.</p>
<div>
        <pre class="programlisting">
CREATE XML SCHEMA &#39;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;xs:schema targetNamespace=&quot;http://www.example.com/parts&quot;
  xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
  xmlns:p=&quot;http://www.example.com/parts&quot;&gt;
   &lt;xs:element name=&quot;Part&quot;&gt;
      &lt;xs:complexType&gt;
         &lt;xs:choice minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
	   &lt;xs:element ref=&quot;p:Part&quot;/&gt;
	 &lt;/xs:choice&gt;
         &lt;xs:attribute name=&quot;ID&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
         &lt;xs:attribute name=&quot;Count&quot; type=&quot;xs:int&quot; use=&quot;optional&quot; /&gt;
         &lt;xs:attribute name=&quot;Type&quot; type=&quot;xs:string&quot; use=&quot;optional&quot; /&gt;
      &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
&lt;/xs:schema&gt;&#39;

CREATE XML SCHEMA &#39;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;xs:schema targetNamespace=&quot;http://www.example.com/jobs&quot;
  xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
  xmlns:p=&quot;http://www.example.com/parts&quot;
  xmlns:j=&quot;http://www.example.com/jobs&quot;&gt;
   &lt;xs:import schemaLocation=&quot;parts&quot; /&gt;
   &lt;xs:element name=&quot;Job&quot;&gt;
      &lt;xs:complexType&gt;
         &lt;xs:sequence&gt;
	   &lt;xs:element ref=&quot;p:Part&quot;/&gt;
	 &lt;/xs:sequence&gt;
         &lt;xs:attribute name=&quot;JobID&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
      &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;
&lt;/xs:schema&gt;&#39;

create table JOBS (
  PACK_ID integer primary key,
  CONTENT XMLType with schema (&#39;http://www.example.com/jobs&#39;, &#39;Job&#39;)
  )

insert into JOBS values (1, &#39;
&lt;j:Job xmlns:j=&quot;http://www.example.com/jobs&quot; xmlns:p=&quot;http://www.example.com/parts&quot; JobID=&quot;asmkeyboard&quot;&gt;
  &lt;p:Part xmlns:p=&quot;http://www.example.com/parts&quot; ID=&quot;keyboard&quot;&gt;
    &lt;p:Part Count=&quot;101&quot;/&gt;
    &lt;p:Part ID=&quot;body&quot;/&gt;
  &lt;/p:Part&gt;
&lt;/j:Job&gt;&#39;)

*** Error 42000: [Virtuoso Driver][Virtuoso Server]XML parser detected an error:
	ERROR  : Only 0 out of 1 required attributes are defined for element &lt;p:Part&gt;, e.g. the element has no attribute &#39;ID&#39;
at line 4 column 27 of &#39;(value to be placed in column DB.DBA.JOBS of CONTENT)&#39;
    &lt;p:Part Count=&quot;101&quot;/&gt;
-------------------------^

insert into JOBS values (2, &#39;
&lt;j:Job xmlns:j=&quot;http://www.example.com/jobs&quot; xmlns:p=&quot;http://www.example.com/parts&quot; JobID=&quot;asmkeyboard&quot;&gt;
  &lt;p:Part xmlns:p=&quot;http://www.example.com/parts&quot; ID=&quot;keyboard&quot;&gt;
    &lt;p:Part ID=&quot;key&quot; Count=&quot;101&quot;/&gt;
    &lt;p:Part ID=&quot;body&quot;/&gt;
  &lt;/p:Part&gt;
&lt;/j:Job&gt;&#39;);

</pre>
      </div>
</div>
<div class="note">
      <div class="notetitle">Note:</div>
<p>
There is no way to change a registered schema if it is used in some WITH SCHEMA constraint.
Double-check any schema before using it, because it may be hard to fix the error
later.
</p>
</div>
	<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="CREATEVIEW.html" title="CREATE VIEW Statement">Previous</a>
          <br />CREATE VIEW Statement</td>
     <td align="center" width="34%">
          <a href="sqlreference.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="DROPXMLSCHEMA.html" title="DROP XML SCHEMA Statement">Next</a>
          <br />DROP XML SCHEMA Statement</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>