0
votes

I have a CMS that runs off XSLT components. I'm trying to create a wrapper component that contains a list of any number of unknown child components. I want to know how I can loop through and display each child component. I have an XSL template for the wrapper component and a template for each child component that is allowed to be added to the wrapper. So far I've done...

<xsl:template match="MainContentWrapper">
    <div class="wrapper-component" style="background-color:{BackgroundColor}; background-image:url('{$imagespath}/{BackgroundImage}')">
        <div class="container">
            <xsl:if test="Header != ''">
                <div class="row">
                    <div class="col-xs-12">
                        <h3 class="wrapper-header"><xsl:value-of select="Header" disable-output-escaping="yes" /></h3>
                    </div>
                </div>
            </xsl:if>

            <div class="row">
                <xsl:for-each select="*[@Name='Item']">
                    <xsl:apply-templates />
                </xsl:for-each>
            </div>
        </div>
    </div>
</xsl:template>

And then my child components all have their own "xsl:template match" template set up for them. I just want an author to be able to create a wrapper component then throw as many components inside that wrapper of any kind, and not a set named component. Am I making sense? Haha. Thanks!

1
"Am I making sense?" Not to me. Why don' you post a small example of an XML input and the expected output? - michael.hor257k

1 Answers

0
votes

Use the node, local-name and name functions to address arbitrary elements:

<!--Match any non-namespaced node-->
<xsl:template match="//node()[local-name() = name()]">
  <xsl:apply-templates/>
</xsl:template>

References