id() function : id « XSLT stylesheet « XML






id() function



File: Data.xml

<?xml version="1.0" encoding="UTf-8" ?>
<emailList>
  <person>
    <name>name 1</name>
    <email>g@gmail.com</email>
  </person>
  <person>
    <name>name 2</name>
    <email>n@hotmail.com</email>
  </person>
</emailList>
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="emailList/person">
    <xsl:if test="id('p001 p002')">
      <div id="{@id}">
        <div>
          <xsl:value-of select="name" />
        </div>
        <div>
          <xsl:value-of select="email" />
        </div>
      </div>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

 








Related examples in the same category

1.ID: xsl:value-of select="id(.)"