Tables within OL and UL elements | Community
Skip to main content
brandon_maynard
September 14, 2021

Tables within OL and UL elements

  • September 14, 2021
  • 0 replies
  • 799 views

I am trying to wrap any <table> elements within an <ol> or <ul> element with an <li> element. I am not having much success. I tried to copy the OOTB template and apply it to my h2d_extended.xsl, but I am not seeing my results. Here is my code from my h2d_extended.xsl file. Any help would be appreciated. For context, I am not seeing the wrapping <li> or the added <p>hello world</p>.

 

AEM Instance:
AEM 6.5 + SP7 + SP8 + XML Add On v3.8

 

 

<!-- Table inside of ol or ul --> <xsl:template match="ol/table|ul/table" mode="convert-to-cals" priority="9"> <xsl:variable name="num-cols"> <xsl:choose> <xsl:when test=".//col"> <!-- take col definitions --> <xsl:value-of select="count(.//col[not(@colspan)]) + sum(.//col/@colspan)"/> </xsl:when> <xsl:when test="./thead"> <!-- take first row of table header --> <xsl:value-of select="count(./thead/tr[1]/th[not(@colspan)]) + sum(./thead/tr[1]/th/@colspan)"/> </xsl:when> <xsl:when test="not(./thead) and ./tbody"> <!-- take first row of table body --> <xsl:value-of select="count(./tbody/tr[1]/td[not(@colspan)]) + sum(./tbody/tr[1]/td/@colspan)"/> </xsl:when> <xsl:otherwise> <xsl:message>unable to determine column number</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="width"> <xsl:if test="@width"> <xsl:value-of select="substring-before(@width,'%')"/> </xsl:if> </xsl:variable> <xsl:variable name="cols-in-first-row"> <xsl:choose> <xsl:when test="tbody/tr"> <xsl:apply-templates select="(tbody[1]/tr[1]/td[1]|tbody[1]/tr[1]/th[1])[1]" mode="count-cols"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="(tr[1]/td[1]|tr[1]/th[1])[1]" mode="count-cols"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <li> <p>hello world</p> <table> <xsl:call-template name="compute-table-borders"/> <xsl:call-template name="compute-rowsep-colsep-defaults"/> <xsl:apply-templates select="@class|@data-conditional"/> <!--xsl:if test="@align"><xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute></xsl:if--> <xsl:choose> <xsl:when test="number($width) &lt; 100"> <xsl:attribute name="pgwide">0</xsl:attribute> </xsl:when> <xsl:when test="string-length($width)"> <xsl:attribute name="pgwide">1</xsl:attribute> </xsl:when> </xsl:choose> <xsl:choose> <xsl:when test="@rules='none' and ='0'"> <xsl:attribute name="frame">none</xsl:attribute> <xsl:attribute name="rowsep">0</xsl:attribute> <xsl:attribute name="colsep">0</xsl:attribute> </xsl:when> <xsl:when test="@border='0'"> <xsl:attribute name="rowsep">0</xsl:attribute> <xsl:attribute name="colsep">0</xsl:attribute> </xsl:when> <xsl:when test="@rules='cols'"> <xsl:attribute name="rowsep">0</xsl:attribute> </xsl:when> <xsl:when test="@rules='rows'"> <xsl:attribute name="colsep">0</xsl:attribute> </xsl:when> </xsl:choose> <xsl:choose> <xsl:when test="@frame='void'"> <xsl:attribute name="frame">none</xsl:attribute> </xsl:when> <xsl:when test="@frame='above'"> <xsl:attribute name="frame">top</xsl:attribute> </xsl:when> <xsl:when test="@frame='below'"> <xsl:attribute name="frame">bottom</xsl:attribute> </xsl:when> <xsl:when test="@frame='border'"> <xsl:attribute name="frame">all</xsl:attribute> </xsl:when> <xsl:when test="@frame='box'"> <xsl:attribute name="frame">all</xsl:attribute> </xsl:when> <xsl:when test="@frame='hsides'"> <xsl:attribute name="frame">topbot</xsl:attribute> </xsl:when> <xsl:when test="@frame='lhs'"> <xsl:attribute name="frame">sides</xsl:attribute> </xsl:when> <xsl:when test="@frame='rhs'"> <xsl:attribute name="frame">sides</xsl:attribute> </xsl:when> <xsl:when test="@frame='vsides'"> <xsl:attribute name="frame">sides</xsl:attribute> </xsl:when> </xsl:choose> <xsl:apply-templates select="caption"/> <tgroup colsep="1"> <xsl:attribute name="cols"> <xsl:value-of select="$cols-in-first-row"/> </xsl:attribute> <xsl:call-template name="create-colspec"> <xsl:with-param name="total-cols"> <xsl:value-of select="$num-cols"/> </xsl:with-param> </xsl:call-template> <xsl:choose> <xsl:when test="thead"> <thead> <xsl:if test="thead/@class"> <xsl:attribute name="outputclass"> <xsl:value-of select="thead/@class"/> </xsl:attribute> </xsl:if> <xsl:apply-templates select="thead/tr" mode="convert-to-cals"/> </thead> </xsl:when> <xsl:when test="tr[th and not(td)]"> <thead> <xsl:if test="thead/@class"> <xsl:attribute name="outputclass"> <xsl:value-of select="thead/@class"/> </xsl:attribute> </xsl:if> <xsl:apply-templates select="tr[th and not(td)]" mode="convert-to-cals"> <!--ideally, do for-each only for rows that contain TH, and place within THEAD; then open up the TBODY for the rest of the rows --> <!-- unforch, all the data will go into one place for now --> </xsl:apply-templates> </thead> </xsl:when> </xsl:choose> <tbody> <xsl:if test="tbody/@class"> <xsl:attribute name="outputclass"> <xsl:value-of select="tbody/@class"/> </xsl:attribute> </xsl:if> <xsl:apply-templates select="tbody/tr[td]|tr[td]" mode="convert-to-cals"/> </tbody> </tgroup> </table> </li> </xsl:template>

 

 

Thanks for reading

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.