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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:35:15+00:00 2026-05-27T05:35:15+00:00

I built an XML workflow to create a rich HTML document with automatic hyperlinks

  • 0

I built an XML workflow to create a rich HTML document with automatic hyperlinks and anchors using unique ids. But I need to add unique anchors to an existing element that are untagged. I don’t want to go through the hundreds of elements to tag the content, so I am wondering if there is a way to pull out the letter starting a paragraph and then append it to a section number to create the unique ID anchor attribute.
The XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<RULES>
<RULE>
<RULE_SECTION>
<RULE_subhead><num>3-3</num>. DOUBT AS TO PROCEDURE </RULE_subhead>
<rule_letterhead>a. Procedure </rule_letterhead>
<rule_letterhead-B>b. Determination of Score for Hole </rule_letterhead-B>
</RULE_SECTION>
<RULE_SECTION>
<RULE_subhead><num>4-1</num>. FORM AND MAKE OF CLUBS </RULE_subhead>
<rule_letterhead>a. General </rule_letterhead>
<rule_letterhead-B>b. Wear and Alteration </rule_letterhead-B>
<rule_letterhead-B>c. Damage in Normal Course of Play </rule_letterhead-B>
</RULE_SECTION>
</RULE>
</RULES>

Note how the two <rule_letterhead> and <rule_letterhead-B> elements start with an initial letter and period (a. b. c., etc). I’d like to build HTML to look like this:

<body>
<h2 class="RULE_subhead" id="r3-3">3-3. DOUBT AS TO PROCEDURE </h2>
<h3 class="rule_letterhead" id="r3-3a">a. Procedure </h3>
<h3 class="rule_letterhead" id="r3-3b">b. Determination of Score for Hole </h3>
<h2 class="RULE_subhead" id="r4-1">4-1. FORM AND MAKE OF CLUBS </h2>
<h3 class="rule_letterhead" id="r4-1a">a. General </h3>
<h3 class="rule_letterhead" id="r4-1b">b. Wear and Alteration </h3>
<h3 class="rule_letterhead" id="r4-1c">c. Damage in Normal Course of Play </h3>
</body>

So, the XSL has to pull the Section number and append it to the first letter of the elements <letterhead> or <letterhead-B> like this “4-1a”.

Here is the XSL I am currently using:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Document</title>
</head>
<body>
<xsl:apply-templates select="RULES"/>
</body>
</html>

</xsl:template>

<xsl:template match="RULE_subhead">
<h2 class="RULE_subhead" id="{concat('r',translate(normalize-space(num), ' ', ''))}">
  <xsl:apply-templates/></h2>
</xsl:template>

<xsl:template match="rule_letterhead">
<h3 class="rule_letterhead"><xsl:apply-templates/></h3>
</xsl:template>

<xsl:template match="rule_letterhead-B">
<h3 class="rule_letterhead"><xsl:apply-templates/></h3>
</xsl:template>
</xsl:stylesheet>

It is working for all the other elements.

Thanks

  • 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-27T05:35:16+00:00Added an answer on May 27, 2026 at 5:35 am
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns="http://www.w3.org/1999/xhtml">
      <xsl:output method="html" encoding="UTF-8" 
                  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
                  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
    
      <xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>Untitled Document</title>
          </head>
          <body>
            <xsl:apply-templates select="RULES"/>
          </body>
        </html>
      </xsl:template>
    
      <xsl:template match="RULE_subhead">
        <h2 class="RULE_subhead" 
            id="{concat('r',translate(normalize-space(num), ' ', ''))}">
        <xsl:apply-templates/>
        </h2>
      </xsl:template>
    
      <xsl:template match="rule_letterhead|rule_letterhead-B">
        <h3 class="rule_letterhead"
            id="{concat('r',translate(normalize-space(preceding-sibling::RULE_subhead/num), ' ', ''), 
                substring(., 1, 1))}">
          <xsl:apply-templates/>
        </h3>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Java's built in XML transformer to take a DOM document and print
I'm using the built-in Java XML Transformer to serialize an XML document into text.
I built a template-based document generator using the Open XML SDK (1.0) , the
I am using eval to create an associative array from php built in xml
I need to convert XML built with dom4j to a w3c document and don't
I have a tree in flex built from an XML document into an XMLlist
There are so many html and xml libraries built into python , that it's
I have built an XML-RPC interface in Python and I need to enforce some
I'm using JSoup in an attempt to built valid XML from a couple of
Im using Python's built in XML parser to load a 1.5 gig XML file

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.