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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:17:14+00:00 2026-06-13T11:17:14+00:00

I’ve been banging my head against the wall with this one. I have a

  • 0

I’ve been banging my head against the wall with this one. I have a series of XML like so:

    <INTELLCONT id="33954082817" dmd:lastModified="2011-04-05T13:38:05" dmd:startDate="2010-12-30" dmd:endDate="2010-12-30">
        <CONTYPE>Journal Article</CONTYPE>
        <CONTYPEOTHER/>
        <CLASSIFICATION>Learning and Pedagogical Research</CLASSIFICATION>
        <STATUS>Not Accepted</STATUS>
        <TITLE>The Use of Alternative Quiz Formats to Enhance Students’ Experiences in the Introductory Accounting Course</TITLE>

    </INTELLCONT>
    <INTELLCONT id="11473068032" dmd:lastModified="2012-08-30T14:12:05" dmd:startDate="2009-03-17" dmd:endDate="2010-11-30">
        <CONTYPE>Journal Article</CONTYPE>
        <CONTYPEOTHER/>
        <CLASSIFICATION>Learning and Pedagogical Research</CLASSIFICATION>
        <STATUS>Published</STATUS>
        <TITLE>"Using Debate to Enhance Critical Thinking in the Accounting Classroom: Two Examples of Debates on the Sarbanes-Oxley Act and Tax Policy Issues</TITLE>

(I’ve removed some of the other tags for brevity). For anyone xml file, there might be 10-20 of these <INTELLCONT> tags. I need to surface the values of the first five of some fields within the <INTELLCONT>, but only the entries where the <PUBLISH> tag is set to “Published”. Here’s the xsl so far:

    <xsl:choose>
    <xsl:when test="dm:Data/dm:Record/dm:INTELLCONT/dm:STATUS = 'Published'">
        <xsl:for-each select="dm:Data/dm:Record/dm:INTELLCONT[1]">
            <xsl:if test="dm:STATUS = 'Published'">
                <p><xsl:value-of select="dm:TITLE" />, 
                    <xsl:choose>
                        <xsl:when test="dm:JOURNAL/dm:JOURNAL_NAME !=''">
                            <i><xsl:value-of select="dm:JOURNAL/dm:JOURNAL_NAME"/></i>, 
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:text> </xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="dm:DTM_PUB !=''">
                            <xsl:value-of select="dm:DTM_PUB"/>,
                        </xsl:when>
                        <xsl:otherwise>
                           <xsl:text> </xsl:text>
                       </xsl:otherwise>
                   </xsl:choose>
                    <xsl:value-of select="dm:DTY_PUB"/></p>
            </xsl:if>
        </xsl:for-each>
    </xsl:when>
</xsl:choose>

This will surface the first entry, but only if <STATUS> is set to “Published”. This is fine, but like in the xml above, since the <STATUS> is not “Published”, nothing shows. This is also fine, but if I put this code in, and enumerate this line <xsl:for-each select="dm:Data/dm:Record/dm:INTELLCONT[1]"> out to <xsl:for-each select="dm:Data/dm:Record/dm:INTELLCONT[5]"> then I’ll get all of the entries where <STATUS> is published, but if there are fewer than 5 that are published, then I won’t get the list of 5 entries that I need.

I know there has to be a better way to do this, but I haven’t figured it out yet. Any help would be great!!

  • 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-13T11:17:15+00:00Added an answer on June 13, 2026 at 11:17 am

    I don’t fully understand your explanation of the requirements, but you seem to be going about it in quite the wrong way. You need to learn about template rules, which are the natural way of writing code in XSLT!

    If you want to display the first five INTELLCONT elements with a STATUS of Published, use

    <xsl:apply-templates select="dm:INTELLICONT[dm:STATUS='Published'][position() &lt;= 5]"/>
    

    Then write a template rule to display them:

    <xsl:template match=:dm:INTELLICONT">
     <p><xsl:apply-templates/></p>
    </xsl:template>
    

    Then write template rules for the individual fields:

    <xsl:template match="dm:JOURNAL[dm:JOURNAL_NAME != '']">
      <i><xsl:value-of select="dm:JOURNAL_NAME"/></i>
    </xsl:template>
    

    When you see XSLT code written by experts, you’ll find there are very few for-each, choose, or if instructions.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.