大家好,我有一个 xslt 模板的以下片段:
<select name="weightoption" id="weightoption">
<xsl:for-each select="product-waights/entry">
<option>
<xsl:attribute name="value">
<xsl:value-of select="price"/>
</xsl:attribute>
<xsl:value-of select="weight"/>
</option>
</xsl:for-each>
</select>
<xsl:variable name="item" select="menu-dish/entry/price" />
<xsl:apply-templates select="menu-dish" mode="menu_dish_information" >
<xsl:with-param name="price" select="$item"/>
</xsl:apply-templates>
在那里我有一个 selectBoks“weightoption”和一个变量项,我想让它等于 selectBox 的值。如果用户更改选择项以更新值并将其作为参数传递给模板。我知道如何使用 html/ajax 来完成,但不确定如何使用 xslt。请就此给我建议...另外,如果有帮助,我将添加我的 xml 文件
<?xml version="1.0" encoding="utf-8" ?>
<data>
<params>
<today>2021-09-17</today>
<current-time>16:38</current-time>
<this-year>2021</this-year>
<this-month>09</this-month>
<this-day>17</this-day>
<timezone>+03:00</timezone>
<website-name>Coffeeport</website-name>
<page-title>Блюдо</page-title>
<root>https://www.coffeeport.ru</root>
<workspace>https://www.coffeeport.ru/workspace</workspace>
<workspace-path>/workspace</workspace-path>
<http-host>www.coffeeport.ru</http-host>
<root-page>menu</root-page>
<current-page>dish</current-page>
<current-page-id>22</current-page-id>
<current-path>/menu/food/torty-na-zakaz/tort1</current-path>
<parent-path>/menu/categories/dishes</parent-path>
<current-query-string><![CDATA[debug=xml]]></current-query-string>
<current-url>https://www.coffeeport.ru/menu/food/torty-na-zakaz/tort1</current-url>
<upload-limit>134217728</upload-limit>
<symphony-version>2.7.7</symphony-version>
<type-slug>food</type-slug>
<category-slug>torty-na-zakaz</category-slug>
<dish-slug>tort1</dish-slug>
<cookie-xsrf-token>4he1qkd5kDX9RiQoOr1hF3PjJatxjV</cookie-xsrf-token>
<cookie-username>p.ivanov</cookie-username>
<cookie-pass>PBKDF2v1|10000|b3fbb565869af1c0c2f8|EKIe+sVXNrj3nLyLgpP5/2ipUwp5Bqvsdhm453yWpr7+MlPyPYlULA==</cookie-pass>
<page-types />
<page-events>
<item handle="feedback">feedback</item>
<item handle="canofspam">canofspam</item>
<item handle="subscribe">subscribe</item>
</page-events>
<recaptcha-sitekey>6LclP8UUAAAAAJPu6n28M7eN8jXbTfy-i814Sorr</recaptcha-sitekey>
<canofspam>d922f7c7543f732ecdc9756758aa2c838b155973</canofspam>
<ds-menu-category-id-by-slug.system-id>
<item handle="84653">84653</item>
</ds-menu-category-id-by-slug.system-id>
<ds-menu-category-id-by-slug>
<item handle="84653">84653</item>
</ds-menu-category-id-by-slug>
<ds-menu-type-id-by-slug.system-id>
<item handle="72">72</item>
</ds-menu-type-id-by-slug.system-id>
<ds-menu-type-id-by-slug>
<item handle="72">72</item>
</ds-menu-type-id-by-slug>
<ds-product-waights.weight>
<item handle="2-kg">2 кг</item>
<item handle="1-kg">1 кг</item>
</ds-product-waights.weight>
<ds-product-waights.price>
<item handle="800">800</item>
<item handle="500">500</item>
</ds-product-waights.price>
<ds-product-waights.product>
<item handle="84680">84680</item>
<item handle="84680">84680</item>
</ds-product-waights.product>
<ds-menu-dish.system-id>
<item handle="84680">84680</item>
</ds-menu-dish.system-id>
<ds-menu-dish.section>
<item handle="84653">84653</item>
</ds-menu-dish.section>
<ds-menu-dish.group />
</params>
<events>
<member-login-info logged-in="no" />
</events>
<contacts>
<section id="9" handle="contacts">Контакты</section>
<entry id="16">
<phone handle="8-800-777-02-18">8 800 777-02-18</phone>
<working-hours handle="s-9-00-do-20-00">с 9:00 до 20:00</working-hours>
<email handle="help-coffeeportru">help@coffeeport.ru</email>
<address handle="125047-g-moskva-ul-1-aya-brestskaya-d-62-pom-4">125047, г. Москва, ул. 1-ая Брестская, д. 62, пом. 4</address>
<legal mode="formatted"><p><strong>Юридический адрес :</strong><br />
125047, г. Москва, ул. 1-ая Брестская, д. 62, пом. 4</p>
<p><strong>ОГРН :</strong><br />
1197746491183</p>
<p><strong>ИНН/КПП :</strong><br />
9710077501/771001001</p>
</legal>
<text mode="formatted"><p style="text-align: center;">Вам есть, что сказать или предложить? <br />
Мы рады Вас услышать! <br />
Свяжитесь с нами любым удобным для Вас способом:</p>
</text>
</entry>
</contacts>
<menu-category-id-by-slug>
<section id="2" handle="menu-categories">Категории меню</section>
<entry id="84653">
<name handle="torty-na-zakaz-v-razrabotke">Торты на заказ (В разработке)</name>
<slug>torty-na-zakaz</slug>
<image>
<item>
<file size="701 KB" path="/public/images/sections" type="image/jpeg" extension="jpg">
<filename>desert_glavnaya.jpg</filename>
<meta creation="2020-12-10T20:32:12+03:00" width="3500" height="2333" />
</file>
</item>
</image>
<default-image>
<item>
<file size="15 KB" path="/public/images/menu/categories" type="image/jpeg" extension="jpeg">
<filename>bez-nazvaniya-1-.jpeg</filename>
<meta creation="2020-12-10T20:32:17+03:00" width="263" height="191" />
</file>
</item>
</default-image>
</entry>
</menu-category-id-by-slug>
<menu-type-id-by-slug>
<section id="22" handle="menu-types">Типы меню</section>
<entry id="72">
<name handle="eda">Еда</name>
<slug>food</slug>
<description mode="formatted"><p>Еда в КОФЕПОРТ — это оригинальные и традиционные рецепты, разнообразная выпечка и вкусности. Мы готовим для вас только из свежих и качественных ингредиентов. Наша еда - это всегда отличное дополнение к горячим и холодным напиткам, на любой вкус и в любое время дня.</p>
</description>
<text mode="formatted"><h2>Приятного аппетита!</h2>
<p>Мы рады предложить нашим гостям десерты собственного производства, свежие салаты, горячий суп, вкусные сэндвичи и роллы. Вы можете позавтракать или пообедать прямо в кофейне или взять еду с собой в офис или на прогулку. Мы готовим только из натуральных ингредиентов, не добавляя компонентов, увеличивающих срок годности наших вкусностей и выпечки. Поэтому каждое утро в КОФЕПОРТ вы найдете только самую качественную и свежую продукцию, произведенную в этот же день.</p>
</text>
</entry>
</menu-type-id-by-slug>
<presentation-file>
<section id="19" handle="presentation">Презентация</section>
<entry id="36">
<file>
<item>
<file size="6.84 MB" path="/public/files/presentation" type="application/pdf" extension="pdf">
<filename>coffeeport_prezentatsiya_04.01.2021.pdf</filename>
<meta creation="2021-01-11T09:41:14+03:00" />
</file>
</item>
</file>
</entry>
</presentation-file>
<menu-categories-all>
<section id="2" handle="menu-categories">Категории меню</section>
<type link-id="72" link-handle="eda" value="Еда">
<entry id="2">
<name handle="vkusnosti">Вкусности</name>
<slug>bakery</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="4">
<name handle="deserty">Десерты</name>
<slug>deserts</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="5">
<name handle="zavtraki">Завтраки</name>
<slug>breakfasts</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="140">
<name handle="rolly">Роллы</name>
<slug>rolly</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="141">
<name handle="cupy">Cупы</name>
<slug>supy</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="153">
<name handle="salaty">Салаты</name>
<slug>salaty</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="154">
<name handle="sendvichi">Сэндвичи </name>
<slug>sendvichi</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="20930">
<name handle="pirogi-na-zakaz">Пироги на заказ</name>
<slug>pirogi-na-zakaz</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
<entry id="84653">
<name handle="torty-na-zakaz-v-razrabotke">Торты на заказ (В разработке)</name>
<slug>torty-na-zakaz</slug>
<type>
<item id="72" handle="eda" section-handle="menu-types" section-name="Типы меню">Еда</item>
</type>
</entry>
</type>
<type link-id="387" link-handle="dobavki" value="Добавки">
<entry id="147">
<name handle="siropy">Сиропы</name>
<slug>dobavki-k-goryachim-napitkam-i-kofe</slug>
<type>
<item id="387" handle="dobavki" section-handle="menu-types" section-name="Типы меню">Добавки</item>
</type>
</entry>
<entry id="391">
<name handle="dobavki">Добавки</name>
<slug>dobavki</slug>
<type>
<item id="387" handle="dobavki" section-handle="menu-types" section-name="Типы меню">Добавки</item>
</type>
</entry>
<entry id="454">
<name handle="spetsii">Специи</name>
<slug>spetsii</slug>
<type>
<item id="387" handle="dobavki" section-handle="menu-types" section-name="Типы меню">Добавки</item>
</type>
</entry>
</type>
<type link-id="390" link-handle="napitki" value="Напитки">
<entry id="148">
<name handle="goryachie-napitki">Горячие напитки </name>
<slug>goryachie-napitki</slug>
<type>
<item id="390" handle="napitki" section-handle="menu-types" section-name="Типы меню">Напитки</item>
</type>
</entry>
<entry id="150">
<name handle="holodnye-napitki">Холодные напитки </name>
<slug>holodnye-napitki</slug>
<type>
<item id="390" handle="napitki" section-handle="menu-types" section-name="Типы меню">Напитки</item>
</type>
</entry>
<entry id="151">
<name handle="svezhevyzhatye-soki">Свежевыжатые соки</name>
<slug>svezhevyzhatye-soki-na-100-ml</slug>
<type>
<item id="390" handle="napitki" section-handle="menu-types" section-name="Типы меню">Напитки</item>
</type>
</entry>
<entry id="397">
<name handle="kofejnye-napitki">Кофейные напитки</name>
<slug>kofejnye-napitki</slug>
<type>
<item id="390" handle="napitki" section-handle="menu-types" section-name="Типы меню">Напитки</item>
</type>
</entry>
</type>
</menu-categories-all>
<map-cities>
<section id="20" handle="cities">Города</section>
<entry id="37">
<name handle="moskva">Москва</name>
<slug>moscow</slug>
</entry>
</map-cities>
<menu-types>
<section id="22" handle="menu-types">Типы меню</section>
<entry id="72">
<name handle="eda">Еда</name>
<slug>food</slug>
<image>
<item>
<file size="1.39 MB" path="/public/images/menu/categories" type="image/jpeg" extension="jpg">
<filename>zastavka-eda.jpg</filename>
<meta creation="2019-09-30T20:11:00+03:00" width="3000" height="2002" />
</file>
</item>
</image>
<description mode="formatted"><p>Еда в КОФЕПОРТ — это оригинальные и традиционные рецепты, разнообразная выпечка и вкусности. Мы готовим для вас только из свежих и качественных ингредиентов. Наша еда - это всегда отличное дополнение к горячим и холодным напиткам, на любой вкус и в любое время дня.</p>
</description>
</entry>
<entry id="390">
<name handle="napitki">Напитки</name>
<slug>drinks</slug>
<image>
<item>
<file size="107 KB" path="/public/images/menu/categories" type="image/jpeg" extension="jpg">
<filename>zastavka-na-razdel-napitki.jpg</filename>
<meta creation="2019-11-06T10:34:06+03:00" width="1404" height="937" />
</file>
</item>
</image>
<description mode="formatted"><p>Хороший кофе — наша работа. Напитки от КОФЕПОРТ- это прекрасный способ взбодриться перед началом рабочего дня и хороший повод сделать паузу в напряженном рабочем графике. Наслаждайтесь каждый день!</p>
</description>
</entry>
<entry id="387">
<name handle="dobavki">Добавки</name>
<slug>syrups</slug>
<image>
<item>
<file size="944 KB" path="/public/images/menu/categories" type="image/png" extension="png">
<filename>dobavki_na_glavnuyu.png</filename>
<meta creation="2018-12-24T17:57:04+03:00" width="1248" height="590" />
</file>
</item>
</image>
<description mode="formatted"><p>У нас вы всегда можете попробовать что-то новое или придать знакомому напитку необычный вкус. Попросите нашего сотрудника добавить в кофе один из наших фирменных сиропов и не забудьте про корицу и другие пряности. Экспериментируйте: добавок у нас очень много!</p>
</description>
</entry>
</menu-types>
<map-city-first>
<section id="20" handle="cities">Города</section>
<entry id="37">
<slug>moscow</slug>
</entry>
</map-city-first>
<cart id="82222" price="0" discount="0" calories="0" calories-calc="0">
<section id="3" handle="dishes">Блюда</section>
<error>No records found.</error>
<cards quantity="0"></cards>
</cart>
<delivery-index>
<section id="40" handle="delivery">Доставка</section>
<entry id="1766">
<title handle="dostavka">Доставка</title>
<slug>delivery</slug>
</entry>
</delivery-index>
<highlight>
<section id="47" handle="highlight">Уведомление</section>
<entry id="32297">
<text mode="formatted">
<p>На сайте работает доставка, и появилась возможность забронировать вкусности в любимой кофейне. Для этого сделайте заказ в <a href="https://www.coffeeport.ru/menu/">меню</a>. Как это <a href="https://www.coffeeport.ru/info/delivery/">работает</a>?</p>
</text>
<order-notice handle="besplatnyj-samovyvoz-iz-lyuboj-nashej-kofejni-soglasno-grafiku-raboty">Бесплатный самовывоз из любой нашей кофейни согласно графику работы.</order-notice>
</entry>
</highlight>
<product-waights>
<section id="48" handle="waights">веса продуктов</section>
<entry id="85990">
<weight handle="2-kg">2 кг</weight>
<price handle="800">800</price>
<product entries="84680" sections="3" x-data-source-mode="dishes.name, dishes.slug" x-field-included-elements="dishes.name, dishes.slug">
<item id="84680" level="1" max-level="-1" section-id="3" section="dishes" matched-element="slug">
<name handle="tort-1">Торт 1</name>
<slug>tort1</slug>
</item>
</product>
</entry>
<entry id="84286">
<weight handle="1-kg">1 кг</weight>
<price handle="500">500</price>
<product entries="84680" sections="3" x-data-source-mode="dishes.name, dishes.slug" x-field-included-elements="dishes.name, dishes.slug">
<item id="84680" level="1" max-level="-1" section-id="3" section="dishes" matched-element="slug">
<name handle="tort-1">Торт 1</name>
<slug>tort1</slug>
</item>
</product>
</entry>
</product-waights>
<menu-dish>
<section id="3" handle="dishes">Блюда</section>
<entry id="84680">
<name handle="tort-1">Торт 1</name>
<weight handle="1">1</weight>
<price handle="500">500</price>
<short-description mode="formatted"><p>Тестовый продукт не заказывать</p>
</short-description>
<description mode="formatted"><p>Тестовый продукт не заказывать</p>
</description>
<images>
<item>
<file size="994 KB" path="/public/images/dishes" type="image/jpeg" extension="jpg">
<filename>101kruassan-mindalnyi-.jpg</filename>
<meta creation="2020-12-10T20:32:05+03:00" width="3500" height="1972" />
</file>
</item>
</images>
<forbidden>No</forbidden>
<coffeehouse>No</coffeehouse>
<mini>No</mini>
<consist><![CDATA[Не известно]]></consist>
<calories>100</calories>
<energy-value>50</energy-value>
<protein>80</protein>
<fat>90</fat>
<carbohydrates>50</carbohydrates>
</entry>
</menu-dish>
<menu-dish-same-category>
<section id="3" handle="dishes">Блюда</section>
<entry id="84680">
<name handle="tort-1">Торт 1</name>
<slug>tort1</slug>
<weight handle="1">1</weight>
<price handle="500">500</price>
<images>
<item>
<file size="994 KB" path="/public/images/dishes" type="image/jpeg" extension="jpg">
<filename>101kruassan-mindalnyi-.jpg</filename>
<meta creation="2020-12-10T20:32:05+03:00" width="3500" height="1972" />
</file>
</item>
</images>
<forbidden>No</forbidden>
<coffeehouse>No</coffeehouse>
<mini>No</mini>
</entry>
</menu-dish-same-category>
<menu-dishes-by-group>
<section id="3" handle="dishes">Блюда</section>
<error required-param="$ds-menu-dish.group">Data source not executed, required parameter is missing.</error>
</menu-dishes-by-group>
</data>