?
Solved

XSLT 2.0 syntax within concat()

Posted on 2005-02-25
4
Medium Priority
?
596 Views
Last Modified: 2008-02-01
I am trying to pass a value into concat() and am a bit lost. The code:

<xsl:for-each-group select="/Reports/Report" group-by="@type">
  <xsl:sort select="@type"/>
  <h2>
    <xsl:value-of select="current-grouping-key()"/>
  </h2>
  <ul>
    <xsl:for-each select="current-group()/Rpt_Title">
      <li>
        <a href="{concat('DESC_',**HERE**,'.html')}">
          <xsl:apply-templates/>
        </a>
      </li>
    </xsl:for-each>
  </ul>
</xsl:for-each-group>

Where I have written "**HERE**" I want the value of 'current-group()/Rpt_Code' which is at the same depth level as Rpt_Title.

TIA, Ken Smith
0
Comment
Question by:KenwSmith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 15

Expert Comment

by:dualsoul
ID: 13402426
you forgot to post your XML :)
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 13402472
so, i've tested on this one:
<?xml version="1.0" encoding="UTF-8"?>
<Reports>
    <Report type="1">
        <Rpt_Title>Title 1</Rpt_Title>
    </Report>
    <Report type="2">
        <Rpt_Title>Title 2</Rpt_Title>
    </Report>
    <Report type="1">
        <Rpt_Title>Title 3</Rpt_Title>
    </Report>
    <Report type="2">
        <Rpt_Title>Title 4</Rpt_Title>
    </Report>
    <Report type="2">
        <Rpt_Title>Title 5</Rpt_Title>
    </Report>
</Reports>


this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/10/xpath-functions" xmlns:xdt="http://www.w3.org/2004/10/xpath-datatypes">
    <xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">    
        <xsl:for-each-group select="/Reports/Report" group-by="@type">
            <xsl:sort select="@type"/>
            <h2>
                <xsl:value-of select="current-grouping-key()"/>
            </h2>
            <ul>
                <xsl:for-each select="current-group()/Rpt_Title">
                    <li>
                        <a href="{concat('DESC_',current-grouping-key(),'.html')}">
                            <xsl:apply-templates/>
                        </a>
                    </li>
                </xsl:for-each>
            </ul>
        </xsl:for-each-group>
    </xsl:template>
</xsl:stylesheet>


and it's works well, it produces links with href="DESC_1.html" and DESC_2.html
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 13402481
ohhh...stop, sorry it seems i've tested something different, than you ask me.
0
 
LVL 15

Accepted Solution

by:
dualsoul earned 500 total points
ID: 13402500
this one i can guess?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/10/xpath-functions" xmlns:xdt="http://www.w3.org/2004/10/xpath-datatypes">
    <xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">    
        <xsl:for-each-group select="/Reports/Report" group-by="@type">
            <xsl:sort select="@type"/>
            <h2>
                <xsl:value-of select="current-grouping-key()"/>
            </h2>
            <ul>
                <xsl:for-each select="current-group()/Rpt_Title">
                    <li>
                        <a href="{concat('DESC_',current()/../Rpt_Code,'.html')}">
                            <xsl:apply-templates/>
                        </a>
                    </li>
                </xsl:for-each>
            </ul>
        </xsl:for-each-group>
    </xsl:template>
</xsl:stylesheet>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question