<cart>
<dimensions>15.2/44/13.5</dimensions>
</cart>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/cart">
<div>
<xsl:text>Ширина: </xsl:text>
<xsl:value-of select="substring-before(dimensions, '/')"/>
</div>
<div>
<xsl:text>Высота:</xsl:text>
<xsl:value-of select="substring-before(substring-after(dimensions, '/'), '/')"/>
</div>
<div>
<xsl:text>Глубина:</xsl:text>
<xsl:value-of select="substring-after(substring-after(dimensions, '/'), '/')"/>
</div>
</xsl:template>
</xsl:stylesheet>
<div>Ширина: 15.2</div>
<div>Высота:44</div>
<div>Глубина:13.5</div>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root/APPLICATION">
<html>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<h1><xsl:value-of select="root/APPLICATION/@NAME"/> </h1>
<table border="1">
<tr>
<td>ID</td>
<td>Deleted</td>
<td>IsLocked</td>
<td>RetriveTime</td>
<td>ChangeTime</td>
<td>AccessTime</td>
<td>SecureStyleID</td>
<td>Name</td>
<td>DBName</td>
<td>TheComment</td>
</tr>
<xsl:apply-templates select="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="MTZAPP_COL/MTZAPP | OBJECTMODE_COL/OBJECTMODE">
<tr>
<td><xsl:value-of select="@ID"/></td>
<td><xsl:value-of select="@Deleted"/></td>
<td><xsl:value-of select="@IsLocked"/></td>
<td><xsl:value-of select="@RetriveTime"/></td>
<td><xsl:value-of select="@ChangeTime"/></td>
<td><xsl:value-of select="@AccessTime"/></td>
<td><xsl:value-of select="@SecureStyleID"/></td>
<td><xsl:value-of select="@Name"/></td>
<td><xsl:value-of select="@DBName"/></td>
<td><xsl:value-of select="@TheComment"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<root>
<foo/>
</root>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<operations>
<xsl:call-template name="operation">
<xsl:with-param name="counter" select="5"/>
</xsl:call-template>
</operations>
</xsl:template>
<xsl:template name="operation">
<xsl:param name="counter" select="1"/>
<operation>
<name>
<xsl:text>Ivan</xsl:text>
<xsl:value-of select="$counter"/>
</name>
<price>
<xsl:value-of select="100 * $counter"/>
</price>
</operation>
<xsl:if test="$counter > 0">
<xsl:call-template name="operation">
<xsl:with-param name="counter" select="$counter - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
xsltproc proc.xsl data.xml > result.xml
cat result.xml
<?xml version="1.0"?>
<operations>
<operation>
<name>Ivan5</name>
<price>500</price>
</operation>
<operation>
<name>Ivan4</name>
<price>400</price>
</operation>
<operation>
<name>Ivan3</name>
<price>300</price>
</operation>
<operation>
<name>Ivan2</name>
<price>200</price>
</operation>
<operation>
<name>Ivan1</name>
<price>100</price>
</operation>
<operation>
<name>Ivan0</name>
<price>0</price>
</operation>
</operations>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<operations>
<xsl:for-each select="1 to 10">
<operation>
<name>
<xsl:text>Ivan</xsl:text>
<xsl:value-of select="position()"/>
</name>
<price>
<xsl:value-of select="100 * position()"/>
</price>
</operation>
</xsl:for-each>
</operations>
</xsl:template>
</xsl:stylesheet>
saxonb-xslt -s:data.xml -xsl:proc.xsl -o:result.xml
cat result.xml
<?xml version="1.0" encoding="UTF-8"?>
<operations>
<operation>
<name>Ivan1</name>
<price>100</price>
</operation>
<operation>
<name>Ivan2</name>
<price>200</price>
</operation>
<operation>
<name>Ivan3</name>
<price>300</price>
</operation>
<operation>
<name>Ivan4</name>
<price>400</price>
</operation>
<operation>
<name>Ivan5</name>
<price>500</price>
</operation>
<operation>
<name>Ivan6</name>
<price>600</price>
</operation>
<operation>
<name>Ivan7</name>
<price>700</price>
</operation>
<operation>
<name>Ivan8</name>
<price>800</price>
</operation>
<operation>
<name>Ivan9</name>
<price>900</price>
</operation>
<operation>
<name>Ivan10</name>
<price>1000</price>
</operation>
</operations
<xsl:templates match="property[@name='artikul']" >
<div>Артикул: <xsl:apply-templates select="value"/></div>
</xsl:templates>
<meta itemprop="position" content="{position() + 1}"/>
Вопрос, как мне правильно составить XSL шаблон чтобы я мог пробежаться по всем вложенным группам?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" encoding="utf-8" version="1.0"/>
<xsl:template match="/informationsystem">
<xsl:if test="count(informationsystem_group) > 0">
<ul>
<xsl:apply-templates select="//informationsystem_group"/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="informationsystem_group">
<li>
<xsl:value-of select="name"/>
</li>
</xsl:template>
</xsl:stylesheet>
<informationsystem>
<informationsystem_group>
<name>name1</name>
<informationsystem_group>
<name>name2</name>
<informationsystem_group>
<name>name3</name>
</informationsystem_group>
</informationsystem_group>
</informationsystem_group>
<informationsystem_group>
<name>name4</name>
<informationsystem_group>
<name>name5</name>
</informationsystem_group>
<informationsystem_group>
<name>name6</name>
</informationsystem_group>
<informationsystem_group>
<name>name7</name>
</informationsystem_group>
<informationsystem_group>
<name>name8</name>
</informationsystem_group>
</informationsystem_group>
<informationsystem_group>
<name>name9</name>
<informationsystem_group>
<name>name10</name>
</informationsystem_group>
<informationsystem_group>
<name>name11</name>
</informationsystem_group>
</informationsystem_group>
</informationsystem>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" encoding="utf-8" version="1.0"/>
<xsl:template match="/informationsystem">
<xsl:if test="count(informationsystem_group) > 0">
<ul>
<xsl:apply-templates select="informationsystem_group"/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="informationsystem_group">
<li>
<xsl:value-of select="name"/>
</li>
<xsl:if test="count(informationsystem_group) > 0">
<li>
<ul>
<xsl:apply-templates select="informationsystem_group"/>
</ul>
</li>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<ul>
<li>name1</li>
<li>
<ul>
<li>name2</li>
<li>
<ul>
<li>name3</li>
</ul>
</li>
</ul>
</li>
<li>name4</li>
<li>
<ul>
<li>name5</li>
<li>name6</li>
<li>name7</li>
<li>name8</li>
</ul>
</li>
<li>name9</li>
<li>
<ul>
<li>name10</li>
<li>name11</li>
</ul>
</li>
</ul>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" version="1.0"/>
<xsl:template match="/">
<div data-attr="data-value">
<xsl:attribute name="data-attr"/>
<p>test</p>
</div>
</xsl:template>
</xsl:stylesheet>
<div data-attr=""><p>test</p></div>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" version="1.0"/>
<xsl:template match="/">
<div>
<xsl:if test="true()">
<xsl:attribute name="data-attr">value</xsl:attribute>
</xsl:if>
<p>test</p>
</div>
<div>
<xsl:if test="false()">
<xsl:attribute name="data-attr">value</xsl:attribute>
</xsl:if>
<p>test</p>
</div>
</xsl:template>
</xsl:stylesheet>
<div data-attr="value"><p>test</p></div>
<div><p>test</p></div>
<xsl:apply-templates select="property_value[tag_name='images']/file"/>
<xsl:template match="property_value[tag_name='images']/file">
<xsl:value-of select="."/>
</xsl:template>
<xsl:value-of select="property_value[tag_name='adress']/value"/>
<xsl:value-of select="property_value[tag_name='telefon']/value"/>
<ФИО Фамилия="Алексеев" Имя="Алексей" Отчество="Алексеевич"></ФИО>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings" extension-element-prefixes="str">
<xsl:template match="/">
<xsl:apply-templates select="ФИО/@Имя"/>
</xsl:template>
<xsl:template match="ФИО/@Имя">
<tr>
<xsl:for-each select="str:tokenize(string(.), '')">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
<tr><td>А</td><td>л</td><td>е</td><td>к</td><td>с</td><td>е</td><td>й</td></tr>
<meta name="description" content="{.//property[@name='proizvoditel']}" />
что не так делаю?
<root>
<foo>123&456</foo>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/root/foo">
<xsl:value-of select="translate(., '&', ' ')"/>
</xsl:template>
</xsl:stylesheet>
123 456
<documentRecipientAddressData>
<street>Centroallee 1000
Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...</street>
<street>Centroallee
1000
Einfahrt
Parkhaus 7 an der
"Alten Waltz" gegenüber Tryp Hotel ...</street>
<street>Centroallee 1000 Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...</street>
</documentRecipientAddressData>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/documentRecipientAddressData/street">
<xsl:variable name="street">
<xsl:call-template name="replace-line-breaks">
<xsl:with-param name="text">
<xsl:call-template name="normalize-line-breaks">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="normalize-space($street)"/>
<xsl:text>
</xsl:text>
<xsl:variable name="street">
<xsl:call-template name="normalize-line-breaks">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="replace($street, '\n', ', ')"/>
<xsl:text>

</xsl:text>
</xsl:template>
<xsl:template name="replace-line-breaks">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="not(contains($text, '
'))">
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before($text, '
')"/>
<xsl:text>, </xsl:text>
<xsl:call-template name="replace-line-breaks">
<xsl:with-param name="text" select="substring-after($text, '
')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="normalize-line-breaks">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="not(contains($text, '

'))">
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="text">
<xsl:value-of select="substring-before($text, '

')"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="substring-after($text, '

')"/>
</xsl:variable>
<xsl:call-template name="normalize-line-breaks">
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Centroallee 1000, Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...
Centroallee 1000, Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...
Centroallee, 1000, Einfahrt, Parkhaus 7 an der, "Alten Waltz" gegenüber Tryp Hotel ...
Centroallee, 1000, Einfahrt, Parkhaus 7 an der, "Alten Waltz" gegenüber Tryp Hotel ...
Centroallee 1000 Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...
Centroallee 1000 Einfahrt Parkhaus 7 an der "Alten Waltz" gegenüber Tryp Hotel ...
<root>
<div class="class1-s">a</div>
<div class="class1_a">b</div>
<div class=" class1+g ">b</div>
<div class="class1-s1">c</div>
<div class="class1-s134">c</div>
<div class="cls1-s134">c</div>
<div class="class1-s134">c</div>
<div c="zclass1-s1">c</div>
<div>c</div>
</root>
/root/div[starts-with(normalize-space(@class), 'class1') and string-length(normalize-space(@class)) = string-length('class1') + 2]
/root/div[matches(normalize-space(@class), '^class1..$')]