<?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
<div>
<p>par</p>
<strong>strong</strong>
<divd>
<p>divpar</p>
</divd>
<blockquote>
<p>bqpar <strong>bqparstrong</strong></p>
</blockquote>
</div>
//p[name(ancestor::blockquote[1]) != 'blockquote']|//strong[name(ancestor::blockquote[1]) != 'blockquote']|//blockquote
Element='<p>par</p>'
Element='<strong>strong</strong>'
Element='<p>divpar</p>'
Element='<blockquote><p>bqpar <strong>bqparstrong</strong></p></blockquote>'
p/code[normalize-space(preceding-sibling::text()[1]) = 'рездел1:']/text()
p/strong[normalize-space(preceding-sibling::text()[1]) = 'рездел2:']/text()
<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>
<tr>
<td class="rborder" align="center">1234</td>
<td class="rborder" align="center">
Клубника
</td>
</tr>
/tr/td[contains(., '1234')]/following-sibling::td/normalize-space(text())
String='Клубника'
<meta name="description" content="{.//property[@name='proizvoditel']}" />
<root>
<elem attr="a">a</elem>
<elem attr="b">b</elem>
<elem attr="c">c</elem>
</root>
/root
<root>
<elem attr="a">a</elem>
<elem attr="b">b</elem>
<elem attr="c">c</elem>
</root>
/root/*[@attr != 'b']
<elem attr="a">a</elem>
<elem attr="c">c</elem>