v2.3.4
This commit is contained in:
parent
7a7a841ea0
commit
3552e76c6c
3692 changed files with 114492 additions and 75030 deletions
|
@ -5,57 +5,63 @@
|
|||
<link href="tabs.css" rel="stylesheet" type="text/css">
|
||||
</head><body>
|
||||
<a style="float:right;" href="http://sourceforge.net/projects/xqilla"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=152021&type=2" border="0" alt="SourceForge.net Logo" /></a>
|
||||
<!-- Generated by Doxygen 1.6.1 -->
|
||||
<div class="navigation" id="top">
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li><a href="index.html"><span>Main Page</span></a></li>
|
||||
<!-- Generated by Doxygen 1.8.5 -->
|
||||
<div id="navrow1" class="tabs">
|
||||
<ul class="tablist">
|
||||
<li><a href="index.html"><span>Main Page</span></a></li>
|
||||
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
||||
<li><a href="annotated.html"><span>Classes</span></a></li>
|
||||
<li><a href="files.html"><span>Files</span></a></li>
|
||||
<li><a href="examples.html"><span>Examples</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- top -->
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">simple-context-item.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<h1>simple-context-item.cpp</h1><p>This example parses a document and sets it as the context item. It then executes an XQuery expression that navigates relative to the context item.</p>
|
||||
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include <iostream></span>
|
||||
<span class="preprocessor">#include <<a class="code" href="xqilla-simple_8hpp.html">xqilla/xqilla-simple.hpp</a>></span>
|
||||
<span class="preprocessor">#include <<a class="code" href="Sequence_8hpp.html">xqilla/runtime/Sequence.hpp</a>></span>
|
||||
|
||||
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {
|
||||
<span class="comment">// Initialise Xerces-C and XQilla by creating the factory object</span>
|
||||
<a name="_a0"></a><a class="code" href="classXQilla.html" title="Provides factory methods for creating XQQuery and DynamicContext objects.">XQilla</a> xqilla;
|
||||
|
||||
<span class="comment">// Parse an XQuery expression</span>
|
||||
<span class="comment">// (AutoDelete deletes the object at the end of the scope)</span>
|
||||
<a name="_a1"></a><a class="code" href="classAutoDelete.html">AutoDelete<XQQuery></a> query(xqilla.<a name="a2"></a><a class="code" href="classXQilla.html#a7475d47b7b2fc51434ba9a381431f7ec" title="Parse the expression contained in the given query string.">parse</a>(X(<span class="stringliteral">"foo/bar/@baz"</span>)));
|
||||
|
||||
<span class="comment">// Create a context object</span>
|
||||
<a class="code" href="classAutoDelete.html">AutoDelete<DynamicContext></a> context(query->createDynamicContext());
|
||||
|
||||
<span class="comment">// Parse a document, and set it as the context item</span>
|
||||
<a name="_a3"></a><a class="code" href="classSequence.html" title="An eagerly evaluated result of a query execution.">Sequence</a> seq = context->resolveDocument(X(<span class="stringliteral">"foo.xml"</span>));
|
||||
<span class="keywordflow">if</span>(!seq.isEmpty() && seq.first()->isNode()) {
|
||||
context->setContextItem(seq.first());
|
||||
context->setContextPosition(1);
|
||||
context->setContextSize(1);
|
||||
}
|
||||
|
||||
<span class="comment">// Execute the query, using the context</span>
|
||||
<a name="_a4"></a><a class="code" href="classResult.html" title="A scoped pointer wrapper for the lazily evaluated query result.">Result</a> result = query->execute(context);
|
||||
|
||||
<span class="comment">// Iterate over the results, printing them</span>
|
||||
<a name="_a5"></a><a class="code" href="classRefCountPointer.html">Item::Ptr</a> item;
|
||||
<span class="keywordflow">while</span>(item = result->next(context)) {
|
||||
std::cout << UTF8(item->asString(context)) << std::endl;
|
||||
}
|
||||
|
||||
<span class="keywordflow">return</span> 0;
|
||||
}
|
||||
</pre></div> </div>
|
||||
<hr size="1"/><address style="text-align: right;"><small>Generated on 18 May 2015 for XQilla Simple API by
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
|
||||
<p>This example parses a document and sets it as the context item. It then executes an XQuery expression that navigates relative to the context item.</p>
|
||||
<div class="fragment"><div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <<a class="code" href="xqilla-simple_8hpp.html">xqilla/xqilla-simple.hpp</a>></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <<a class="code" href="Sequence_8hpp.html">xqilla/runtime/Sequence.hpp</a>></span></div>
|
||||
<div class="line"></div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {</div>
|
||||
<div class="line"> <span class="comment">// Initialise Xerces-C and XQilla by creating the factory object</span></div>
|
||||
<div class="line"> <a name="_a0"></a><a class="code" href="classXQilla.html">XQilla</a> xqilla;</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="comment">// Parse an XQuery expression</span></div>
|
||||
<div class="line"> <span class="comment">// (AutoDelete deletes the object at the end of the scope)</span></div>
|
||||
<div class="line"> <a name="_a1"></a><a class="code" href="classAutoDelete.html">AutoDelete<XQQuery></a> query(xqilla.<a name="a2"></a><a class="code" href="classXQilla.html#a7475d47b7b2fc51434ba9a381431f7ec">parse</a>(X(<span class="stringliteral">"foo/bar/@baz"</span>)));</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="comment">// Create a context object</span></div>
|
||||
<div class="line"> <a class="code" href="classAutoDelete.html">AutoDelete<DynamicContext></a> context(query->createDynamicContext());</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="comment">// Parse a document, and set it as the context item</span></div>
|
||||
<div class="line"> <a name="_a3"></a><a class="code" href="classSequence.html">Sequence</a> seq = context->resolveDocument(X(<span class="stringliteral">"foo.xml"</span>));</div>
|
||||
<div class="line"> <span class="keywordflow">if</span>(!seq.isEmpty() && seq.first()->isNode()) {</div>
|
||||
<div class="line"> context->setContextItem(seq.first());</div>
|
||||
<div class="line"> context->setContextPosition(1);</div>
|
||||
<div class="line"> context->setContextSize(1);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="comment">// Execute the query, using the context</span></div>
|
||||
<div class="line"> <a name="_a4"></a><a class="code" href="classResult.html">Result</a> result = query->execute(context);</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="comment">// Iterate over the results, printing them</span></div>
|
||||
<div class="line"> <a name="_a5"></a><a class="code" href="classRefCountPointer.html">Item::Ptr</a> item;</div>
|
||||
<div class="line"> <span class="keywordflow">while</span>(item = result-><a name="a6"></a><a class="code" href="classResultImpl.html#a4820c3c36a27975b1b704b903d2d1c5f">next</a>(context)) {</div>
|
||||
<div class="line"> std::cout << UTF8(item-><a name="a7"></a><a class="code" href="classItem.html#aeefef8ff091f935f4c81b53031582561">asString</a>(context)) << std::endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"></div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.5
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue