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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:23:43+00:00 2026-05-11T21:23:43+00:00

I have an xml output like this: <data> <item-types> <entry id=1 items=5> <category>Frozen</category> </entry>

  • 0

I have an xml output like this:

<data>
    <item-types>
        <entry id="1" items="5">
            <category>Frozen</category>
        </entry>
        <entry id="2" items="4">
            <category>Breakfast</category>
        </entry>
    </item-types>

    <items>
        <entry id="28">
            <item-number>1115</item-number>
            <name>Marion Berries, IQF</name>
            <area>
                <item id="1">Groceries - Frozen</item>
            </area>
        </entry>
        <entry id="29">
            <item-number>1117</item-number>
            <name>Peach Cups</name>
            <area>
                <item id="1">Groceries - Frozen</item>
            </area>
        </entry>
        <entry id="35">
            <item-number>1570</item-number>
            <name>Sausage Patty</name>
            <area>
                <item id="2">Groceries - Breakfast</item>
            </area>
        </entry>
        <entry id="32">
            <item-number>1575</item-number>
            <name>French Toast Stix, WG</name>
            <area>
                <item id="2">Groceries - Breakfast</item>
            </area>
        </entry>
    </items>
</data>

The items-types are the categories of the items below. item-types/entry/@id relates directly to items/entry/area/item/@id and I’m trying to organize the items in to the categories for my output.

So far I am using the following XSL transformation.

<xsl:template match="item-types/entry">
    <h3><xsl:value-of select="concat(@id,'. ',category)" /></h3>
    <ul>
        <xsl:apply-templates select="/data/items/entry[area/item/@id = @id]" />
    </ul>
</xsl:template>
<xsl:template match="items/entry">
    <li>
        <xsl:value-of select="concat(item-number,'. ',name,' (',area/item/@id,')')" />
    </li>
</xsl:template>

The problem is it’s not working. I believe the problem is the predicate on line 4 of the transformation: [area/item/@id = @id] When I remove this, it shows all the items in every category.

Is there a way to show the “Frozen” items in the “Frozen” category and the “Breakfast” items in the “Breakfast” category?

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-11T21:23:44+00:00Added an answer on May 11, 2026 at 9:23 pm

    Easily done with an XSL key.

    <xsl:key name="kEntryByAreaId" match="items/entry" use="area/item/@id" />
    
    <!-- this is just for the sake of the test -->
    <xsl:template match="/data">
      <xsl:apply-templates select="item-types/entry" />
    </xsl:template>
    
    <xsl:template match="item-types/entry">
      <h3>
        <xsl:value-of select="concat(@id,'. ',category)" />
      </h3>
      <ul>
        <xsl:apply-templates select="key('kEntryByAreaId', @id)" />
      </ul>
    </xsl:template>
    
    <xsl:template match="items/entry">
      <li>
        <xsl:value-of select="
          concat(
            item-number, 
            '. ', name,
            ' (', area/item/@id, ')'
          )
        " />
      </li>
    </xsl:template>
    

    Now to answer the question why your try did not work.

    This expression:

    /data/items/entry[area/item/@id = @id]
    

    says: “all the /data/items/entry elements with their area/item/@id value equal to their @id value”. Trouble is – they have no @id value.

    What you mean is this:

    /data/items/entry[area/item/@id = current()/@id]
    

    This would work, but the key will be faster.

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

Sidebar

Ask A Question

Stats

  • Questions 129k
  • Answers 129k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer str.count(sub[, start[, end]]) Return the number of non-overlapping occurrences of… May 12, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer Add the cents to the number and you get 2314885530818450000,… May 12, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer I am using TinyMCE with the paste plugin an the… May 12, 2026 at 5:51 am

Related Questions

I have an Edit action and an Edit view to allow users to update
Say I have the following XML: <a> <b>1</b> <b>2</b> <b>3</b> </a> ... and require:
I'm running into a problem with axis2 and ajax. I'm getting xml from one
Is there anything similar to getElementById in actionscript? I'm trying to make a prototype

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.