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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:06:22+00:00 2026-05-25T20:06:22+00:00

I have an XML document (shown below), what I need to do is get

  • 0

I have an XML document (shown below), what I need to do is get a list of all the unique Type @ID values, regardless of where they are below SizeRanges

So for this document I need to get 10,8,6,5 into something I can use for-each upon.

Ultimately, I’m trying to show each SizeRange in a table beside each other, and get the same Types to line up on the same row. But the problem I am having is extracting a distinct list of Types I can loop on.

XML Document:

<SizeRanges>
    <SizeRange ID="1" Name="8-18">
        <Types>
            <Type ID="10">
                <Size Name="8"  Quantity="1" />
                <Size Name="10" Quantity="2" />
                <Size Name="12" Quantity="2" />
                <Size Name="14" Quantity="3" />
                <Size Name="16" Quantity="1" />
                <Size Name="18" Quantity="1" />
            </Type>
            <Type ID="8">
                <Size Name="8"  Quantity="1" />
                <Size Name="10" Quantity="1" />
                <Size Name="12" Quantity="2" />
                <Size Name="14" Quantity="2" />
                <Size Name="16" Quantity="1" />
                <Size Name="18" Quantity="1" />
            </Type>
            <Type ID="6">
                <Size Name="8"  Quantity="1" />
                <Size Name="10" Quantity="1" />
                <Size Name="12" Quantity="1" />
                <Size Name="14" Quantity="1" />
                <Size Name="16" Quantity="1" />
                <Size Name="18" Quantity="1" />
            </Type>
            <Type ID="5">
                <Size Name="10" Quantity="1" />
                <Size Name="12" Quantity="1" />
                <Size Name="14" Quantity="1" />
                <Size Name="16" Quantity="1" />
                <Size Name="18" Quantity="1" />
            </Type>
        </Types>
    </SizeRange>
    <SizeRange ID="2" Name="S-XL">
        <Types>
            <Type ID="10">
                <Size Name="S"  Quantity="1" />
                <Size Name="M"  Quantity="3" />
                <Size Name="L"  Quantity="4" />
                <Size Name="XL" Quantity="2" />
            </Type>
            <Type ID="8">
                <Size Name="S"  Quantity="1" />
                <Size Name="M"  Quantity="2" />
                <Size Name="L"  Quantity="3" />
                <Size Name="XL" Quantity="2" />
            </Type>
            <Type ID="6">
                <Size Name="S"  Quantity="1" />
                <Size Name="M"  Quantity="2" />
                <Size Name="L"  Quantity="2" />
                <Size Name="XL" Quantity="1" />
            </Type>
            <Type ID="5">
                <Size Name="S"  Quantity="1" />
                <Size Name="M"  Quantity="1" />
                <Size Name="L"  Quantity="2" />
                <Size Name="XL" Quantity="1" />
            </Type>
        </Types>
    </SizeRange>
</SizeRanges>
  • 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-25T20:06:23+00:00Added an answer on May 25, 2026 at 8:06 pm

    Give this a shot:

    <xsl:key name="types" match="Type" use="@ID"/>
    <xsl:variable name="distinctTypes" as="xs:integer*" select="distinct-values(//SizeRange/Types/Type)" />
    <xsl:template match="/">
        <xsl:for-each select="$distinctTypes">
            <xsl:value-of select="." />
        </xsl:for-each>
    </xsl:template>
    

    Here’s another way:

    <xsl:key name="types" match="Type" use="@ID"/>
    <xsl:template match="/">
        <xsl:for-each select="//SizeRange/Types/Type[generate-id() = generate-id(key('types', @ID)[1])]">
            <xsl:value-of select="@ID"/>
        </xsl:for-each>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have an xml document consisting of a list as shown below: <Items>
i have a list of event Ids returned from an xml document as shown
I have a XML document like shown below: <root> <level1> <level2> <level3> ..... </level3>
I have an xml document object that I need to convert into a string.
Situation: I have a simple XML document that contains image information. I need to
I have got the XML below, which is stored in string type variable, and
I have an XML document with un-namespaced elements, and I want to use XSLT
I have an XML document: var xml:XML = new XML(<rootNode> <head> <meta name=template content=Default
I have an XML document something like ::: <?xml version=1.0 encoding=utf-8?> <?mso-application progid=Excel.Sheet?> <Workbook
I have an XML document that I'm trying to style via CSS. A relevant

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.