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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:12:38+00:00 2026-05-27T09:12:38+00:00

Here is the DTD <!ELEMENT Responses (Student*)> <!ELEMENT Student (Response+)> <!ATTLIST Student studentID ID

  • 0

Here is the DTD

<!ELEMENT Responses (Student*)>

<!ELEMENT Student (Response+)>

    <!ATTLIST Student   studentID ID #REQUIRED>



<!ELEMENT Response (List+)>

<!ELEMENT List (#PCDATA)>

    <!ATTLIST List questionID IDREF #REQUIRED>

I want the college that most students are in. If there is a tie, report all colleges that tied.

let $student := doc("responses.xml")/Responses/Student 

for $dc in distinct-values 
    (for $college in $student/Response/List[@questionID = "college"]
    return data($college))

return <College>{$dc} - number of students: {count($student[Response/List[@questionID = "college"] = data($dc)])</College>)

I am getting error with count(), I just want to count with a condition.

2nd question how do I select the maximum ones

  • 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-27T09:12:39+00:00Added an answer on May 27, 2026 at 9:12 am

    There is a typo in the last line of your code. You have an open curly brace just before count, but it is not closed before </College>, and there is an extra closing parenthesis after </College>.

    To get the college that is associated with (attended by?) the most students, you need to order on the count, and take the first item that is returned that way. See the slightly altered code below.

    Note: I had to guess about your data a bit, so I created something myself. It is such that there are actually three colleges with same max, but only one is returned. You may want to tweak a bit, by finding the max count itself first, and use that to locate all colleges with that count afterwards..

    let $doc := 
        document {
            <Responses>
                <Student studentID="s1">
                    <Response>
                        <List questionID="college">q1</List>
                        <List questionID="college">q2</List>
                        <List questionID="college">q3</List>
                    </Response>
                    <Response>
                        <List questionID="college">q4</List>
                        <List questionID="college">q5</List>
                        <List questionID="college">q6</List>
                    </Response>
                </Student>
                <Student studentID="s2">
                    <Response>
                        <List questionID="college">q4</List>
                        <List questionID="college">q5</List>
                        <List questionID="college">q6</List>
                    </Response>
                    <Response>
                        <List questionID="college">q7</List>
                        <List questionID="college">q8</List>
                        <List questionID="college">q9</List>
                    </Response>
                </Student>
                <Student studentID="s3">
                    <Response>
                        <List questionID="college">q1</List>
                        <List questionID="college">q2</List>
                        <List questionID="college">q3</List>
                    </Response>
                    <Response>
                        <List questionID="college">q4</List>
                        <List questionID="college">q5</List>
                        <List questionID="college">q6</List>
                    </Response>
                </Student>
            </Responses>
        }
    

     

    let $student := $doc/Responses/Student
    return (
        for $dc in
            distinct-values(
                for $college in $student/Response/List[@questionID = "college"]
                return data($college)
            )
        let $count := count($student[Response/List[@questionID = "college"] = data($dc)])
        order by $count descending, $dc ascending
        return <College>{$dc} - number of students: {$count}</College>
    )[1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an HTML page where I want to load an element with a
First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
I'm seeing my Friend's code here... <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN> <HTML>
My Problem was: Add a value to a div element in a dropdown list.
I have an example of DTD script here, and I was wondering if they
Here is the basic XSL. I am trying to pull out the element q_DECISION_NUMBER
I want to bind an onclick event to an element I insert dynamically with
I'm trying to obtain a list of information for the root element of an
Using the DTD validator here , I am informed that the following DTD is
Line 8, Column 23: document type does not allow element STYLE here If 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.