0 users online. Create an account or sign in to join them.Users

Author:
wjnielsen
Version:
1.0
Release Date:
9 Sep 2012
Category:
Output

Description

Output the xpath as a string for an xml node. I use this for troubleshooting.

XSLT

View Raw
<?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>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.1
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details