Category Enterprise information systems

Assign variable in xml

Posted on by YUONNE C.

XSLT <xsl:variable>


❮ Whole XSLT Part Reference

Definition as well as Usage

The <xsl:variable> element is certainly used for you to lay claim a city and global variable.

Note: The particular adjustable is normally global in case it truly is announced because an important top-level factor, as well as native if it truly is proclaimed within some sort of template.

Note: Now that people include set in place a fabulous variable's cost, everyone could not change or simply revise that will value!

Tip: Most people can certainly increase a good importance to be able to your varying by your articles in all the <xsl:variable> facet And by just any choose attribute!


Syntax

<xsl:variable
name="name"
select="expression">

  <!-- Content:template -->

</xsl:variable>

Attributes

AttributeValueDescription
namenameRequired.

assign adaptable during xml

Specifies that designate connected with the variable

selectexpressionOptional. Becomes that benefits connected with rubrics meant for owners thesis variable

Example 1

If this decide trait is gift, the particular <xsl:variable> issue cannot really contain any kind of subject matter.

When the actual opt for credit consists of some literal chain, typically the string will have to be inside quotations. The actual soon after a couple of samples nominate your significance "red" to help you that subject to shifts "color":

<xsl:variable name="color" select="'red'" />


<xsl:variable name="color" select='"red"' />

Example 2

If any <xsl:variable> part primarily contains any label feature, and even now there is absolutely no subject material, and then that significance for the particular adaptable is a particular useless string:

<xsl:variable name="j" />

Example 3

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

<xsl:variable name="header">
  <tr bgcolor="#9acd32">
    <th>Title</th>
    <th>Artist</th>
  </tr>
</xsl:variable>

<xsl:template match="/">
  <html>
  <body>
  <table border="1">
    <xsl:copy-of select="$header" />
    <xsl:for-each select="catalog/cd">
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>


❮ Complete XSLT Component Reference

assign variable with xml

0 thoughts on “Assign variable in xml

Add comments

Your e-mail will not be published. Required fields *