ایکس ایس ایل تی <xsl:template> عنصر

ਨਿਰਧਾਰਣ ਅਤੇ ਵਰਤੋਂ

<xsl:template> ਇਲੈਕਟਰੌਨ ਵਿੱਚ ਨਿਰਧਾਰਤ ਇਲੈਕਟਰੌਨ ਨਾਲ ਮੈਚ ਕਰਨ ਲਈ ਲਾਗੂ ਕੀਤੇ ਜਾਣ ਵਾਲੇ ਨਿਯਮਾਂ ਨੂੰ ਸ਼ਾਮਲ ਕਰਦਾ ਹੈ。

match ਗੁੰਜਾਇਸ਼ ਟੈਮਪਲੇਟ ਨੂੰ ਕਿਸੇ XML ਇਲੈਕਟਰੌਨ ਨਾਲ ਜੋੜਦਾ ਹੈ (ਉਦਾਹਰਣ, match="/" ਪੂਰੇ ਦਸਤਾਵੇਜ਼ ਦੇ ਸਾਰੇ ਖੰਡਾਂ ਨੂੰ ਨਿਰਧਾਰਤ ਕਰਦਾ ਹੈ)。

ਟਿੱਪਣੀ:<xsl:template> ਹੈ ਉੱਚ ਪੱਧਰੀ ਇਲੈਕਟਰੌਨ (top-level element)।

ਵਿਧਾਨ

<xsl:template
name="name"
match="pattern"
mode="mode"
priority="number">
  <!-- Content:(<xsl:param>*,template) -->
</xsl:template>

ਗੁੰਜਾਇਸ਼

ਗੁੰਜਾਇਸ਼ ਮੁੱਲ ਵਰਣਨ
name name

ਚੋਣੀਬੱਧ। ਟੈਮਪਲੇਟ ਦਾ ਨਾਮ ਨਿਰਧਾਰਤ ਕਰੋ

ਟਿੱਪਣੀ: ਜੇਕਰ ਇਹ ਗੁੰਜਾਇਸ਼ ਛੱਡ ਦਿੱਤੀ ਜਾਂਦੀ ਹੈ ਤਾਂ ਮਾਤਰ match ਗੁੰਜਾਇਸ਼ ਨੂੰ ਸੈਟ ਕਰਨਾ ਹੋਵੇਗਾ。

match pattern

ਚੋਣੀਬੱਧ। ਟੈਮਪਲੇਟ ਦਾ ਮੈਚ ਪੈਟਰਨ

ਟਿੱਪਣੀ: ਜੇਕਰ ਇਹ ਗੁੰਜਾਇਸ਼ ਛੱਡ ਦਿੱਤੀ ਜਾਂਦੀ ਹੈ ਤਾਂ ਮਾਤਰ name ਗੁੰਜਾਇਸ਼ ਨੂੰ ਸੈਟ ਕਰਨਾ ਹੋਵੇਗਾ。

mode mode ਚੋਣੀਬੱਧ। ਟੈਮਪਲੇਟ ਨੂੰ ਮੋਡ ਨਿਰਧਾਰਤ ਕਰੋ
priority number ਚੋਣੀਬੱਧ। ਟੈਮਪਲੇਟ ਦੀ ਪਹਿਲਵਾਂ ਨੰਬਰ

ਉਦਾਹਰਣ

ਉਦਾਹਰਣ 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
  <h2>My CD Collection</h2> 
  <xsl:apply-templates/> 
  </body>
  </html>
</xsl:template>
<xsl:template match="cd">
  <p>
  <xsl:apply-templates select="title"/> 
  <xsl:apply-templates select="artist"/>
  </p>
</xsl:template>
<xsl:template match="title">
  Title: <span style="color:#ff0000">
  <xsl:value-of select="."/></span>
  <br />
</xsl:template>
<xsl:template match="artist">
  Artist: <span style="color:#00ff00">
  <xsl:value-of select="."/></span>
  <br />
</xsl:template>
</xsl:stylesheet>