Sophie

Sophie

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

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="xmltype.html" title="XMLType" />
  <link rel="next" href="contents.html" title="Contents" />
  <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="xmldom" />
    <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="xmltype.html" title="XMLType">Prev</a> | <a class="link" href="rdfandsparql.html" title="RDF Data Access and Data Management">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>
      <a href="xmltype.html">XMLType</a>
   </div>
   <div class="selected">
      <a href="xmldom.html">Changing XML entities in DOM style</a>
    <div>
        <a href="#xmldomtypecasting" title="Composing Document Fragments From DOM Function Arguments">Composing Document Fragments From DOM Function Arguments</a>
    </div>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="xmldom" />
    <h2>13.11. Changing XML entities in DOM style</h2>
<p>
An application may need to perform small irregular changes in an XML document.
It can be time-consuming to create a modified copy of a whole document for making
each small change. It can be also hard to express condition for making the change
in terms of XPath in order to use XSLT or XQuery.
</p>
<p>
Virtuoso offers a way to modify an existing XML entity by local operations like
&quot;insert a subtree before current node&quot; or &quot;replace one subtree with
a given one&quot;. These operations are called DOM operations because they are similar to
JavaScript operations with the Document Object Model.
</p>
<p>
DOM operations are the only operations that change an existing XML document
instead of creating a new modified document. It is very important to understand that
one document can be shared between many XML entities so changes made via one entity
may affect data accessible via other entities that share the same document.
Every XML document has special flags to &quot;lock&quot; its content and thus prevent
the content from being changed. E.g. XSLT and XQuery processors optimize access to the
source document in hope that every access to any entity will produce the same result
during the whole run of the processor. If an extension function will modify the source
document in the middle then the result of the processing is probably corrupted and this
error may be very hard to detect and debug. To prevent this sort of problems,
the XSLT processor locks the source at start and unlock at end so any attempt to modify the source
during the run will signal an error. The document can be locked in the following cases:
</p>
<ul>
  <li>The document is the source of the XSLT processing that is in progress.</li>
  <li>The document contains the context node that is passed to the XQuery processor at start.</li>
  <li>The document is used as a external generic entity in some other document.</li>
  <li>The document is created by the call of XPath function doc, document or document-literal
during the processing of some other document and that document is still in use.</li>
</ul>
<p>
One additional issue of using DOM operations is that any DOM operation invalidates
DTD and schema validation information that was associated with the document before the operation.
</p>
<ul>
<div class="formalpara">
        <strong>Schema validation status (&quot;is validated&quot; flag)</strong>
        <p>
E.g. if an schema based instance of XMLType is validated against its schema and thus it has
set its &quot;is validated&quot; flag to 1 then the flag is to be reset to zero if the
XML entity of this instance is modified by DOM operation, because there is no guarantee that
the modified document is still valid against the declared schema; if the application will repeat
the validation and it is successful then the flag will be set to 1 again.</p>
      </div>
<div class="formalpara">
        <strong>DTD-based processing of ID attributes</strong>
        <p>
A validating XML parser can build special dictionaries of ID attributes when it reads
a document. These dictionaries are used by <a href="xpf_id.html">id</a>
XPATH function and &quot;pointer operator&quot; of XQuery to find a node labeled by a given
ID value without searching the whole document. Any change in document tree invalidates data in these
dictionaries so any access to them will signal an error.</p>
      </div>
    </ul>
<a name="xmldomtypecasting" />
    <h3>13.11.1. Composing Document Fragments From DOM Function Arguments</h3>
<p>
When a DOM modification function adds some nodes to the tree, the content of these nodes comes
from values of arguments of the function. In the most common case, some generic entity is created
from one or more arguments and the function adds the content of the entity into the appropriate place of the document.
This process is regulated by a small set of very intuitive rules.
</p>
<p>
All data to be inserted are calculated before any modification of the document is started.
For example it is safe to insert into the document a fragment of this document, even if it contains
the point of insertion; such operation will never cause infinite loops.
</p>
<p>
If an instance of XMLType is passed then its internal XML entity is used.
</p>
<p>
If an argument is neither an XML entity nor a string then it is cast to the string first.
</p>
<p>
If an argument is NULL then it is fully ignored, as if there is no such argument at all.
</p>
<p>
A root node of a document can not be added into the tree of other document. Instead,
every child node of the root (i.e. every top-level node of the document) is added to
the target document, the order of child nodes will be preserved.
An XML document usually contains only one top-level element node, but it also can contain
comment and processing instruction nodes at top-level. Depending on the application,
such comments and instructions may be inappropriate in the middle of the modified document.
Thus it is worth to check what the application should insert: the root node with everything inside
or only a top-level element node.
</p>
<p>
If some function accepts a list of arguments as list of values to be inserted, these values will be concatenated
into a single generic entity. It is important to remember that the XML document can not contain two neighbour text nodes.
If two consecutive arguments are strings then a single node that is a concatenation of these string is added.
If the value of one argument is a string and the value of the next argument is a tree fragment that starts with a string
then this pair of strings will also be replaced with a concatenation of these strings.
When a function inserts a text after some existing text node of the XML document, no new node is created and
the existing text node is replaced with the text node that is the concatenation of old and new texts.
</p>
<p>
In general, you should not expect that adding N values into the document will add N new nodes to the document.
It can add a lesser number of nodes due to ignoring NULLs and concatenating some texts. It can also add a greater
number of nodes if some values are root nodes with many children.
</p>
<br />
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="xmltype.html" title="XMLType">Previous</a>
          <br />XMLType</td>
     <td align="center" width="34%">
          <a href="webandxml.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="rdfandsparql.html" title="RDF Data Access and Data Management">Next</a>
          <br />Contents of RDF Data Access and Data Management</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>