使用 XQuery 显示 xml 集合的内容
我必须使用 xml 数据库 (Sedna) 来存储和检索 Java 对象。项目中的每个自定义类都存储在一个集合中。我有以下问题:我不确定如何将对象写入集合中。也就是说,我不知道它们确切的xml结构,所以我无法对它们进行正确的查询。
对于给定的集合,是否有一个查询可以向我显示集合的内容?
Host h = new Host();
h.name = "test1";
h.freeSpace = 32;
String id1 = this.addHost(h);
//addHost method
try
{
Collection c = this.findCollection("Hosts"); //gives me the Hosts collection
if (c == null)
return null;
h.id = c.createId();
BinaryResource br = (BinaryResource) c.createResource(h.id, BinaryResource.RESOURCE_TYPE);
br.setContent(h);
c.storeResource(br);
return h.id;
} catch (XMLDBException e) {
System.err.println("Error adding Host entry into the database: " + e.getMessage());
return null;
}
I have to use an xml database (Sedna) to store and retrieve Java objects. Every custom class in the project is stored into a collection. I have the following problem : I'm not sure how the objects are written into the collection. That is to say, I don't know their exact xml structure, so I can't do a proper query on them.
Is there a query that, for a given collection, will show me the content of a collection?
Host h = new Host();
h.name = "test1";
h.freeSpace = 32;
String id1 = this.addHost(h);
//addHost method
try
{
Collection c = this.findCollection("Hosts"); //gives me the Hosts collection
if (c == null)
return null;
h.id = c.createId();
BinaryResource br = (BinaryResource) c.createResource(h.id, BinaryResource.RESOURCE_TYPE);
br.setContent(h);
c.storeResource(br);
return h.id;
} catch (XMLDBException e) {
System.err.println("Error adding Host entry into the database: " + e.getMessage());
return null;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要查看数据库或集合或文档的结构(架构),请查询以下系统文档之一 (检索元数据):
$schema
– 描述性架构所有文档和集合
一些与模式相关的信息;
$schema_
– 的文档的描述性架构或
名为 ;
例如,运行
se_term
,并执行doc('$schema_test')
以获取“测试”文档/集合的结构。你如何存储你的资源?请给我们代码片段。甚至很难理解您使用的是哪一种 API(XML:DB、XQJ、本机 Sedna Java API)。
To view structure (schema) of your database or collection or document query one of the following system documents (Retrieving Metadata):
$schema
– descriptive schemaof all documents and collections with
some schema-related information;
$schema_<name>
– thedescriptive schema of the document or
collection named ;
For example, run
se_term
, and executedoc('$schema_test')
to get structure of the 'test' document/collection.How do you store your resources? Please give us snippet of code. It's very hard to understand even which one API do you use (XML:DB, XQJ, native Sedna Java API).