-
-
Save pfhawkins/1672763 to your computer and use it in GitHub Desktop.
flatten
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
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:str="http://exslt.org/strings" | |
xmlns:re="http://exslt.org/regular-expressions" | |
extension-element-prefixes="str regexp" | |
xmlns="http://www.w3.org/1999/xhtml"> | |
<xsl:output mode="text" omit-xml-declaration="yes"/> | |
<xsl:template match="/"> | |
<xsl:apply-templates select="//table//tr" mode="variables"> | |
<xsl:sort/> | |
</xsl:apply-templates><xsl:apply-templates select="//table//tr"/></xsl:template> | |
<xsl:template match="tr"> | |
<xsl:if test="count(td) = 3"> | |
<xsl:value-of select="td[1]"/>|<xsl:value-of select="td[2]"/>|<xsl:value-of select="td[3]"/><xsl:text> | |
</xsl:text> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match="tr" mode="variables"> | |
<xsl:if test="count(td) = 3"> | |
<xsl:for-each select="td"> | |
<xsl:if test="re:test(., '.*\$\{[A-Za-z0-9]+\}.*')">variable|<xsl:value-of select="re:replace(., '.*\$\{([A-Za-z0-9]+)\}.*', '', '\1')"/>| | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment