I am trying to create a grid indicated as follows:
<Node>
<UI>Grid</UI>
<Rows>3</Rows>
<Cols>3</Cols>
<Node>stuff</Node>
<Node>stuff</Node>
<Node>stuff</Node>
...
</Node>
I want to use Bootstrap, so I have
<xsl:template match ="Node[UI[contains(., 'Grid')]]">
<div class ="container-fluid">
<xsl:apply-templates select="Node" mode="Grid"/>
</div>
</xsl:template>
And then:
<xsl:template match ="=Node" mode="Grid">
<div class ="col-lg-???">
<xsl:apply-templates />
</div>
</xsl:template>
In the last part, col-lg - ??? must somehow use the node position as a child inside the node mesh to calculate the required tag so that the mesh is correctly created. In the end, the <3.3> grid will have 9 nodes, and I want to automatically arrange them as follows:

Just using their position inside the grid node. I know that I will also need to consider rowing inside the container, but I'm not sure about that. Colsusually displayed on Cols = Children/Rows.
The output should look something like this:
<div class = "container">
<div class ="row">
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
</div>
<div class ="row">
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
</div>
<div class ="row">
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
<div class = "col-lg-4" ></div>
</div>
</div>
EDIT:
This seems to be done if it is a single line:
<div class ="col-lg-{12 div count(../Node)}">
<xsl:apply-templates />
</div>
But not sure about the string part.
EDIT2:
:
<xsl:template match ="//Sub/Node">
<xsl:if test="count(./preceding-sibling::*) mod (count(../Node) div ../../Rows/text()) = 0">
<div class ="row"></div>
</xsl:if>
<div class ="col-lg-{12 div count(../Node)}">
<xsl:apply-templates />
</div>
<xsl:if test="count(./preceding-sibling::*) mod (count(../Node) div ../../Rows/text()) = 1">
<div class ="rowclose"></div>
</xsl:if>
</xsl:template>
rowclose , , div if- , . . :
<div class="container-fluid">
<div class="row"></div>
<div class="col-lg-3"></div>
<div class="col-lg-3"></div>
<div class="rowclose"></div>
<div class="row"></div>
<div class="col-lg-3"></div>
<div class="col-lg-3"></div>
<div class="rowclose"></div>
</div>