Making an XSL stylesheet work with paged XML
Posted
by fudgey
on Stack Overflow
See other posts from Stack Overflow
or by fudgey
Published on 2010-03-25T17:27:20Z
Indexed on
2010/03/26
4:33 UTC
Read the original article
Hit count: 485
First off, here is the situation. I'm using a guild hosting site that allows you to input the URL to an XSL file and another input for the XML. All well and good when all of the XML you want is contained in one file.
My problem is this Game Roster XML which is paginated... look near the bottom of the file and you will find a <page_links>
section that contains a pager written in HTML with links to /xml?page=2
etc. Since the guild hosting site is set up to only process one XML page I can't get to the other XML pages.
So, I can only think of two solutions, but I have no idea how to get started
- Set up a php page that combines all XML pages into one, then output that file. I can then use this URL in the guild hosting site XSL processor.
- Somehow combine all the XML files within the XSL stylesheet. I found this question on SO (I don't really understand it, because I don't know what the
document($pXml1)
is doing), but I don't think it will work since the number of pages will be variable. I think this might be possible by loading the next page until the<members_to>
value equals the<members_total>
.
Any other ideas? I don't know XSL or php that well so any help with code examples would be greatly appreciated.
Update: I'm trying method 2 above and here is a snippet of XSLT with which I am having trouble. The first page of the code displays without problems, but the I am having trouble with this xsl:if
, or maybe it's the document()
statement.
Update #2: changed the document to use the string & concat functions, but it's still not working.
<xsl:template name="morepages">
<xsl:param name="page">1</xsl:param>
<xsl:param name="url">
<xsl:value-of select="concat(SuperGroup/profule_url,'/xml?page=')"/>
</xsl:param>
<xsl:if test="document(string(concat($url,$page)))/SuperGroup/members_to < document(string(concat($url,$page)))/SuperGroup/members_total">
<xsl:for-each select="document(string(concat($url,$page + 1)))/SuperGroup/members/members_node">
<xsl:call-template name="addrow" />
</xsl:for-each>
<!-- Increment page index-->
<xsl:call-template name="morepages">
<xsl:with-param name="page" select="$page + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
© Stack Overflow or respective owner