Created
December 19, 2013 03:28
-
-
Save wjn/8033990 to your computer and use it in GitHub Desktop.
Write Path: a utility that I use for XSLT debugging, which will show the present XPath location in an XML document.
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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:template name="write-path"> | |
<xsl:param name="path"/> | |
<xsl:param name="output"/> | |
<xsl:choose> | |
<xsl:when test="$path/parent::node()"> | |
<xsl:call-template name="write-path"> | |
<xsl:with-param name="output"> | |
<xsl:choose> | |
<xsl:when test="$output"> | |
<xsl:value-of select="concat(local-name($path), '/', $output)"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="local-name($path)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:with-param> | |
<xsl:with-param name="path" select="$path/parent::node()"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="concat('/',$output)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment