Relative context
File: Data.xml <book> <title>title 1</title> <chapter> <title>chapter 1</title> <para>line 1</para> <para>line 2</para> </chapter> <chapter> <title>title 2</title> <para>line 3</para> <para>line 4</para> </chapter> </book> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="title"> Title: <xsl:apply-templates /> </xsl:template> <xsl:template match="chapter/title"> Chapter title: <xsl:apply-templates /> </xsl:template> </xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?> Title: title 1 Chapter title: chapter 1 line 1 line 2 Chapter title: title 2 line 3 line 4