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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:24:28+00:00 2026-06-14T10:24:28+00:00

I had to add an href attribute to the following xml but not every

  • 0

I had to add an href attribute to the following xml but not every subprocess will have one.

<?xml version="1.0"?>
<processes>
    <process nr="1" name="Process1" >
        <subprocess nr="1" name="Subprocess1" href="some/relative/link.html"></subprocess>
        <subprocess nr="2" name="Subprocess2" href="#"></subprocess>
        <subprocess nr="3" name="Subprocess3"></subprocess>
    </process>
</processes>

What do I need to change in my original XSL to produce the below HTML output?
How do I deal with the different href attribute values?

XSL:

<xsl:template name="subprocess">
<xsl:call-template name="linking"/>
</xsl:template>
 <xsl:template name="linking">
 <xsl:variable name="processNo" select="@nr"/>   
 <ul class="myframe">
  <xsl:for-each select="subprocess">
    <li>
      <a class="myButton" href="p{$processNo}s{@nr}.html">
        <xsl:value-of select="@nr"/>
        <br/>
        <xsl:value-of select="@name"/>
      </a>
    </li>
  </xsl:for-each>
</ul>
</xsl:template>

HTML:

<ul class="myframe">
    <li><a class="linkButton" href="some/relative/link.html">Subprocess1</a></li>
    <li><a class="noLink" href="#">Subprocess2</a></li>
    <li><a class="myButton" href="p1s3.html">Subprocess3</a></li>
</ul>

So, depending on the href attribute I want to assign different CSS classes too.

Thanks for your help.

  • 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-14T10:24:29+00:00Added an answer on June 14, 2026 at 10:24 am

    Use xsl:choose and xsl:attribute:

    <xsl:template name="linking">
        <xsl:variable name="processNo" select="@nr"/>
        <ul class="myframe">
            <xsl:for-each select="subprocess">
                <li>
                    <a>
                        <xsl:choose>
                            <xsl:when test="@href eq '#'">
                                <xsl:attribute name="class" select="'noLink'"/>
                            </xsl:when>
                            <xsl:when test="not(@href)">
                                <xsl:attribute name="class" select="'myButton'"/>
                                <xsl:attribute name="href"
                                    select="concat('p',$processNo,'s',@nr,'.html')"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:sequence select="@href"/>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:value-of select="name()"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had to maunally add some html within the sidebar div of html, but
I had only one function to Add another row to the table id=tblOtherParties and
Had a good read through similar topics but I can't quite a) find one
I originally had a submit button. <input class=submit type=submit class=input value=Add name=command /> but
First of all, I have never written a property editor from scratch, but had
There have been several SO solutions to this, but I haven't had any luck
I managed my original problem i had to add the break; but now the
I had to add <prefer-web-inf-classes>true</prefer-web-inf-classes> to weblogic.xml to resolve a Hibernate antr compatibility issue
I have a table and I had to add a migration script to add
I want to add one office document to another. Until now I had to

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.