Get value with : text « XSLT stylesheet « XML






Get value with

File: Data.xml
<?xml version="1.0"?>
<cv>
  <para>
    <performance>
      <publication>A</publication>
      B
      <venue>C</venue>
      D
      <group>E</group>
      F
      <date>1998</date>
      G
      <quote>
        test
      </quote>
      H
    </performance>
  </para>
</cv>

File: Transform.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="para">
    <p>
      <xsl:apply-templates />
    </p>
  </xsl:template>

  <xsl:template match="publication">
    <font face="arial">
      <xsl:apply-templates />
    </font>
  </xsl:template>

  <xsl:template match="quote">
    <xsl:text />
    "
    <xsl:apply-templates />
    "
    <xsl:text />
  </xsl:template>

  <xsl:template match="work">
    <i>
      <xsl:apply-templates />
    </i>
  </xsl:template>

  <xsl:template match="role">
    <u>
      <xsl:apply-templates />
    </u>
  </xsl:template>

</xsl:stylesheet>

Output:

<html>
   <body>
        
      <p>
             
               <font face="arial">A</font>
               B
               C
               D
               E
               F
               1998
               G
               
             "
             
                 test
               
             "
             
               H
             
           
      </p>
      
   </body>
</html>

 








Related examples in the same category

1.Start a new line with
2.Copy text with
3.Use text() function to get text
4.match an element and get text with text() function