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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:55:38+00:00 2026-06-18T05:55:38+00:00

Given the following xml: <parameterGroup> <parameter value=1 name=Level0_stratum> </parameter> <parameter value=1 name=Level2_stratum> </parameter> <parameter

  • 0

Given the following xml:

<parameterGroup>
    <parameter value="1" name="Level0_stratum">
    </parameter>
    <parameter value="1" name="Level2_stratum">
    </parameter>
    <parameter value="1" name="Level1_stratum">
    </parameter>
    <parameter value="6" name="foo">
    </parameter>       
    <parameter value="9" name="bar">
    </parameter>    
</parameterGroup>

I’d like to derive a boolean variable that indicates whether the @value of ALL the Level*_stratum values are the same, as in this case they are (1).

So far I’ve been able to group all the pertinent nodes in a set as follows:

select="//parameter[starts-with(@name,'Level') and ends-with(@name,'_stratum') ]"

but I’m not sure the most efficient way to compare all their @value attributes for equality?

  • 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-18T05:55:39+00:00Added an answer on June 18, 2026 at 5:55 am

    I believe this should do what you’re looking to do (the value-of lines are not necessary and are just there to show the values of the variables):

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    
        <xsl:template match="/">
          <xsl:variable 
                 name="allStrata"
                 select="//parameter[starts-with(@name, 'Level') and
                                     ends-with(@name, '_stratum')]" />
          <xsl:value-of select="concat(count($allStrata), ' strata. ')"/>
    
          <!-- Determines whether all strata have the same values by comparing them all 
                 against the first one. -->
          <xsl:variable name="allStrataEqual" 
                        select="not($allStrata[not(@value = $allStrata[1]/@value)])" />
    
          <xsl:value-of select="concat('All equal: ', $allStrataEqual)" />
        </xsl:template>
    </xsl:stylesheet>
    

    When this is run on your sample input above, the result is:

    3 strata. All equal: true
    

    When this is run on your sample input after changing the third value to 8 (or anything else), the result is:

    3 strata. All equal: false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XML (basic.xml): <rdr> <details> <detail> <name>version</name> <value>15.0</value> </detail> <detail> <name>resolution</name> <value>1080X1920</value>
Given the following XML structure: <courses> <course> <title>foo</title> <description>bar</description> </course> ... </courses> How could
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <application name=foo> <movie name=tc english=tce.swf chinese=tcc.swf
Given the following xml: <root xmlns=http://tempuri.org/myxsd.xsd> <node name=mynode value=myvalue /> </root> And given the
Given the following XML markup: <root xmlns=Demo> <child name=foo/> </root> and an XPathNavigator positioned
Given the following XML fragment: <foo> <bar>1</bar> <bar>2</bar> <bar>3</bar> </foo> The following XSL should
Given the following XML: <Contact> <ContactID>41111-f15a-4fa1-b643-47877608f557</ContactID> <ContactStatus>ACTIVE</ContactStatus> <Name>ABC Ltd</Name> <EmailAddress>xxx@xxx.co</EmailAddress> <SkypeUserName>xxxdemo</SkypeUserName> <Addresses> <Address> <AddressType>STREET</AddressType>
Given the following XML, I would like to return all eventtitles where the eventtype
Given the following XML file: <packages> <package name=Library> <distributionPoints> <distributionPoint path=http://SERVER001/SMS_DP_SMSPKGD$/CEN0003B/ /> <distributionPoint path=http://SERVER002/SMS_DP_SMSPKGD$/CEN0003B/
Given the following XML: <results name=queryResults> <int name=intfield1:[* TO 10]>11</int> <int name=intfield2:[10 TO 20]>9</int>

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.