I think there is no direct way to do this in XSL but wanted to check with you all before writing a server-side code.
I'm working on a website to display tweets from hundreds of different accounts using twitter API. There is a large XML file containing 200+ twitter ID's and count (1-12). I have a PHP script that does OAuth and outputs JSON using the twitter API. This PHP file takes both id and count as query strings. Now twitter does have a limit to the number of requests that can be sent per 15 minutes. Since the web page is generated using XSL transformation via Saxon, I was thinking to do something like-
<xsl:template name="all-social">
<xsl:for-each select="/social/twitter">
<xsl:value-of select="unparsed-text(concat('http://something/twitter.php?
id=',@id,'&count=',@count))"/>
<!-- or apply-templates select="document(--URL--)" -->
</xsl:for-each>
</xsl:template>
This will return the JSON of tweets and I can do everything on the front-end to display it properly. But to overcome the API limit I need to add a pause or sleep inside the for-each
loop like-
<xsl:template name="all-social">
<xsl:for-each select="/social/twitter">
<!-- Wait for 5 seconds -->
<xsl:value-of select="unparsed-text(concat('http://something/twitter.php?
id=',@id,'&count=',@count))"/>
</xsl:for-each>
</xsl:template>
Again, I understand this is very easy to do by just using the server-side scripting, by I'm curious if there is a way to add a sleep() during XSL transformation. Any ideas/recommendation will be highly appreciated.