xQuery 中的元素构造函数是什么? [英] What is the element constructor in xQuery?

查看:18
本文介绍了xQuery 中的元素构造函数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 关于 xQuery 的书 并且它充满了元素构造函数之类的表达...我的问题是:

I'm reading a book about xQuery and it is full of expression like element constructor... and my question is:

什么是元素构造函数,{}"是元素构造函数?

What is the element constructor and is "{<expression>}" an element constructor?

推荐答案

元素构造函数创建元素.在 XQuery 中有几种方法可以做到这一点.

An element constructor creates an element. There are several ways that you can do that in XQuery.

花括号 {} 标记 封闭表达式.由于您可以使用文字 XML 和计算表达式,因此大括号表示何时离开静态上下文并进入动态构造.类似于将 <%@ page ... %> 用于 JSP 指令.

The curly braces {} mark the beginning and end of an enclosed expression in XQuery. Since you can use literal XML and computed expressions, the curly braces denote when you are leaving the static context and entering the dynamic constructs. Similar to how you would use <%@ page ... %> for JSP directives.

带有 直接元素构造函数,您使用 XML 语法创建静态 XML 结构.

With a direct element constructor, you use XML syntax to create a static XML structure.

例如:

  <book isbn="isbn-0060229357">
    <title>Harold and the Purple Crayon</title>
  </book>

使用 计算元素构造函数,元素节点和内容,可以根据元素名称及其内容的表达式生成动态 XML 结构.

With a computed element constructor, an element node and content and can generate dynamic XML structure from expressions for the element name and it's content.

例如:

element book {
  attribute { "isbn" } { "isbn-0060229357" },
  <title>Harold and the Purple Crayon</title>
}

您还可以使用表达式来计算元素名称:

You can also use an expression to compute the element name:

element { fn:concat("bo", "ok") } {
  attribute { "isbn" } { "isbn-0060229357" },
  <title>Harold and the Purple Crayon</title>
}

这篇关于xQuery 中的元素构造函数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆