1

Topic: It is impossible to take value from a parent node in a cycle (xslt)

To all kind time of days, I ask to help, if it is possible, to solve a problem on conversion. Real initial XML very bulky, on it I will describe the task on a simple example. In an example there are some elements "catalog" in which there are some child members "cd" which in turn as have child members. But flush with "cd" there is a field "flow".
The task in what to sort out all elements "cd" to take therefrom the necessary fields but as in each step of a cycle still to get an element "flow" the appropriate directory ("catalog"). Here an example initial XML:

<? xml version = "1.0" encoding = "UTF-8"?>
<root>
<catalog>
<cd>
<title> Empire Burlesque </title>
<artist> Bob Dylan </artist>
<country> USA </country>
<company> Columbia </company>
<price> 10.90 </price>
<year> 1985 </year>
</cd>
<cd>
<title> Hide your heart </title>
<artist> Bonnie Tyler </artist>
<country> UK </country>
<company> CBS Records </company>
<price> 9.90 </price>
<year> 1988 </year>
</cd>
<cd>
<title> Greatest Hits </title>
<artist> Dolly Parton </artist>
<country> USA </country>
<company> RCA </company>
<price> 9.90 </price>
<year> 1982 </year>
</cd>
<flow> 1 </flow>
</catalog>
<catalog>
<cd>
<title> Empire Burlesque </title>
<artist> Bob Dylan </artist>
<country> USA </country>
<company> Columbia </company>
<price> 10.90 </price>
<year> 1985 </year>
</cd>
<cd>
<title> Hide your heart </title>
<artist> Bonnie Tyler </artist>
<country> UK </country>
<company> CBS Records </company>
<price> 9.90 </price>
<year> 1988 </year>
</cd>
<cd>
<title> Greatest Hits 2 </title>
<artist> Dolly Parton </artist>
<country> USA </country>
<company> RCA </company>
<price> 9.90 </price>
<year> 19822222 </year>
</cd>
<flow> 2 </flow>
</catalog>
</root>

Here example XSLT which to fulfill conversion and issues in a label

<? xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<table border = "1">
<tr bgcolor = "#9acd32">
<th> Title </th>
<th> Artist </th>
<th> flow </th>
</tr>
<xsl:for-each select = "root/catalog">
<xsl:for-each select = "cd">
<tr>
<td> <xsl:value-of select = "title"/> </td>
<td> <xsl:value-of select = "artist"/> </td>
<td> <xsl:value-of select = "//flow"> </td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Here such table as a result turns out, but it is necessary for me, when the line is formed, in a column flow there was a value from an appropriate parent element catalog. Value flow it not simply ordinal value of an element, here can be the arbitrary value.
[img=https://s8.hostingkartinok.com/uploads/images/2017/10/c17f10e4fbc202ece255a262ad79ec36.png]
I apologize that likely very clumsily stated the task, but I hope clearly that is required. Some days already thought as to make, looked examples but and it did not turn out to achieve result. In advance I thank for the help.

2

Re: It is impossible to take value from a parent node in a cycle (xslt)

<td> <xsl:value-of select = "./flow"/> </td>

Or

<xsl:value-of select = "parent:: catalog/flow"/>

3

Re: It is impossible to take value from a parent node in a cycle (xslt)

Very Pavlovny dream;
Thanks big! As all was simple.

4

Re: It is impossible to take value from a parent node in a cycle (xslt)

lucky7;

//flow

to get an element flow at any nesting level, considering from a document root. One of most  operations

.//flow

to get an element flow at any nesting level, considering from a current element