---
title: "创新型 XPath/XQuery 工具"
date: "2015-03-03"
categories: 
  - "xpath"
  - "xquery"
tags: 
  - "xmlspy"
  - "xpath"
  - "xquery"
description: 探索 XMLSpy 2015 中增强的 XPath 和 XQuery 工具，该工具支持 XPath 3.1 和 XQuery 3.1，旨在简化表达式的开发和测试过程。
---
Status: #blog

Tags:  #xmlspy #xpath #xquery

Categories: [xpath+xquery](/blog/zh/category/xpathxquery.md) | [xpath+xquery](/blog/zh/category/xpathxquery.md)
# 创新型 XPath/XQuery 工具

在 XMLSpy 2015 版本的第三个版本中，XPath 和 XQuery 的支持得到了显著提升。除了增加对最新标准版本的支持，即 [XPath 3.1](http://www.w3.org/TR/xpath-31/) 和 [XQuery 3.1](http://www.w3.org/TR/xquery-31/)，我们还为 XPath/XQuery 窗口添加了创新的新工具，用于开发和测试 XPath 和 XQuery 表达式。

这些新工具可以显著加快开发、评估和完善表达式和语句的过程，然后再将它们添加到更大的 XSLT 或 XQuery 文档中。这可以**节省您的时间和精力**，因为您可以立即了解每个运算符或函数的工作方式，并确保您的表达式能够返回预期的结果。我发现这些函数描述和输入辅助工具对于学习 XPath/XQuery 3.1 中新引入的映射和数组功能的工作原理特别有帮助。

![XPath 和 XQuery 工具](/blog/images/C0019116_700x335.jpg)

<!--more-->

如您在下方看到的，XPath/XQuery 窗口支持所有版本的 XPath (1.0/2.0/3.1) 和 XQuery (1.0/3.1)，以及 [XQuery 更新功能 (1.0/3.0)](https://www.youtube.com/watch?v=pJ0380Y1JPg)。

 

![图片](https://lh3.ggpht.com/-eOZYDBDcIW4/VPcWBhFBAYI/AAAAAAAAAos/KJ3Ces2He5c/image_thumb.png?imgmax=800 "image")

XPath/XQuery 工具窗口有两种模式：构建模式和评估模式，您可以在工作过程中在两种模式之间切换。

**构建模式**

构建模式为您提供了众多工具，这些工具可以帮助您快速、轻松地创建 XPath 和 XQuery 表达式：

> **\- Point-and-click expression building**, via a comprehensive a list of operators, expressions, and built in functions, which you can insert in an expression by double clicking. Functions are inserted with their arguments indicated by “#” placeholders, making it easy to build expressions quickly and error-free.

> **\- Mouse-over hints** that describe each operator, expression, and function, so you can be sure to choose the correct one for the expression at hand.

> **\- Enhanced entry helpers** that display the description of built in functions, and then show helpful function and parameter details as you type, speeding development and ensuring accuracy.

> **\- Ready-to-use code snippets** for complex statements such as FLWOR and XQuery Update Facility expressions, found in the Operator/Expression pane. Here you can read a description of each and insert the expression at the cursor by double clicking.

[![(图片已剪辑)](https://lh3.ggpht.com/-ZesjtsKcCo0/VPSQUH4KTyI/AAAAAAAAAoA/LpXths2pcoI/clip_image004_thumb.png?imgmax=800 "clip_image004")](http://lh4.ggpht.com/-hP-444Vb3-c/VPSQTzlw1JI/AAAAAAAAAn8/SbJyEoO1YD8/s1600-h/clip_image004%25255B3%25255D.png)

**评估模式**

评估模式允许您在工作过程中测试 XPath/XQuery 语句的结果，这具有以下几个优点：

> **\- Save time and avoid errors** by testing expressions before adding them to your document and adjusting as needed.

> \- **Evaluate an XPath or XQuery expression against one or more files**: the active document, all open files, a folder, or an entire XMLSpy project.

> \- **Utilize nine tabs** for developing and testing complex expressions. Once you have composed an expression on one tab, switching to a new tab lets you build and analyze the results of a new expression – but when you switch back to the previous tab, the expression and results are still there. This allows you develop multiple expressions side-by-side and incrementally make changes to each one of them, preserving both the expression and the result for each tab.

[![(图片已剪辑)](https://lh4.ggpht.com/-Tl2hLyVZPQo/VPSQU-gQAII/AAAAAAAAAoU/DsvmTqaQhn8/clip_image005_thumb.png?imgmax=800 "clip_image005")](http://lh5.ggpht.com/-v8KfzvQjCeY/VPSQUSkjZSI/AAAAAAAAAoI/Oq_z1a6XiKw/s1600-h/clip_image005%25255B3%25255D.png)

现在就来尝试这些新的 XPath 和 XQuery 工具吧，您可以免费下载 [XMLSpy 软件的 30 天免费试用](https://www.altova.com/zh/download-trial.html).

最后一点：我之前提到，XPath/XQuery 工具不仅可以节省时间和减少错误，还能帮助您了解最新标准版本中的新功能。您还可以参考 Altova 提供的全新、免费的 [在线 XPath 3.0 培训课程](https://www.altova.com/zh/training/xpath3/default.aspx)。
