English 中文(简体)
eXist XQuery Packtables in CDATA
原标题:eXist XQuery wrap variable in CDATA

我很想知道,能否将变数的内容(可能包含有幻觉的html)列入一个数据部分。

I am using XQuery with eXist and I just can t seem to get it working.

I tried

<![CDATA[ $data ]]>
<![CDATA[ {$data} ]]>

在这两种情况下,变量不以内容取代,而是分别保持数据和{数据}。

I also tried using concat and other string functions, but these resulted in <![CDATA[ becoming &lt;![CDATA[.

元数据包括:从一位htmlwysiwyg编辑获取/张贴数据。

xquery version "1.0";
declare namespace request="http://exist-db.org/xquery/request";

let $data := request:get-parameter("content" , "")
return <![CDATA[ {$data} ]]>

Does anyone now how it should be done? Thanks in advance.

问题回答

如果你想将一些信息化但具有任意性的超文本编码为示意图,例如将使用:

eg.

xquery version "1.0";
declare namespace util="http://exist-db.org/xquery/util";

let $data := <div><h1>stuff</h1><a href="url"> <img src="image"/></a></div>
return
   util:serialize($data,"method=xml"))

The effect is the same as if the XML were enclosed in CDATA, with the reserved XML characters encoded.





相关问题
XQuery, fn:id and BD eXist

Does "fn:id" function return IDREFS when it is used in a FLOWER xquery with eXists database? I can t get any example... :(

SQL Server xQuery return NULL instead of empty

So in this example I m trying to return a NULL instead of an empty nvarchar for element2 and element3. I can t seem to find an answer to this anywhere, or if it s even possible. I know I can check ....

Does QExo XQuery string-join work?

When I run string-join, I get a weird output like this: <clinic> <Name>Olive Street Pediatrics</Name> <Address>1500 Olive St, Los Angeles, CA 90015</Address> <...

XQuery: how to properly append , in for loop

So I have xml data like this: <PhoneNumber>213-512-7457</PhoneNumber> <PhoneNumber>213-512-7465</PhoneNumber> and with this XQuery: <PhoneNumberList> { for $...

Filter SQL queries on the XML column using XPath/XQuery

I m having a table with one XML column. I d like to filter out the rows where a specific attribute in the XML match a string, essentially doing a WHERE or HAVING. The table looks something like this ...

热门标签