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 8604189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:30:44+00:00 2026-06-12T02:30:44+00:00

Issue: Solved, I was able to produce a script that will go through my

  • 0

Issue:
Solved, I was able to produce a script that will go through my XHTML list and produce XML output.

The question was:
What should the XSLT look like, when I have an ordered list?

Thanks @Sbof

I need to produce the following XML:

<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ul">
  <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
    <Content>abc</Content>
    <Br/>
    <Content>xyz</Content>
    <Br/>
    <Content>abc</Content>
    <Br/>
    <Content>xyzabc</Content>
    <Br/>
  </CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 1">
  <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
    <Content>xyz</Content>
    <Br/>
  </CharacterStyleRange>
</ParagraphStyleRange>
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 2">
  <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
    <Content>abc</Content>
    <Br/>
  </CharacterStyleRange>
</ParagraphStyleRange>

I have XHTML (The content is different, but does same thing) that looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
<ol>
    <li>abc</li>
    <li>xyz</li>
    <li>abc</li>
    <li>xyzabc</li>
    <li>xyz<ol>
        <li>abc</li>
        </ol>
    </li>
    <li>xyzxyz</li>
    <li>abc</li>
    <ol>
        <li>xyz</li>
    </ol>
    <li>next level</li>
</ol>
</body>
</html>

This is a snippet of XSLT to transverse the XHTML:

  <xsl:template match="xhtml:ol/xhtml:li[not(*)]">
    <xsl:call-template name="para-style-range">
      <xsl:with-param name="style-name">article%3aol Level 1</xsl:with-param>
    </xsl:call-template>
    <xsl:if test ="xhtml:ol/xhtml:li[*]|
                   xhtml:ul/xhtml:li[*]">
      <xsl:apply-templates select="xhtml:ol/xhtml:li[*]|
                                   xhtml:ul/xhtml:li[*]" />
    </xsl:if>
  </xsl:template>

This is the result I get using my script:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="7.5">
    <Story Self="ucb" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n">
        <StoryPreference OpticalMarginAlignment="false" OpticalMarginSize="12" FrameType="TextFrameType" StoryOrientation="Horizontal" StoryDirection="LeftToRightDirection"/>
        <InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false"/>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ul">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>abc</Content>
                <Br/>
                <Content>xyz</Content>
                <Br/>
                <Content>abc</Content>
                <Br/>
                <Content>xyzabc</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 1">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>xyz</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 2">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>abc</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 1">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>xyzxyz</Content>
                <Br/>
                <Content>abc</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 3">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>xyz</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
        <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/ol level 1">
            <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Character Style 1">
                <Content>next level</Content>
                <Br/>
            </CharacterStyleRange>
        </ParagraphStyleRange>
    </Story>
</idPkg:Story>

XSLT snipped to get the attribute value of paragraph:

<xsl:template name="para-style-range">
    <!-- The name of the paragraph style in InDesign -->
    <xsl:param name="style-name"/>
    <xsl:param name ="isTable" />
    <!-- A string of text that will precede the paragraph's actual content (ex: 'by ')-->
    <xsl:param name="prefix-content" select="''"/>
    <ParagraphStyleRange>
      <xsl:attribute name="AppliedParagraphStyle">
        <xsl:value-of select="concat('ParagraphStyle/', $style-name)"/>
      </xsl:attribute>
      <xsl:if test="$prefix-content != ''">
        <CharacterStyleRange>
          <Content><xsl:value-of select="$prefix-content"/></Content>
        </CharacterStyleRange>
      </xsl:if>
      <xsl:apply-templates select="text()|*" mode="character-style-range"/>
      <xsl:choose>
        <xsl:when test ="$isTable = 'true'">
          <!--Dont do any thing here-->
        </xsl:when>
        <xsl:otherwise>
          <Br/>
        </xsl:otherwise>
      </xsl:choose>

    </ParagraphStyleRange>
  </xsl:template>

Let me know if I can provide more script to help those who are still confused about the code or need help figuring it out.

  • 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-06-12T02:30:45+00:00Added an answer on June 12, 2026 at 2:30 am

    The following XSL works on your example:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
        xmlns:html="http://www.w3.org/1999/xhtml"
        exclude-result-prefixes="html">
        <xsl:template match="text()"/>
        <xsl:template match="/">
            <rootElement>
                <xsl:apply-templates/>
            </rootElement>
        </xsl:template>
        <xsl:template match="//html:ol">
            <ParagraphStyleRange>
                <xsl:attribute name="AppliedParagraphStyle">
                    <xsl:text>ParagraphStyle/ol level </xsl:text>
                    <xsl:value-of select="count(ancestor::html:ol)"/>
                </xsl:attribute>
                <xsl:apply-templates select="child::html:li"/>
            </ParagraphStyleRange>
            <xsl:apply-templates select="descendant::html:ol"/>
        </xsl:template>
    
        <xsl:template match="//html:li">
            <CharacterStyleRange>
                <xsl:attribute name="AppliedCharacterStyle">
                    <xsl:text>CharacterStyle/Character Style </xsl:text>
                    <xsl:value-of select="count(ancestor::html:li)"/>
                </xsl:attribute>
            <Content>
                <xsl:value-of select="normalize-space(text())"/>
            </Content>
            <br/>
            </CharacterStyleRange>
        </xsl:template>
    </xsl:stylesheet>
    

    The exact input I used was

    <!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
        </head>
        <body>
            <ol>
                <li>level1a</li>
                <li>level1b
                    <ol>
                        <li>level2a</li>
                        <li>level2b</li>
                        <li>level2c
                            <ol>
                                <li>level3a</li>
                            </ol>
                        </li>
                    </ol>
                </li>
            </ol>
        </body>
    </html>
    

    You might need to adapt this to your exact need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue is SOLVED: Problem is that it is a pre-compiled web page project and
Edit 4/4/12 I STILL HAVE ONE QUESTION: I solved my issue but it adds
I've got an issue that was wondering if could be solved in a particular
UPDATE: SOLVED I've discovered the issue. Using the .libPaths() function, I was able to
UPDATE The issue is solved, all the code you can see works. Hello! I
Fairly simple issue which is solved in PHP by using a static variable. private
I am developing an app using jquery mobile and last issue to be solved
I already have this issue but I cannot remember how to solved it. (I
I've read every post about this issue, but nothing solved the problem. I'll be
On Monday, I thought I had solved the session hijacking security issue by setting

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.