Marklogic XSLT输出中V形符号处理中的明显缺陷
当文本中有左V形时,我会遇到XSLT/XQuery组合问题。似乎如果我在XSLT中创建一个属性并将一个包含V形符号的值放入该属性中,那么当XQuery接收到输出时,它不会转义V形符号。当我稍后使用xdmp:quote()然后使用xdmp:unquote对XML进行报价时,我得到一个错误 但当我在查询控制台中测试这个时就不是了 如果我在查询控制台中运行它,它可以正常工作:Marklogic XSLT输出中V形符号处理中的明显缺陷,marklogic,Marklogic,当文本中有左V形时,我会遇到XSLT/XQuery组合问题。似乎如果我在XSLT中创建一个属性并将一个包含V形符号的值放入该属性中,那么当XQuery接收到输出时,它不会转义V形符号。当我稍后使用xdmp:quote()然后使用xdmp:unquote对XML进行报价时,我得到一个错误 但当我在查询控制台中测试这个时就不是了 如果我在查询控制台中运行它,它可以正常工作: let $Q := xdmp:quote( xdmp:xslt-eval( <xsl:style
let $Q :=
xdmp:quote(
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="A">
<NEW>
<xsl:attribute name="Attribute" select="normalize-space(./string())"/>
<xsl:value-of select="normalize-space(.)"/>
</NEW>
</xsl:template>
</xsl:stylesheet> , document { <A>1 < 2</A> }
)
)
let $XML := xdmp:unquote($Q)
return
$XML
让$Q:=
xdmp:quote(
xdmp:xslt-eval(
,文件{12}
)
)
让$XML:=xdmp:unquote($Q)
返回
$XML
但如果在XQuery主模块中运行相同的代码,则会收到此错误消息
XDMP-DOCATTRVALCHAR: xdmp:unquote("<NEW Attribute="1 < 2">1 &lt; 2</NEW>") -- Invalid attribute value character "<" or missing close quote at line 1
in /XSLTbugTest.xqy, at 15:12 [1.0-ml]
$Q = "<NEW Attribute="1 < 2">1 &lt; 2</NEW>"
XDMP-DOCATTRVALCHAR:XDMP:unquote(“1&;lt;2”)--无效的属性值字符“您可能没有正确创建和导入模块,或者使用了另一个错误的XDMP:quote | unquote
要找出问题的原因,您可以删除xdmp:quote | unquote
以测试主模块
XDMP-DOCATTRVALCHAR: xdmp:unquote("<NEW Attribute="1 < 2">1 &lt; 2</NEW>") -- Invalid attribute value character "<" or missing close quote at line 1
in /XSLTbugTest.xqy, at 15:12 [1.0-ml]
$Q = "<NEW Attribute="1 < 2">1 &lt; 2</NEW>"
我简化了我的一个模块:
declare variable $reader :=
xdmp:quote(
xdmp:xslt-eval(
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<BOOK author="{{distinct-values(//author)}}">
<xsl:sequence select="//title"/>
</BOOK>
</xsl:template>
</xsl:stylesheet>,
document {
<books>
<book>
<title>Sense < Sensibility</title>
<author>Jane < Austen</author>
<date>1811</date>
</book>
<book>
<title>Pride > Prejudice</title>
<author>Jane < Austen</author>
<date>1813</date>
</book>
</books>
}
)
);
declare function xsltTrans() {
let $_ := xdmp:unquote($reader)
return
$_
};
我发现只有当我将输出选项设置为“html”时才会出现错误。我必须将其设置为“html”,因为我开发了一个生成html页面的XQuery应用程序,这样做可以避免一些问题
因此,如果我将输出格式更改为“xml”,并解决这样做会单独引起的其他问题,我可以避免错误
我仍然认为这种情况发生是很奇怪的,即使是在“html”中“输出模式 我已经知道只有在使用quote和unquote时才会出现问题。是unquote抛出了错误。我必须能够出于本讨论范围之外的原因使用quote和unquote,因此避免使用quote和unquote不是一种选择。我也不知道你所说的模块“错误应用”是什么意思。您可以通过创建一个只包含上述代码的新模块来确认问题,无需创建函数和变量,就像我在上面键入的一样。您将看到错误。当然,请参见编辑:相同的结果。就性能而言,我只使用quote | unquote
内存(非结构化)文档作为节点。您使用的是什么版本的MarkLogic?上述代码在10.0-4中运行良好。我使用的是10.0-6。当我说“错误的应用程序”时,我指的是您的unquote
消息与原始输入节点的上下文不匹配。在你的QConsole中试试这个,看看它是否通过了:xdmp:unquote(“1&;lt;2”)
如果通过了,你能将输入节点重构为1&;书信电报;2
?