- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中javax.xml.xquery.XQSequence
类的一些代码示例,展示了XQSequence
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XQSequence
类的具体详情如下:
包路径:javax.xml.xquery.XQSequence
类名称:XQSequence
[英]This interface represents a sequence of items as defined in the XDM. The sequence may be materialized or non-materialized.
The next
method is useful to position the XQSequence
over the next item in the sequence. If the scrollability is XQConstants.SCROLLTYPE_SCROLLABLE
, then the previous
method can be called to move backwards. In the case of a forward only sequence, the get methods may be only called once per item. To perform multiple gets on an item, extract the item first from the sequence using the getItem
method and then operate on the XQItem
object.
XQPreparedExpression expr = conn.prepareExpression("for $i ..");
XQSequence result = expr.executeQuery();
// create the ItemTypes for string and integer
XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING);
XQItemType intType = conn.createAtomicType(XQItemType.XQBASETYPE_INT);
// positioned before the first item
while (result.next())
{
XQItemType type = result.getItemType();
// If string, then get the string value out
if (type.equals(strType))
String str = result.getAtomicValue();
else if (type.equals(intType)) // if it is an integer..
int intval = result.getInt();
...
}
In a sequence, the cursor may be positioned on an item, after the last item or before the first item. The getPosition
method returns the current position number. A value of 0 indicates that it is positioned before the first item, a value of count() + 1
indicates that it is positioned after the last item, and any other value indicates that it is positioned on the item at that position.
For example, a position value of 1 indicates that it is positioned on the item at position 1.
The isOnItem
method may be used to find out if the cursor is positioned on the item. When the cursor is positioned on an item, the next
method call will move the cursor to be on the next item.
See also: Section 12 Serialization, XQuery API for Java (XQJ) 1.0, which describes some general information applicable to various XQJ serialization methods.
[中]此接口表示XDM中定义的一系列项。序列可以是物化的或非物化的。next
方法可用于将XQSequence
放置在序列中的下一项上。如果可滚动性为XQConstants.SCROLLTYPE_SCROLLABLE
,则可以调用previous
方法向后移动。对于仅向前的序列,每个项只能调用一次get方法。要对一个项目执行多个get,请首先使用getItem
方法从序列中提取该项目,然后对XQItem
对象进行操作。
XQPreparedExpression expr = conn.prepareExpression("for $i ..");
XQSequence result = expr.executeQuery();
// create the ItemTypes for string and integer
XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING);
XQItemType intType = conn.createAtomicType(XQItemType.XQBASETYPE_INT);
// positioned before the first item
while (result.next())
{
XQItemType type = result.getItemType();
// If string, then get the string value out
if (type.equals(strType))
String str = result.getAtomicValue();
else if (type.equals(intType)) // if it is an integer..
int intval = result.getInt();
...
}
按顺序,光标可能位于某个项目上,最后一个项目之后或第一个项目之前。getPosition
方法返回当前位置号。值0表示它位于第一个项目之前,count() + 1
表示它位于最后一个项目之后,任何其他值表示它位于该项目的该位置。
例如,位置值为1表示它位于项目的位置1。isOnItem
方法可用于确定光标是否位于项目上。当光标定位在一个项目上时,next
方法调用会将光标移动到下一个项目上。
另请参见:第12节序列化,XQuery API for Java(XQJ)1.0,其中描述了适用于各种XQJ序列化方法的一些一般信息。
代码示例来源:origin: dsukhoroslov/bagri
public static Map<String, Object> mapFromSequence(XQSequence cs) throws XQException {
Map<String, Object> result;
synchronized (cs) {
if (cs.isScrollable()) {
cs.beforeFirst();
result = new HashMap<>(cs.count());
} else {
result = new HashMap<>();
}
while (cs.next()) {
XQSequence pair = (XQSequence) cs.getObject();
pair.beforeFirst();
pair.next();
String key = pair.getAtomicValue();
pair.next();
Object value = pair.getObject();
result.put(key, value);
}
}
return result;
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public void write(ObjectDataOutput out, XQSequence sequence) throws IOException {
try {
List<XQItemAccessor> items;
synchronized (sequence) {
if (sequence.isScrollable()) {
sequence.beforeFirst();
items = new ArrayList<>(sequence.count());
} else {
items = new ArrayList<>();
}
while (sequence.next()) {
Object value = sequence.getObject();
if (value instanceof XQItemAccessor) {
items.add((XQItemAccessor) value);
} else {
items.add(sequence.getItem());
}
}
}
logger.trace("write; writing {} items", items.size());
out.writeObject(items);
} catch (XQException ex) {
throw new IOException(ex);
}
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public void close() {
try {
xqs.close();
} catch (XQException ex) {
logger.error("close", ex);
}
}
代码示例来源:origin: dsukhoroslov/bagri
@SuppressWarnings({ "rawtypes", "unchecked" })
private List getList(XQSequence xqc) throws XQException {
ArrayList list = new ArrayList();
boolean hasNext = xqc.isOnItem();
if (!hasNext) {
hasNext = xqc.next();
}
while (hasNext) {
list.add(xqc.getItem());
hasNext = xqc.next();
}
return list;
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public Item next() throws XPathException {
try {
if (xqs.next()) {
return convertXQItem(xqs.getItem(), config);
}
} catch (XQException ex) {
throw new XPathException(ex);
}
return null;
}
代码示例来源:origin: dsukhoroslov/bagri
@Override
public void deleteDocument(String uri) throws XQException {
String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
"declare variable $uri external;\n" +
"let $uri := bgdb:remove-document($uri)\n" +
"return $uri\n";
XQPreparedExpression xqpe = xqConn.prepareExpression(query);
xqpe.bindString(new QName("uri"), uri, xqConn.createAtomicType(XQItemType.XQBASETYPE_ANYURI));
XQSequence xqs = xqpe.executeQuery();
String result = null;
try {
if (xqs.next()) {
result = xqs.getAtomicValue();
}
if (!uri.equals(result)) {
throw new XQException("got no result from bgdb:remove-document function");
}
} finally {
xqpe.close();
xqs.close();
}
}
代码示例来源:origin: dsukhoroslov/bagri
xqpe.bindSequence(new QName("props"), xqc.createSequence(props.iterator()));
XQSequence xqs = xqpe.executeQuery();
if (xqs.next()) {
long id = xqs.getLong();
xqpe.close();
xqs.close();
return id;
} else {
xqpe.close();
xqs.close();
throw new XQException("no response from store-document function");
代码示例来源:origin: dsukhoroslov/bagri
private long storeXmlDocument(String fileName) throws XQException {
String dName = "..\\..\\etc\\samples\\tpox\\";
String xml;
try {
xml = readTextFile(dName + fileName);
} catch (IOException ex) {
throw new XQException(ex.getMessage());
}
String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
"declare variable $sec external;\n\n" +
//"return bgdb:store-document($sec)\n";
"for $id in bgdb:store-document($sec)\n" +
"return $id\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("sec"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
XQSequence xqs = xqpe.executeQuery();
if (xqs.next()) {
long result = xqs.getLong();
xqpe.close();
return result;
} else {
xqpe.close();
throw new XQException("no response from store-document function");
}
}
代码示例来源:origin: dsukhoroslov/bagri
String result = null;
try {
if (xqs.next()) {
result = xqs.getAtomicValue();
xqs.close();
我是 XQuery 初学者。我需要任何软件来运行 XQuery 吗?我在哪里输入 XQuery 代码 - 在 HTML 页面或 XML 中?我应该使用什么扩展名来保存我的 XQuery 文件? 最佳答
我正在编写一个 XQuery,它需要检查正在运行的 XQuery 版本(eXist、Saxon 等)。是否有一个标准函数可以返回 XQuery 的系统属性,例如版本、供应商等? 我知道有一些系统特定的
我正在阅读 book about xQuery它充满了像元素构造函数这样的表达......我的问题是: 什么是元素构造函数,“{}”是元素构造函数吗? 最佳答案 元素构造函数创建一个元素。在 XQue
我在网站上阅读了大量的 XQuery 教程。几乎他们所有人都在教我 XQuery 语法。假设我已经了解了 XQuery 语法,那么我将如何在我的网站上实际实现 XQuery? 例如,我有book.xm
以下有什么区别: import module namespace fs = "http://expath.org/ns/file"; declare namespace an = "http://zo
我有note.xml: Tove Jani Reminder Don't forget me this weekend! 和note.xqy: let $srcDoc:="not
我正在寻找一个示例,它表明 XQuery 表达式评估不是顺序的。在将 XQuery 的功能特性与过程语言进行比较时,总是会提到这一点。 例如在 XQuery, 2nd edition ,在下面的部分:
很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .
所以我有一个看起来像这样的 XQuery: for $i in /*:rootElement where $i/*:field = "test" return $i 这个查询返回了很多结果,但我真的只
我有一个xml文档如下 sony vijay 我正在尝试写一个 xquery 1) 找到具有给定用户 ID 的用户 - sony 2) 将给定用户的“test”属性值更改为
是否XQuery更新支持自增属性,就像SQL中的自增字段一样? 我正在使用 BaseX作为我的数据库。 最佳答案 给定 an answer from Christian Grün on the Bas
是否可以使用 XQUERY 来检索属性 filename从以下 XML?我正在尝试使用 /preFileDoc/inpXML/@filename但它不起作用...... ABC XYZ
尝试根据不同的过滤器计算一个集合中的汽车数量。即使我们看到多辆汽车满足要求,查询也返回计数 0。 fn:count(cts:search(fn:collection("com.cars"), cts:
我想在 xquery 中创建一个计数器。我最初的尝试如下所示: let $count := 0 for $prod in $collection let $count := $count + 1 re
我有一系列的值。他们都可以是平等的……或者不是。所以使用 XQuery 我想获得序列中最频繁的项目。 let $counter := 0, $index1 := 0 for $value in $se
当我查找 XQuery 示例时,有时会看到使用了运算符 =>。 我试图寻找它的含义,但找不到任何东西。由于我使用的是 MarkLogic,因此它可能仅适用于 MarkLogic,但我对此表示怀疑。 从
我必须使用 xquery 以 DDMMYYYY 格式创建日期字符串。输入到我的 xquery 的日期将类似于“2004-05-02T00:00:00+01:00”。截至目前,我正在使用以下解决方案来获
我正在使用 XQuery 执行加法。以下是数据库中保存的XML结构: 1 1001 50,1
忙于将 SQLServer 2008 R2 和 MarkLogic 8 与简单的个人实体进行比较。我的数据集适用于 100 万条记录/文档。注意:两个数据库都在同一台机器上(本地主机)。 以下 SQL
想象一下,如果我有一个以下格式存储在 Marklogic 中的 xml 文档: DocumentID question1
我是一名优秀的程序员,十分优秀!