Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XSLT 2.0 syntax within concat()

Posted on 2005-02-25
4
Medium Priority
?
608 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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

577 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