xquery 自动换行 [英] xquery word wrap

查看:31
本文介绍了xquery 自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 XQuery 将长字符串自动换行到 100 个字符.换句话说,将一些空格更改为换行符,使非病理行短于 100 个字符.有没有简单的方法?

I need to word wrap long string to 100 characters using XQuery. In other words, to change some spaces to newlines so that the non-patological lines will be shorter than 100 characters. Is there an easy way?

推荐答案

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

I think you just need this XPath 2.0 expression:

replace(concat(normalize-space(text),' '),'(.{0,60}) ','$1
')

使用 Dimitre 的输入、输出:

With Dimitre's input, output:

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.

这篇关于xquery 自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆