1

In short, sibling divs coded in my custom ItemStyle for use with a CQWP are being nested into each other.

Stripped down to the essential structure I have

<xsl:template name="AssetDocumentSubProcessDetails" match="Row[@Style='AssetDocumentSubProcessDetails']" mode="itemstyle">

    <div class="assetDocumentProcess">
        <div class="row1"></div>
        <div class="row2">
            <div class="col1"></div>
            <div class="col2"></div>
        </div>
    </div> 

</xsl:template>

In use, this is rendering out like this

    <div class="assetDocumentProcess">
        <div class="row1">
            <div class="row2">
                <div class="col1">
                    <div class="col2">
                    </div>
                </div>
            </div>
        </div>
    </div>

And I'm dumbfounded. Why is SharePoint doing this?

2

This makes no sense to me but...

It appears that SharePoint XSLT for CQWP doesn't like empty elements. When I have an empty div it pulls the next element in the DOM into the parent of the empty element. My code had clearing divs at the end of the main containers so getting rid of those resolved the issue.

2
  • That's right, i've experienced the same issue in the past and it was also related with empty elements. Aug 22 '14 at 11:02
  • OK but then how to fix it? I have a div that remains empty because it's only meant to display an image. I tried to put an arbitrary &nbsp; just to put content but it's not rendered right. What's the solution? Oct 10 '18 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.