【问题标题】:eXist: is it possible to have XQuery modules stored in XML files?eXist:是否可以将 XQuery 模块存储在 XML 文件中?
【发布时间】:2011-06-23 03:27:21
【问题描述】:

您可以将模块存储在 eXist 中,例如在/modules/my.xqm 下:

module namespace my = "http://www.example.com/";
declare function my:answerToTheUltimateQuestion() as xs:integer { 42 }

然后将其导入到查询中,如:

import module namespace my="http://www.example.com/" 
                        at "xmldb:exist:///db/modules/my.xqm";
my:answerToTheUltimateQuestion()

除了将 XQuery 存储在“文本文件”中之外,是否可以将其存储在 XML 文件中,这只是 XQuery 的包装器?我正在考虑一个类似于我们在向 eXist (<exist:query><exist:text>) 发布查询时使用的包装器。这将使使用需要存储在数据库中的 XML 数据的工具来更轻松地操作 XQuery 模块。

【问题讨论】:

    标签: module xquery exist-db


    【解决方案1】:

    您可以将 XQueryX 格式的 XQuery 存储到 eXist-db 中,然后使用小型 XQuery 和 eXist-db 中 XQueryX W3C 规范中的 XSLT 将其转换为 XQuery 并执行它。

    【讨论】:

    • 亚当,谢谢你的建议。所以我的 XML 文件包含 module.xml:<module>XQuery for module</module> 中模块的 XQuery。在开头,我添加:<?xml-stylesheet href="to-xquery.xsl" type="text/xsl" ?>。当我为module.xml 执行GET 时,它会被XSLT 处理,然后我会取回XQuery。唯一的问题是内容类型是 text/html,而不是 application/xquery。我在 XSLT 中添加了一个<xsl:output method="text" media-type="application/xquery"/>,但这似乎对内容类型没有影响。我错过了什么吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    • 1970-01-01
    • 2014-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多