Note that there are some explanatory texts on larger screens.

plurals
  1. POTruncate XML with XSLT
    text
    copied!<p>I have a question for the clever people of the SO community.</p> <p>Below is a snippet of XML generated by the <a href="http://symphony21.com/" rel="nofollow noreferrer">Symphony CMS</a>. </p> <pre><code> &lt;news&gt; &lt;entry&gt; &lt;title&gt;Lorem Ipsum&lt;/title&gt; &lt;body&gt; &lt;p&gt;&lt;strong&gt;Lorem Ipsum&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada auctor magna. Vivamus urna justo, pulvinar nec, sagittis malesuada, accumsan in, massa. Quisque mi purus, gravida eget, ultricies a, porta in, sem. Maecenas justo elit, elementum vel, feugiat vulputate, pulvinar nec, velit. Fusce vel ante et diam bibendum euismod. Nunc vel nulla non lorem dignissim placerat. Nulla magna massa, auctor et, tempor nec, auctor sit amet, turpis. Quisque odio lacus, auctor at, posuere id, suscipit eget, dui. Phasellus aliquam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin varius. Phasellus cursus. Cras mattis adipiscing turpis. Sed.&lt;/p&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada auctor magna.&lt;/p&gt; &lt;/body&gt; &lt;/entry&gt; &lt;/news&gt; </code></pre> <p>What I need to do is take a portion of the <code>&lt;body&gt;</code> element, based on a specified length, for display in the blog style of:</p> <blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada auctor magna. Vivamus urna justo, pulvinar nec, sagittis malesuada, accumsan in, massa. Quisque mi purus, gravida eget, ultricies a, porta in, sem... <strong>more</strong></p> </blockquote> <p>...where <strong>more</strong> is a link to the full news item. I know I can select specific paragraphs and I also know I can use the substring function to bring a specified number of characters. However, I need to preserve the formatting of the text, i.e. the HTML tags within the <code>&lt;body&gt;</code> element.</p> <p>I realise this raises issues of tag closure but there must surely be a way. Hopefully someone more experienced with XSLT can shed some light on this issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload