XSLT:在“长”文本中添加空格单词
有一个代码:
<p>
Lorem ipsum dolor sit ametconsecteturadipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
Duis aute iruredolorinreprehenderit in voluptate
velit esse cillum doloreeufugiatnullapariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
</p>
需要接收:
<p>
Lorem ipsum dolor sit <span class="spaced">a m e t c o n s e c t e t u r a d i p i s i c i n g</span> elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
Duis aute <span class="spaced">i r u r e d o l o r i n r e p r e h e n d e r i t</span> in voluptate
velit esse cillum <span class="spaced">d o l o r e e u f u g i a t n u l l a p a r i a t u r</span>. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
</p>
意义在于分隔“长”单词用空格 。在该单词的每个字母后面添加空格。然后有必要在带有“spaced”类的标签中结束这个单词。
如果该单词中的字母数量超过 10 个(例如,可以设置任何值),则该单词被认为是“长”。
xslt这个问题怎么解决呢?
There is a code:
<p>
Lorem ipsum dolor sit ametconsecteturadipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
Duis aute iruredolorinreprehenderit in voluptate
velit esse cillum doloreeufugiatnullapariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
</p>
It is necessary to receive:
<p>
Lorem ipsum dolor sit <span class="spaced">a m e t c o n s e c t e t u r a d i p i s i c i n g</span> elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
Duis aute <span class="spaced">i r u r e d o l o r i n r e p r e h e n d e r i t</span> in voluptate
velit esse cillum <span class="spaced">d o l o r e e u f u g i a t n u l l a p a r i a t u r</span>. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.
</p>
The sense consists in dividing "long" words with spaces. To put space after each letter in such word. Then it is necessary to conclude this word in a tag with a class "spaced".
The word is considered "long" if the quantity of letters in this word is more 10 (for example. It is possible to set any value).
How to solve this problem means xslt?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个 XSLT 2.0 样式表,您可以使用 Saxon 9 或 AltovaXML 工具:
Here is an XSLT 2.0 stylesheet that you could run with Saxon 9 or with AltovaXML tools:
非常聪明的人促使我做出了这个决定,对他们非常感谢。 在 xslt 1.0 中工作,无需任何扩展。这不是我的解决方案。
Very clever people have prompted me the decision, huge to them thanks. Works in xslt 1.0 without any extansions. It is not my solution.