xquery自动换行

dan*_*tel 5 xquery

我需要使用XQuery将长字符串换行为100个字符.换句话说,将一些空格更改为换行符,以便非语法行将短于100个字符.有一个简单的方法吗?

小智 9

我想你只需要这个XPath 2.0表达式:

replace(concat(normalize-space(text),' '),'(.{0,60}) ','$1
')
Run Code Online (Sandbox Code Playgroud)

使用Dimitre的输入,输出:

Dec. 13 — As always for a presidential inaugural, security
and surveillance were extremely tight in Washington, DC,
last January. But as George W. Bush prepared to take the
oath of office, security planners installed an extra layer
of protection: a prototype software system to detect a
biological attack. The U.S. Department of Defense, together
with regional health and emergency-planning agencies,
distributed a special patient-query sheet to military
clinics, civilian hospitals and even aid stations along the
parade route and at the inaugural balls. Software quickly
analyzed complaints of seven key symptoms — from rashes to
sore throats — for patterns that might indicate the early
stages of a bio-attack. There was a brief scare: the system
noticed a surge in flulike symptoms at military clinics.
Thankfully, tests confirmed it was just that — the flu.
Run Code Online (Sandbox Code Playgroud)