 <blockquote> <p>So my question is how can i set the response object to contain the processed list of the images</p> </blockquote> <p>Use a stylesheet rather than an XPath selector:</p> <pre><code> select * from xslt where url="http://www.mysite.com/page-path" and stylesheet="http://www.mysite.com/page-path.xsl" </code></pre> <p>Define the stylesheet as such:</p> <pre><code> &lt;xsl:template match="img[@alt]"&gt; &lt;xsl:for-each select="@alt"&gt; &lt;script&gt; alt.push(&lt;xsl:value-of select="."/&gt;); &lt;/script&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;xsl:template match="img[not(@alt)]"&gt; &lt;xsl:for-each select="@src"&gt; &lt;script&gt; noalt.push(&lt;xsl:value-of select="."/&gt;); &lt;/script&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; </code></pre>