Garmaine Staff asked 2 years ago

I got the next code in XML

<container>
    <id>6</id>
    <title>Producto</title>
    <body>Descripción del producto</body>
    <price>300.0</price>
    <stock>0</stock>
    <images>
        <image>images/products/product.svg</image>
    </images>
</container>

I need to convert this XML in this HTML:

<!-- Central section -->
<div class="title">
    <h1>Title</h1>
</div>
<section class="central-margin">
    <div class="container central-content">

        <!-- Carousel images -->
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img class="d-block w-100" src="image-1" alt="First slide">
                </div>
                <div class="carousel-item">
                    <img class="d-block w-100" src="image-2" alt="First slide">
                </div>
                <div class="carousel-item">
                    <img class="d-block w-100" src="image-3" alt="First slide">
                </div>
            </div>
        </div>

        <!-- Product info -->
        <div class="product-content">
            <div class="description">
                Description
            </div>
        <div class="data">
            <form action="">
                <label>Precio:<span class="float-right">300 €</span></label><br>
                <label>Stock:<span class="float-right">0</span></label><br>
                <input type="text" name="id" value="6" hidden>
                <input type="submit" class="btn btn-primary w-100" value="Comprar">
            </form>
        </div>
    </div>
</section>

I try to do it with multiples XSL files. I dont understand how to create this two parts (the div for title, section for content) with only one XSL File. My second problem is that I dont know exactly how "xsl:for-each" and "xsl:template match=''" works. If someone can help me with a simple example with be nice.

Sorry if i wrote something wrong, im from spain and I dont know much english.

Thanx for the help.