I am fetching an XML document from a third party (so I cannot change it) which contains around 1000 records. I am translating this using XSLT to only show the user 50 records at a time. I can control which records are shown by checking the position e.g.
xsl:if test="not(position() < 101)"
xsl:if test="position() < 150"
The user would prefer to jump to a value rather than scrolling through page by page until they find it. The rest of the records should still show after the jump to value so I don't want to check for an exact match. I initially thought that I could do a string comparison e.g.
xsl:if test="@key >= 'jumpto'"
but this is not supported in 1.0. Any ideas how to achieve what I want?
The XML is quite large to post and the data is confidential. But imagine it is a simple XML file with just a name e.g.
<contacts>
<name>alan</name>
<name>brad</name>
<name>chad</name>
<name>dave</name>
<name>eric</name>
</contacts>
I want to only show the data starting from dave onwards and I can pass dave to the XSL document.
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="p">dave</xsl:param>
<xsl:template match="contacts">
<out>
<xsl:apply-templates
select="name[. = $p] | name[. = $p]/following-sibling::name"/>
</out>
</xsl:template>
<xsl:template match="name">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Output:
<out>
<name>dave</name>
<name>eric</name>
</out>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With