Jump to content
  • 0

Тег начинается xsl:


hike
 Share

Question

4 answers to this question

Recommended Posts

  • 0

Файл формата HTML начинается

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

Подскажите, что это за язык? Посоветуйте учебник, плиз.

Это шаблонизатор.

В документе подключается примерно так:


<?php
$Structure = & singleton('Structure');
$Structure->ShowStructure(2, 'ЛевоеМеню');
?>

В одном xsl может быть прописаны параметры для всех модулей сайта.

Выглядит примерно так:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml" />

<!-- ОтобразитьФорму -->

<xsl:template match="/">
<xsl:apply-templates select="/document" />
</xsl:template>

<xsl:template match="/document">

<!-- Проверка формы -->
<script type="text/javascript" language="JavaScript">
$(document).ready(function() {
$("#form<xsl:value-of select="forms_id" />").validate({
focusInvalid: true,
errorClass: "input_error"
})
});
</SCRIPT>

<h1><xsl:value-of disable-output-escaping="yes" select="forms_name" /></h1>

<xsl:choose>
<!-- Выводим ошибку (error), если она была передана через внешний параметр -->
<xsl:when test="error != ''">
<div id="error">
<xsl:value-of disable-output-escaping="yes" select="error" />
</div>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="forms_description" />
</xsl:otherwise>
</xsl:choose>

<!-- Параметр action формы должен быть "./", если обработчик на этой же странице, либо "./form/", если обработчик на другой странице, например ./form/ -->
<form name="form{forms_id}" id="form{forms_id}" class="validate" action="./" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="2" cellspacing="0">
<!-- Вывод спсика полей формы -->
<xsl:apply-templates select="fields/field" mode="show_form" />

<!-- Код подтверждения -->
<xsl:if test="forms_captcha_key != 0">
<tr>
<td>Контрольные цифры
<sup>
<font color="red">*</font>
</sup>
</td>
<td>
<img id="form_captcha_{/document/forms_id}_{/document/forms_captcha_key}" src="/captcha.php?get_captcha={forms_captcha_key}&height=30&width=100" class="image" name="captcha" />

<div id="captcha">
<img style="border: 0px" src="/hostcmsfiles/images/refresh.gif" /> <a href="javascript:void(0);" onclick="ReNewCaptchaById('form_captcha_{/document/forms_id}_{/document/forms_captcha_key}', '{forms_captcha_key}', 30); return false;">Показать другое число</a>
</div>

<input type="hidden" name="captcha_key" value="{forms_captcha_key}" size="5" />
<input type="text" name="captcha_keystring" class="required" minlength="4" title="Введите число, которое указано выше." />
<!-- <div id="captcha">Введите число, которое указано выше.</div> -->
</td>
</tr>
</xsl:if>
<tr>
<td colspan="2" align="center">
<xsl:choose>
<!-- Простая кнопка -->
<xsl:when test="forms_button_type = 0">
<input name="{forms_button_name}" value="{forms_button_text_value}" type="submit" />
</xsl:when>
<!-- Кнопка с картинкой -->
<xsl:otherwise>
<button name="{forms_button_name}" value="{forms_button_value}" type="submit">
<xsl:value-of disable-output-escaping="yes" select="forms_button_text_value" />
</button>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</form>
</xsl:template>

<xsl:template match="fields/field" mode="show_form">
<!-- Не скрытое поле и не надпись -->
<xsl:if test="type != 7 and type != 8">
<tr>
<td>
<xsl:value-of disable-output-escaping="yes" select="field_text_name" />
<xsl:if test="obligatory=1">
<sup>
<font color="red">*</font>
</sup>
</xsl:if> </td>
<td>
<!-- Текстовые поля -->
<xsl:if test="type = 0 or type = 1 or type = 2">
<input type="text" name="{name}" value="{value}" size="{size}">
<xsl:choose>
<xsl:when test="type = 1">
<xsl:attribute name="type">password</xsl:attribute>
</xsl:when>
<!-- Поле для ввода пароля -->
<xsl:when test="type = 2">
<xsl:attribute name="type">file</xsl:attribute>
</xsl:when>
<!-- Поле загрузки файла -->
<xsl:otherwise>
<xsl:attribute name="type">text</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="obligatory = 1">
<xsl:attribute name="class">required</xsl:attribute>
<xsl:attribute name="minlength">1</xsl:attribute>
<xsl:attribute name="title">Заполните поле <xsl:value-of disable-output-escaping="yes" select="field_text_name" /></xsl:attribute>
</xsl:if>
</input>
</xsl:if>

<!-- Радиокнопки -->
<xsl:if test="type = 3 or type = 9">
<xsl:apply-templates select="list/list_item" />
<label class="input_error" for="{name}" style="display: none">Выберите, пожалуйста, значение.</label>
</xsl:if>

<!-- Checkbox -->
<xsl:if test="type = 4">
<input type="checkbox" name="{name}">
<xsl:if test="checked = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:if>

<!-- Textarea -->
<xsl:if test="type = 5">
<textarea name="{name}" cols="{cols}" rows="{rows}" wrap="off">
<xsl:if test="obligatory = 1">
<xsl:attribute name="class">required</xsl:attribute>
<xsl:attribute name="minlength">1</xsl:attribute>
<xsl:attribute name="title">Заполните поле <xsl:value-of disable-output-escaping="yes" select="field_text_name" /></xsl:attribute>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="value" />
</textarea>
</xsl:if>

<!-- Список -->
<xsl:if test="type = 6">
<select name="{name}">
<xsl:if test="obligatory = 1">
<xsl:attribute name="class">required</xsl:attribute>
<xsl:attribute name="title">Заполните поле <xsl:value-of disable-output-escaping="yes" select="field_text_name" /></xsl:attribute>
</xsl:if>
<option value="">...</option>
<xsl:apply-templates select="list/list_item" />
</select>
</xsl:if>
</td>
</tr>
</xsl:if>

<!-- скрытое поле -->
<xsl:if test="type = 7">
<input type="hidden" name="{name}" value="{value}" />
</xsl:if>

<!-- Надпись -->
<xsl:if test="type = 8">
<tr>
<td colspan="2" align="center">
<strong><xsl:value-of disable-output-escaping="yes" select="field_default_value" /></strong>
</td>
</tr>
</xsl:if>
</xsl:template>

<!-- Формируем радиогруппу или выпадающий список -->
<xsl:template match="list/list_item">
<xsl:if test="../../type = 3">
<input id="{../../name}_{list_item_id}" type="radio" name="{../../name}" value="{list_item_value}">
<xsl:if test="list_item_value = ../../value">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
<xsl:if test="../../obligatory = 1">
<xsl:attribute name="class">required</xsl:attribute>
<xsl:attribute name="minlength">1</xsl:attribute>
<xsl:attribute name="title">Заполните поле <xsl:value-of disable-output-escaping="yes" select="field_text_name" /></xsl:attribute>
</xsl:if>
</input> 
<label for="{../../name}_{list_item_id}"><xsl:value-of disable-output-escaping="yes" select="list_item_value" /></label>
<br/>
</xsl:if>

<xsl:if test="../../type = 6">
<option value="{list_item_value}">
<xsl:if test="list_item_value = ../../value">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="list_item_value" />
</option>
</xsl:if>

<xsl:if test="../../type = 9">
<input id="{../../name}_{list_item_id}" type="checkbox" name="{../../name}" value="{list_item_value}">
<xsl:if test="list_item_value = ../../value">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
<xsl:if test="../../obligatory = 1">
<xsl:attribute name="class">required</xsl:attribute>
<xsl:attribute name="minlength">1</xsl:attribute>
<xsl:attribute name="title">Заполните поле <xsl:value-of disable-output-escaping="yes" select="field_text_name" /></xsl:attribute>
</xsl:if>
</input> 
<label for="{../../name}_{list_item_id}"><xsl:value-of disable-output-escaping="yes" select="list_item_value" /></label>
<br/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy