Reference text after selecting tags and attributes : text « XSLT stylesheet « XML Tutorial

Home
XML Tutorial
1.Introduction
2.Namespace
3.XML Schema
4.XPath
5.XSLT stylesheet
XML Tutorial » XSLT stylesheet » text 
5.70.2.Reference text after selecting tags and attributes
File: Data.xml

<employee hireDate="09/01/1998">
  <last>A</last>
  <first>B</first>
  <salary>95000</salary>
</employee>

File: Transform.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes" />
  <xsl:template match="employee">
    <xsl:apply-templates select="@hireDate" />
    <xsl:text>
        </xsl:text>
    <xsl:apply-templates select="first" />
    <xsl:text> 
        </xsl:text>
    <xsl:apply-templates select="last" />
  </xsl:template>
  

</xsl:stylesheet>

Output:

09/01/1998
        
        A
5.70.text
5.70.1.select='@title | text()'
5.70.2.Reference text after selecting tags and attributes
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.