Last active
March 15, 2019 07:44
-
-
Save brendo/511115fb5f1997cc24a28c3ad86cba26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<people> | |
<item id='1'>Fred</item> | |
<item id='2'>Jane</item> | |
<item id='3'>Bob</item> | |
<item id='4'>Mary</item> | |
<item id='6'>Tom</item> | |
</people> | |
<people-details> | |
<entry id='1'> | |
<name>Fred</name> | |
<show>Yes</show> | |
</entry> | |
<entry id='2'> | |
<name>Jane</name> | |
<show>No</show> | |
</entry> | |
<entry id='3'> | |
<name>Bob</name> | |
<show>Yes</show> | |
</entry> | |
<entry id='4'> | |
<name>Mary</name> | |
<show>No</show> | |
</entry> | |
<entry id='5'> | |
<name>Max</name> | |
<show>Yes</show> | |
</entry> | |
<entry id='6'> | |
<name>Tom</name> | |
<show>Yes</show> | |
</entry> | |
</people-details> | |
</data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> | |
<xsl:output method="xml" indent="yes" /> | |
<xsl:template match="/"> | |
<data> | |
<xsl:variable name='folks'> | |
<xsl:for-each select='data/people/item'> | |
<xsl:copy-of select='/data/people-details/entry[@id = current()/@id and show = "Yes"]' /> | |
</xsl:for-each> | |
</xsl:variable> | |
<xsl:apply-templates select='exsl:node-set($folks)/entry[position() < 3]' mode='show-people' /> | |
</data> | |
</xsl:template> | |
<xsl:template match="entry" mode='show-people'> | |
<name> | |
<xsl:value-of select='name' /> | |
</name> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment