·  XSLT – Elements – <xsl:value-of>

 

- Info :

  - If select attribute specifies element's attribute, then it's value is returned.

  - If select attribute specifies an element, then value of FIRST element, which satisfyes select criteria, is returned.

    This means that if specified element contains substructure, string with values of all child text elements is returned.

  - To reference current element, for instance one returned by <xsl:for-each>, set select attribute to "." .

 

- Example:

 

    test.xml

    <?xml version="1.0"?>

    <?xml-stylesheet type="text/xsl" href="test.xsl"?>

    

    <people>

    

      List of students

      <student id="88765">

    

        <name>   

          Jack

          <subname>

            Junior 

          </subname>

        </name>

    

        <name>Jill</name>

    

        <age > 23 </age>

    

      </student>

    

    </people>

    

    test.xsl

    <?xml version="1.0" ?>

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

    

      <xsl:template match="people">

        <xsl:value-of select="student/name"/> <br/>

        <xsl:value-of select="student/@id" /> <br/>

      </xsl:template>

      

    </xsl:stylesheet>

    

    result

    Jack Junior
    88765