示例#1
0
    def test_return_also_raw(self):
        xq = Xquery(xpath='/el')
        xq.xq_var = '$n'
        xq._raw_prefix = 'r_'
        xq.return_also({'myid': 'count(util:expand(%(xq_var)s/@id))'}, raw=True)
        self.assert_('<r_myid>{count(util:expand($n/@id))}</r_myid>' in xq._constructReturn())

        xq = Xquery(xpath='/el')
        xq.xq_var = '$n'
        xq._raw_prefix = 'r_'
        xq.return_also({'myid': '@id'}, raw=True)
        self.assert_('<r_myid>{@id}</r_myid>' in xq._constructReturn())
示例#2
0
 def test_return_also__fulltext_score(self):
     xq = Xquery(xpath='/el')
     xq.xq_var = '$n'
     xq.return_also({'fulltext_score': ''})
     self.assert_('let $fulltext_score := ft:score($n)' in xq.getQuery())
     self.assert_('<fulltext_score>{$fulltext_score}</fulltext_score>' in xq._constructReturn())
示例#3
0
 def test_return_also__highlight(self):
     xq = Xquery(xpath='/el')
     xq.xq_var = '$n'
     xq.return_also({'fulltext_score': ''})
     xq.add_filter('.', 'highlight', 'dog star')
     self.assert_('(/el[ft:query(., "dog star")]|/el)' in xq.getQuery())
示例#4
0
 def test_return_also(self):
     xq = Xquery(xpath='/el')
     xq.xq_var = '$n'
     xq.return_also({'myid': '@id', 'some_name': 'name'})
     self.assert_('{$n}' in xq._constructReturn())
     self.assert_('<field>{$n/@id}</field>' in xq._constructReturn())