Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4343150
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:42:41+00:00 2026-05-21T11:42:41+00:00

I’m grouping bulleted items and embedding them as a second list of bulleted items

  • 0

I’m grouping bulleted items and embedding them as a second list of bulleted items inside some list elements. I can get the items to group, but my recursion template is selecting everything from my current position in the doc to the end. I need to set an ending point for my nested lists.

My output looks like this:

<ul>
    <li>First Bullet:<ul>
         <li>Sub-bullet 1: info for sub-bullet
                                            1</li>
         <li>Sub-bullet 2: info for sub-bullet
                                            2</li>
         <li>Sub-bullet 3: info for sub-bullet
                                            3</li>
         <li>Sub-bullet 4: info for sub-bullet
                                                4</li>
         <li>Sub-bullet 5: info for sub-bullet
                                            5</li>
         <li>Sub-bullet 6: info for sub-bullet
                                            6</li>
        </ul>
    </li>

    <li>Second Bullet:<ul>
         <li>Sub-bullet 5: info for sub-bullet
                                            5</li>
         <li>Sub-bullet 6: info for sub-bullet
                                            6</li>
        </ul>
    </li>
</ul>

But it SHOULD look like this (without Sub-bullets 5 and 6 under the first li):

<ul>
    <li>First Bullet:<ul>
         <li>Sub-bullet 1: info for sub-bullet
                                            1</li>
         <li>Sub-bullet 2: info for sub-bullet
                                            2</li>
         <li>Sub-bullet 3: info for sub-bullet
                                            3</li>
         <li>Sub-bullet 4: info for sub-bullet
                                                4</li>
        </ul>
    </li>

    <li>Second Bullet:<ul>
         <li>Sub-bullet 5: info for sub-bullet
                                            5</li>
         <li>Sub-bullet 6: info for sub-bullet
                                            6</li>
        </ul>
    </li>
</ul>

I’m not sure how to properly group the sub-bullets in XSLT to get them in the correct position.

Here’s my source:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<office:document-content xmlns:dom="http://www.w3.org/2001/xml-events"
  xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
  xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0">
  <office:body>
    <office:presentation>
      <draw:page draw:name="Slide1" draw:style-name="a1271"
        draw:master-page-name="Master1-Layout3-cust-Bullet"
        presentation:presentation-page-layout-name="Master1-PPL3">
        <draw:frame draw:id="id109" presentation:style-name="a1039"
                    draw:name="Content Placeholder 1" svg:x="0.31258in" svg:y="1.29095in"
                    svg:width="9.33243in" svg:height="3.8175in" presentation:class="outline"
                    presentation:placeholder="false">
                    <draw:text-box>
                        <text:list text:style-name="a1012">
                            <text:list-item>
                                <text:p text:style-name="a1011" text:class-names=""
                                    text:cond-style-name=""><text:span text:style-name="a1010"
                                        text:class-names="">First Bullet:</text:span></text:p>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1015">
                            <text:list-item>
                                <text:list text:style-name="a1015">
                                    <text:list-item>
                                        <text:p text:style-name="a1014" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1013" text:class-names=""
                                                >Sub-bullet 1: info for sub-bullet
                                            1</text:span></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1018">
                            <text:list-item>
                                <text:list text:style-name="a1018">
                                    <text:list-item>
                                        <text:p text:style-name="a1017" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1016" text:class-names=""
                                                >Sub-bullet 2: info for sub-bullet
                                            2</text:span></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1021">
                            <text:list-item>
                                <text:list text:style-name="a1021">
                                    <text:list-item>
                                        <text:p text:style-name="a1020" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1019" text:class-names=""
                                                >Sub-bullet 3: info for sub-bullet
                                            3</text:span></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1025">
                            <text:list-item>
                                <text:list text:style-name="a1025">
                                    <text:list-item>
                                        <text:p text:style-name="a1024" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1022" text:class-names=""
                                                >Sub-bullet 4: info for sub-bullet
                                                4</text:span><text:span text:style-name="a1023"
                                                text:class-names=""/></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1029">
                            <text:list-item>
                                <text:p text:style-name="a1028" text:class-names=""
                                    text:cond-style-name=""><text:span text:style-name="a1026"
                                        text:class-names="">Second Bullet:</text:span><text:span
                                        text:style-name="a1027" text:class-names=""/></text:p>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1032">
                            <text:list-item>
                                <text:list text:style-name="a1032">
                                    <text:list-item>
                                        <text:p text:style-name="a1031" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1030" text:class-names=""
                                                >Sub-bullet 5: info for sub-bullet
                                            5</text:span></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                        <text:list text:style-name="a1035">
                            <text:list-item>
                                <text:list text:style-name="a1035">
                                    <text:list-item>
                                        <text:p text:style-name="a1034" text:class-names=""
                                            text:cond-style-name=""><text:span
                                                text:style-name="a1033" text:class-names=""
                                                >Sub-bullet 6: info for sub-bullet
                                            6</text:span></text:p>
                                    </text:list-item>
                                </text:list>
                            </text:list-item>
                        </text:list>
                    </draw:text-box>
                    <svg:desc/>
                </draw:frame>
      </draw:page>
    </office:presentation>
  </office:body>
</office:document-content>

Here’s my stylesheet:

<xsl:stylesheet
    version="2.0"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
    xmlns:math="http://www.w3.org/1998/Math/MathML"
    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
    xmlns:dom="http://www.w3.org/2001/xml-events"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
    office:class="text"
    office:version="1.0"
    exclude-result-prefixes="#all">
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="draw:frame">
<ul>
 <xsl:for-each-group select="draw:text-box/text:list" group-starting-with="text:list-item">
  <xsl:for-each select="current-group()">

        <xsl:apply-templates select="text:list-item[not(text:list)]"/>

    </xsl:for-each>
</xsl:for-each-group> 
</ul>
</xsl:template>

<xsl:template match="draw:text-box/text:list/text:list-item/text:list/text:list-item/text:p">
<li><xsl:value-of select="."/></li>
</xsl:template>


<xsl:template match="draw:text-box/text:list/text:list-item/text:p">
<li><xsl:value-of select="."/>
    <!-- Check for nested list -->
    <xsl:if test="../../following-sibling::text:list[text:list-item/text:list]">

            <xsl:for-each select="current-group()">
            <xsl:apply-templates select="text:list-item/text:p"/>
            </xsl:for-each>

            </xsl:for-each-group>
    </ul>
    </xsl:if>
</li>
</xsl:template>


</xsl:stylesheet>

Any suggestions on how to accomplish this in 2.0? I’ve attempted to create some count variables, but haven’t had any luck yet on establishing an endpoint outside of the current-group context. I know there must be an obvious (and more elegant) way to get this done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:42:42+00:00Added an answer on May 21, 2026 at 11:42 am

    There is a short, simple and easy solution that doesn’t require XSLT 2.0 at all:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
     exclude-result-prefixes="text"
     >
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="text:list">
      <ul><xsl:apply-templates/></ul>
     </xsl:template>
    
     <xsl:template match="text:list-item[not(text:list)]">
      <li><xsl:apply-templates/></li>
     </xsl:template>
    
     <xsl:template match=
      "text()[not(ancestor::text:list-item)]"/>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <office:document-content xmlns:dom="http://www.w3.org/2001/xml-events"
    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
    xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"   xmlns:xlink="http://www.w3.org/1999/xlink"   xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0">
        <office:body>
            <office:presentation>
                <draw:page draw:name="Slide1" draw:style-name="a1271"         draw:master-page-name="Master1-Layout3-cust-Bullet"         presentation:presentation-page-layout-name="Master1-PPL3">
                    <draw:frame draw:id="id109" presentation:style-name="a1039"                     draw:name="Content Placeholder 1" svg:x="0.31258in" svg:y="1.29095in"                     svg:width="9.33243in" svg:height="3.8175in" presentation:class="outline"                     presentation:placeholder="false">
                        <draw:text-box>
                            <text:list text:style-name="a1012">
                                <text:list-item>
                                    <text:p text:style-name="a1011" text:class-names=""                                     text:cond-style-name="">
                                        <text:span text:style-name="a1010"                                         text:class-names="">First Bullet:</text:span>
                                    </text:p>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1015">
                                <text:list-item>
                                    <text:list text:style-name="a1015">
                                        <text:list-item>
                                            <text:p text:style-name="a1014" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1013" text:class-names=""                                                 >Sub-bullet 1: info for sub-bullet                                             1</text:span>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1018">
                                <text:list-item>
                                    <text:list text:style-name="a1018">
                                        <text:list-item>
                                            <text:p text:style-name="a1017" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1016" text:class-names=""                                                 >Sub-bullet 2: info for sub-bullet                                             2</text:span>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1021">
                                <text:list-item>
                                    <text:list text:style-name="a1021">
                                        <text:list-item>
                                            <text:p text:style-name="a1020" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1019" text:class-names=""                                                 >Sub-bullet 3: info for sub-bullet                                             3</text:span>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1025">
                                <text:list-item>
                                    <text:list text:style-name="a1025">
                                        <text:list-item>
                                            <text:p text:style-name="a1024" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1022" text:class-names=""                                                 >Sub-bullet 4: info for sub-bullet                                                 4</text:span>
                                                <text:span text:style-name="a1023"                                                 text:class-names=""/>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1029">
                                <text:list-item>
                                    <text:p text:style-name="a1028" text:class-names=""                                     text:cond-style-name="">
                                        <text:span text:style-name="a1026"                                         text:class-names="">Second Bullet:</text:span>
                                        <text:span                                         text:style-name="a1027" text:class-names=""/>
                                    </text:p>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1032">
                                <text:list-item>
                                    <text:list text:style-name="a1032">
                                        <text:list-item>
                                            <text:p text:style-name="a1031" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1030" text:class-names=""                                                 >Sub-bullet 5: info for sub-bullet                                             5</text:span>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                            <text:list text:style-name="a1035">
                                <text:list-item>
                                    <text:list text:style-name="a1035">
                                        <text:list-item>
                                            <text:p text:style-name="a1034" text:class-names=""                                             text:cond-style-name="">
                                                <text:span                                                 text:style-name="a1033" text:class-names=""                                                 >Sub-bullet 6: info for sub-bullet                                             6</text:span>
                                            </text:p>
                                        </text:list-item>
                                    </text:list>
                                </text:list-item>
                            </text:list>
                        </draw:text-box>
                        <svg:desc/>
                    </draw:frame>
                </draw:page>
            </office:presentation>
        </office:body>
    </office:document-content>
    

    the wanted, correct result is produced:

    <ul>
       <li>First Bullet:</li>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 1: info for sub-bullet                                             1</li>
       </ul>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 2: info for sub-bullet                                             2</li>
       </ul>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 3: info for sub-bullet                                             3</li>
       </ul>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 4: info for sub-bullet                                                 4</li>
       </ul>
    </ul>
    <ul>
       <li>Second Bullet:</li>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 5: info for sub-bullet                                             5</li>
       </ul>
    </ul>
    <ul>
       <ul>
          <li>Sub-bullet 6: info for sub-bullet                                             6</li>
       </ul>
    </ul>
    

    and the browser displays this as:

    • First Bullet:
    • Sub-bullet 1: info for sub-bullet 1
    • Sub-bullet 2: info for sub-bullet 2
    • Sub-bullet 3: info for sub-bullet 3
    • Sub-bullet 4: info for sub-bullet 4
    • Second Bullet:
    • Sub-bullet 5: info for sub-bullet 5
    • Sub-bullet 6: info for sub-bullet 6
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.