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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:24:39+00:00 2026-05-23T08:24:39+00:00

Context This is for a Custom Query Web Part (CQWP) in SharePoint 2007 .

  • 0

Context

This is for a Custom Query Web Part (CQWP) in SharePoint 2007. I am extracting a list of event from a calendar and I want to display a list of current system State for all system, even if they have no current event.

The list is ordered by system name.

XML received

Suppose you have either XML :

<events>
    <event>
        <system>A</system>
        <state>1</state>
    </event>
    <event>
        <system>B</system>
        <state>2</state>
    </event>
    <event>
        <system>C</system>
        <state>3</state>
    </event>
</events>

OR

<events>
    <event>
        <system>A</system>
        <state>1</state>
    </event>

    <event>
        <system>C</system>
        <state>2</state>
    </event>
</events>

Note : 3 static system (A,B or C). They can have no current event (I didn’t put start/end date as it was unneeded for the question.)

Data output wanted

I want my XSL output to be like :

<table>
    <tr>
        <th>System</th>
        <th>State</th>
    </tr>
    <tr>
        <td>A</td>
        <td>1</td>
    </tr>
    <tr>
        <td>B</td>
        <td>1</td>
    </tr>
    <tr>
        <td>C</td>
        <td>3</td>
    </tr>
</table>

That is, I want to have output for all 3 systems, even if they don’t have a current event (hence, not in the XML (Default state is 1)). Oh and yeah, 1 system could have 2+ current event. ( <td>A</td><td>1</td></tr><tr><td>A</td><td>2</td>). A perfect answer would concatenate same system event and only display the highest state, but I can do without.

Current XSL

Here’s the current template I have :

<xsl:template name="system" match="Row[@Style='system']" mode="itemstyle">
    <xsl:if test="count(preceding-sibling::*)=0">
        <table><tr><th>System</th>
        <th>State</th></tr>
    </xsl:if>
    <tr>
            <td><xsl:value-of select="@System"/></td>
             <td><xsl:value-of select="@State"/></td>
    </tr>
    <xsl:if test="count(following-sibling::*)=0">
        </table>
    </xsl:if>
</xsl:template>

What I thought

I though I could use a variable (or 3?) to contain my list of (static) system

<xsl:variable name="Systems">A,B,C</xsl:variable> 

<xsl:variable name="System1">A</xsl:variable> 
<xsl:variable name="System2">B</xsl:variable> 
<xsl:variable name="System3">C</xsl:variable> 

Then, in XSL, check if <xsl:value-of select="@System"/> ever equals this/those variable value.

Questions

Is it doable?

Would you suggest me to proceed otherwise, if so, how?

How can I compare my variable(s) to <xsl:value-of select="@System"/>?

Bonus: How can I concatenate same system event and only display the highest state?

  • 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-23T08:24:39+00:00Added an answer on May 23, 2026 at 8:24 am

    Thanks for both answerer, your example helped me understand XSL. However, since it was for SharePoint, I became aware that I’d have to play within the framework…

    The case no current event is handled in the mainStyle.xsl and only display default html.

    Items are handled in itemStyle.xsl, one by one. Most of my code was placed there.

    First, I created a bunch of variables:

        <xsl:variable name="testACCP">
                <xsl:choose><xsl:when test="count(../Row[@Systeme='A'])>0">1</xsl:when>
                [...]
        </xsl:variable>
    

    I then build up my solution, starting with a header when I was at my first node

         <xsl:if test="count(preceding-sibling::*)=0">
            <xsl:text disable-output-escaping="yes">
                &lt;table width="100%" border="0" cellspacing="0" cellpadding="3" &gt;
                [...]
    

    If a System had no event, I’d know it with my variable, and display accordingly

    <xsl:if test="$testA=0">
                <tr id="linkitem" class="item" style="background:#f0fff3">
                        <td>A</td><td>OK</td>
                        [...]
    

    As for the display of the max value only, this was abandoned. There’s some value to know that you have 2 current events impacting a system in the end.

    This solution work, but it is sorta dumb, creating lots of variables per items to do test on a group… To optimize, a highly modified mainstyle.xsl or a full blown WebPart would be required.

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

Sidebar

Related Questions

I've created a custom ItemStyle_ContactDetails.xsl for a SharePoint 2010 content query web part, which
I have adapted my Content Query Web Part (CQWP) so it generates ul tags
I have a custom list created in Sharepoint 2007 and displayed by a content
In the context of this question link text is possible from a Controller that
I want to open a file for reading. However, in the context of this
I came across this in the following context from B. Pfaff's Analysis of Integrated
I'm loading lots of User and related Group objects from a custom PDO query
I build custom gallery for photos only. I taking photos from sdcard with this
I need to store an array in a custom content type in MOSS. This
For context - read this . Problem: class Program { static void Main() {

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.