当前位置: 首页>>代码示例>>Python>>正文


Python Xquery.getQuery方法代码示例

本文整理汇总了Python中eulexistdb.query.Xquery.getQuery方法的典型用法代码示例。如果您正苦于以下问题:Python Xquery.getQuery方法的具体用法?Python Xquery.getQuery怎么用?Python Xquery.getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eulexistdb.query.Xquery的用法示例。


在下文中一共展示了Xquery.getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_limits

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
    def test_set_limits(self):
        # subsequence with xpath
        xq = Xquery(xpath='/el')
        xq.xq_var = '$n'
        xq.set_limits(low=0, high=4)
        self.assertEqual('subsequence(/el, 1, 4)', xq.getQuery())
        # subsequence with FLWR query
        xq.return_only({'name': 'name'})
        self.assert_('subsequence(for $n in' in xq.getQuery())

        # additive limits
        xq = Xquery(xpath='/el')
        xq.set_limits(low=2, high=10)
        xq.set_limits(low=1, high=5)
        self.assertEqual('subsequence(/el, 4, 4)', xq.getQuery())

        # no high specified
        xq = Xquery(xpath='/el')
        xq.set_limits(low=10)
        self.assertEqual('subsequence(/el, 11, )', xq.getQuery())

        # no low
        xq = Xquery(xpath='/el')
        xq.set_limits(high=15)
        self.assertEqual('subsequence(/el, 1, 15)', xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:27,代码来源:test_query.py

示例2: test_filters

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:9,代码来源:test_query.py

示例3: test_filter_exists

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:10,代码来源:test_query.py

示例4: test_namespaces

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
 def test_namespaces(self):
     xq = Xquery(xpath='/foo:el', namespaces={'foo': 'urn:foo#'})
     ns_declaration = '''declare namespace foo='urn:foo#';'''
     # xpath-only xquery should have namespace declaration
     self.assert_(ns_declaration in xq.getQuery())
     # full FLOWR xquery should also have declaration
     xq.return_only({'id': '@id'})
     self.assert_(ns_declaration in xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:10,代码来源:test_query.py

示例5: test_not_filters

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:12,代码来源:test_query.py

示例6: test_filter_in

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:0xffea,项目名称:eulexistdb,代码行数:12,代码来源:test_query.py

示例7: test_filter_in

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:mangalam-research,项目名称:eulexistdb,代码行数:13,代码来源:test_query.py

示例8: test_filter_gtlt

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:16,代码来源:test_query.py

示例9: test_filter_gtlt

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:mangalam-research,项目名称:eulexistdb,代码行数:17,代码来源:test_query.py

示例10: test_set_collection

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
    def test_set_collection(self):
        # initialize with no collection
        xq = Xquery(xpath='/el')
        xq.set_collection('coll')
        self.assertEquals('collection("/db/coll")/el', xq.getQuery())

        # initialize with one collection, then switch
        xq = Xquery(collection='coll1')
        xq.set_collection('coll2')
        self.assertEquals('collection("/db/coll2")/node()', xq.getQuery())

        # leading slash is ok too
        xq.set_collection('/coll3')
        self.assertEquals('collection("/db/coll3")/node()', xq.getQuery())

        # set to None
        xq.set_collection(None)
        self.assertEquals('/node()', xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:20,代码来源:test_query.py

示例11: test_sort

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
    def test_sort(self):
        xq = Xquery(collection="mycoll")
        xq.xq_var = '$n'
        xq.sort('@id')
        self.assert_('order by $n/@id ascending' in xq.getQuery())
        self.assert_('collection("/db/mycoll")' in xq.getQuery())

        # prep_xpath function should clean up more complicated xpaths
        xq.sort('name|@id')
        self.assert_('order by $n/name|$n/@id' in xq.getQuery())

        # sort descending
        xq.sort('@id', ascending=False)
        self.assert_('order by $n/@id descending' in xq.getQuery())

        # sort case-insensitive
        xq.sort('@id', case_insensitive=True)
        self.assert_('order by fn:lower-case($n/@id) ascending' in xq.getQuery())

        # case-insensitive and descending
        xq.sort('@id', case_insensitive=True, ascending=False)
        self.assert_('order by fn:lower-case($n/@id) descending' in xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:24,代码来源:test_query.py

示例12: test_fulltext_options

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [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())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:8,代码来源:test_query.py

示例13: test_distinct

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
 def test_distinct(self):
     # distinct-values
     xq = Xquery(xpath='/el')
     xq.distinct()
     self.assertEqual('distinct-values(/el)', xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:7,代码来源:test_query.py

示例14: test_clear_limits

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
 def test_clear_limits(self):
     xq = Xquery(xpath='/el')
     xq.set_limits(low=2, high=5)
     xq.clear_limits()
     self.assertEqual('/el', xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:7,代码来源:test_query.py

示例15: test_defaults

# 需要导入模块: from eulexistdb.query import Xquery [as 别名]
# 或者: from eulexistdb.query.Xquery import getQuery [as 别名]
 def test_defaults(self):
     xq = Xquery()
     self.assertEquals('/node()', xq.getQuery())
开发者ID:codekansas,项目名称:eulexistdb,代码行数:5,代码来源:test_query.py


注:本文中的eulexistdb.query.Xquery.getQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。