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

  • Home
  • SEARCH
  • 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 7788667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:04:03+00:00 2026-06-01T21:04:03+00:00

I have a table that is populated from a SQL database. Most of the

  • 0

I have a table that is populated from a SQL database. Most of the data entered will have an ABN which I can use to look up email and name. Some data doesn’t have an ABN, and only has a UID. I don’t want to have to display the UID in the table since its unnecessary 98% of the time, so I want to use an xsl:when to change the name field to the UID if there isn’t a name.

Here is an example of the 2 cases in XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <CourseData>
      <row batchid="0" courseid="10101" createdon="04/03/2012 01:08PM" datecompleted="1:08 PM" datecompletedDateValue="1333483680000" lastupdatebyabn="999999" lastupdatebyuid="tsmith" lastupdateon="04/03/2012 01:08PM" num="2" respondentabn="999999" respondentemail="tsmith@test.com" respondentid="1" respondentname="Thomas Smith" respondentuid="tsmith"/>       
      <row batchid="0" courseid="10101" createdon="04/03/2012 01:08PM" datecompleted="1:08 PM" datecompletedDateValue="1333483697000" lastupdatebyabn="" lastupdatebyuid="jsmith" lastupdateon="04/03/2012 01:08PM" num="3" respondentabn="" respondentemail="" respondentid="2" respondentname=" " respondentuid="jsmith"/>
    </CourseData>

Here is the XSL I’m using, which obviously isn’t working.

    <xsl:choose>
      <xsl:when test="row[@respondentabn='']">
        <label datafield="@respondentuid"></label>
      </xsl:when>
      <xsl:otherwise>
        <label datafield="@respondentname"></label>
      </xsl:otherwise></xsl:choose></td>

How can I fix this?

Edit: So after talking to my boss, he said for one I’d need an loop in there for this to work right, but that I really shouldn’t be doing this in the .xsl anyways. I modified my sql that is serving up the data to make that change for me, which in retrospect, I probably should have thought of in the first place.

  • 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-01T21:04:04+00:00Added an answer on June 1, 2026 at 9:04 pm

    You don’t give much indication of the stylesheet so it’s hard to be sure but I’d guess you have something like

    <xsl:for-each select="row">
    <xsl:choose>
          <xsl:when test="row[@respondentabn='']">
            <label datafield="@respondentuid"></label>
          </xsl:when>
          <xsl:otherwise>
            <label datafield="@respondentname"></label>
          </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    

    or in any event if the current node is such that row[@respondentabn=”] does anything useful it must be the parent of row in which case <label datafield="@respondentuid"> would select attributes of the parent (even if the AVT syntax was corrected).

    So I would guess:

    <xsl:for-each select="row">
    <xsl:choose>
          <xsl:when test="string(@respondentabn)">
            <label datafield="{@respondentuid}"></label>
          </xsl:when>
          <xsl:otherwise>
            <label datafield="{@respondentname}"></label>
          </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    

    Or, more tersely

    <xsl:for-each select="row">
       <label datafield="{@respondentuid[string(.)]|
                          @respondentname[not(string(../@respondentuid))]}"/>
     </xsl:for-each>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView being populated from a non-SQL database that we use internally.
I have a large table that get populated from a view. This is done
I have a table Survey_Data_Response that is populated with an 'insert into' statement from
I have a database table on a development server that is now fully populated
I have table that I insert data with following query (from c# code): INSERT
We have some code that archives data from a Microsoft Access database into a
I have two columns in a table that are populated with integer values. For
I have a table, named ReportingPeriods , that I want to be populated entirely
I am using Derby database with Java and Eclipse. I have a table which
I have an online user roster populated from a database. Each username is a

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.