本文整理汇总了Python中eulexistdb.query.Xquery.add_filter方法的典型用法代码示例。如果您正苦于以下问题:Python Xquery.add_filter方法的具体用法?Python Xquery.add_filter怎么用?Python Xquery.add_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulexistdb.query.Xquery
的用法示例。
在下文中一共展示了Xquery.add_filter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filters
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filters(self):
xq = Xquery(xpath='/el')
xq.add_filter('.', 'contains', 'dog')
self.assertEquals('/el[contains(., "dog")]', xq.getQuery())
# filters are additive
xq.add_filter('.', 'startswith', 'S')
self.assertEquals('/el[contains(., "dog")][starts-with(., "S")]', xq.getQuery())
示例2: test_filter_exists
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_exists(self):
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'exists', True)
self.assertEquals('/el[@id]', xq.getQuery())
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'exists', False)
self.assertEquals('/el[not(@id)]', xq.getQuery())
示例3: test_not_filters
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_not_filters(self):
xq = Xquery(xpath='/el')
xq.add_filter('.', 'contains', 'dog', mode='NOT')
self.assertEquals('/el[not(contains(., "dog"))]', xq.getQuery())
xq = Xquery(xpath='/el')
xq.add_filter('.', 'contains', 'dog', mode='NOT')
xq.add_filter('.', 'startswith', 'S', mode='NOT')
self.assertEquals('/el[not(contains(., "dog") or starts-with(., "S"))]',
xq.getQuery())
示例4: test_filter_in
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_in(self):
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'in', ['a', 'b', 'c'])
self.assertEquals('/el[contains(("a","b","c"), @id)]', xq.getQuery())
# filter on a 'special' field - requires let & where statements
xq = Xquery(xpath='/el')
xq.add_filter('document_name', 'in', ['a.xml', 'b.xml'])
self.assert_('let $document_name' in xq.getQuery())
self.assert_('where contains(("a.xml","b.xml"), $document_name)' in xq.getQuery())
示例5: test_filter_in
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_in(self):
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'in', ['a', 'b', 'c'])
self.assertEquals('/el[@id="a" or @id="b" or @id="c"]', xq.getQuery())
# filter on a 'special' field - requires let & where statements
xq = Xquery(xpath='/el')
xq.add_filter('document_name', 'in', ['a.xml', 'b.xml'])
self.assert_('let $document_name' in xq.getQuery())
self.assert_('where $document_name="a.xml" or $document_name="b.xml"'
in xq.getQuery())
示例6: test_filter_gtlt
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_gtlt(self):
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'gt', 5)
self.assert_('where $n/@id > 5' in xq.getQuery())
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'gte', 5)
self.assert_('where $n/@id >= 5' in xq.getQuery())
xq.add_filter('@id', 'lt', '5')
self.assert_('where $n/@id < 5' in xq.getQuery())
xq.add_filter('@id', 'lte', 3)
self.assert_('where $n/@id <= 3' in xq.getQuery())
示例7: test_filter_gtlt
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_gtlt(self):
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'gt', 5)
self.assert_('el[@id > 5]' in xq.getQuery())
xq = Xquery(xpath='/el')
xq.add_filter('@id', 'gte', 5)
self.assert_('/el[@id >= 5]' in xq.getQuery())
xq.add_filter('@id', 'lt', '10')
self.assert_('el[@id >= 5]' in xq.getQuery())
self.assert_('[@id < "10"]' in xq.getQuery())
xq.add_filter('@id', 'lte', 3)
self.assert_('[@id <= 3]' in xq.getQuery())
示例8: test_return_also__highlight
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
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())
示例9: test_filter_escaping
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filter_escaping(self):
xq = Xquery(xpath='/el')
xq.add_filter('.', 'contains', '"&')
self.assertEquals('/el[contains(., """&")]', xq.getQuery())
示例10: test_filters_highlight
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filters_highlight(self):
xq = Xquery(xpath='/el')
xq.add_filter('.', 'highlight', 'dog star')
self.assertEquals('(/el[ft:query(., "dog star")]|/el)', xq.getQuery())
示例11: test_fulltext_options
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_fulltext_options(self):
# pass in options for a full-text query
xq = Xquery(xpath='/el', fulltext_options={'default-operator': 'and'})
xq.add_filter('.', 'fulltext_terms', 'dog')
self.assert_('<default-operator>and</default-operator>' in xq.getQuery())
self.assert_('/el[ft:query(., "dog", $ft_options)]', xq.getQuery())
示例12: test_filters_fulltext
# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import add_filter [as 别名]
def test_filters_fulltext(self):
xq = Xquery(xpath='/el')
xq.add_filter('.', 'fulltext_terms', 'dog')
self.assertEquals('/el[ft:query(., "dog")]', xq.getQuery())