我想知道如何修改存储在DB中的原始文档的内存中副本.我对update扩展非常满意,它允许我通过文本节点搜索/替换并永久地更改它们.但是,这种行为并不总是我想要的.在某些特殊情况下,我需要导出文档,并在运行中进行微小的更改.它似乎不是eXist支持copy,我会考虑.
对于永久性更改,我使用:
declare function cust-utils:replace-spaces-hard($document as xs:string) as empty() {
let $doc := doc($document)/tei:TEI
let $match := '(^|\s| )([szkvaiouSZKVAIOU])[\s]'
for $i in (1 to 2)
return
for $text in $doc//text()
return
update value $text[matches(., $match)] with replace($text, $match, '$1$2 ')
};
Run Code Online (Sandbox Code Playgroud)
(我迭代两次,因为看起来XPATH 2.0不允许在正则表达式中使用环绕声,这里的匹配有时会重叠.)
如何临时做同样的事?我尝试了Datypic中有趣的函数,但它只返回特定的节点.我需要保留文档顺序.简单地说,我需要浏览一个文档树,替换特定的字符串并按原样返回文档,而不是在DB中更新它.
UPDATE
不幸的是,这个:
declare function cust-utils:copy($input as item()*) as item()* {
for $node in $input
return $node
};
Run Code Online (Sandbox Code Playgroud)
绝对一样
declare function cust-utils:copy($input as item()*) as item()* {
for $node in $input
return
typeswitch($node) …Run Code Online (Sandbox Code Playgroud) 如何检查XQuery存在方法中的多个值?我XQuery在SQL语句中运行它
Select [column1] [xmlcolumn] from tablet
where [xmlcolumn].exist('/node/subnode/subsubnode[.="value1"]') = 1
Run Code Online (Sandbox Code Playgroud)
我希望能够指定多个值like [.="value1" OR "value2" OR ...].
任何指针都表示赞赏.
有没有办法让 eXist 按原样返回处理指令?看起来它在输出中以某种方式忽略了它。
\n\n如果我使用 XEP 作为渲染引擎,处理指令非常有用,因此如果能够在 XSL-FO 文档的根之前或在其启动之后立即保留它们,那就太好了。
\n\n如果我在模板中有:
\n\n<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:tei="http://www.tei-c.org/ns/1.0" version="2.0">\n <xsl:template match="/">\n <fo:root>\n <?xep-pdf-page-layout two-columns-right?>\nRun Code Online (Sandbox Code Playgroud)\n\n它只是返回:
\n\n<fo:root xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">\n <fo:layout-master-set>\nRun Code Online (Sandbox Code Playgroud)\n\n我\xe2\x80\x99ve尝试在查询的序言中使用:\n来保存处理指令,declare option exist:serialize "method=xhtml media-type=text/xml process-xsl-pi=yes";但无济于事。
更新一
\n\n我的场景的步骤是:
\n\ntransform:transform()函数transform:transform()函数时,我向其传递一个基本样式表,其中包括其他样式表pages-masters,该样式表覆盖了渲染引擎稍后使用的 FO 文档的根。该样式表包含 ( <xsl:include/>) 到基本样式表(收集所有样式表)中并传递给函数。我试图删除<paragraph>我的XML 中的所有空节点.这就是我所拥有的:
<root>
<text>
<paragraph>This is some text</paragraph>
<paragraph></paragraph>
<paragraph>More text</paragraph>
</text>
<text>
<paragraph>Another paragraph</paragraph>
<paragraph></paragraph>
</text>
</root>
Run Code Online (Sandbox Code Playgroud)
这是我的XQuery:
let $root-ele as element() := doc("text.xml")/*
return
update delete $root-ele/text[paragraph = '']
Run Code Online (Sandbox Code Playgroud)
它似乎没有更新文件,但我不确定为什么?
此转换称为 docUri.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" expand-text="yes">
<xsl:output method="text"/>
<xsl:template match="document-node()">{document-uri(.)}</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
使用此 xQuery 从存在数据库调用时不返回正在处理的 xml 文件的名称
xquery version "3.1";
transform:transform(doc("/db/apps/data/aDatabaseFile.xml"),
doc("/db/apps/docUri.xsl"),())
Run Code Online (Sandbox Code Playgroud)
它应该返回“/db/apps/data/aDatabaseFile.xml”
看起来 MarkLogic XSLT doc(uri) 或 document(uri) 函数没有在内容数据库的上下文中解析 uri上有类似的问题?