Click here to Skip to main content
15,890,336 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: saving a file to the internet. Pin
Gerry Schmitz1-Jun-17 3:20
mveGerry Schmitz1-Jun-17 3:20 
AnswerRe: saving a file to the internet. Pin
Terry Perez11-Sep-17 3:41
Terry Perez11-Sep-17 3:41 
QuestionXSLT passing a variable to starts-with Pin
bjmallon13-Feb-17 14:03
bjmallon13-Feb-17 14:03 
AnswerRe: XSLT passing a variable to starts-with Pin
Richard Deeming14-Feb-17 2:32
mveRichard Deeming14-Feb-17 2:32 
GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon16-Feb-17 18:45
bjmallon16-Feb-17 18:45 
GeneralRe: XSLT passing a variable to starts-with Pin
Richard Deeming17-Feb-17 1:48
mveRichard Deeming17-Feb-17 1:48 
GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon20-Feb-17 22:55
bjmallon20-Feb-17 22:55 
GeneralRe: XSLT passing a variable to starts-with Pin
Richard Deeming21-Feb-17 1:42
mveRichard Deeming21-Feb-17 1:42 
OK, I think I've found the problem.

Within the <xsl:for-each select="msxsl:node-set($Letters)/token">, the default context is the node-set returned from your "tokenise" template. When you try to resolve /Users, it's looking in that node set, rather than the source document.

You need to capture the nodes from the source document that you want to process, and pass those to the template:
XML
<xsl:variable name="users" select="/Users" />

<xsl:for-each select="msxsl:node-set($Letters)/token">
    <xsl:variable name="currToken" select ="./node()[1]"/>
    <xsl:call-template name="ListSurnameStartsWith">
	    <xsl:with-param name="users" select="$users"/>
        <xsl:with-param name="character" select="$currToken"/>
    </xsl:call-template>
</xsl:for-each>

Update the template to:
XML
<xsl:template name="ListSurnameStartsWith">
    <xsl:param name="users" />
    <xsl:param name="character" select="''"/>
    
    <xsl:variable name="charMatch" select="$users/User[starts-with(Surname, $character)]"/>    
    <xsl:variable name="charCount" select="count($charMatch)"/>
    
    <xsl:if test="$charCount > 0">
        <h2>
            <a href="javascript:void(0)" class="dsphead" onclick="dsp(this)">
                <span class="dspchar">+</span> <xsl:value-of select="$character"/> (<xsl:value-of select="$charCount"/>)
            </a>
        </h2>
        <div class="dspcont">
            <table border="1" cellpadding="1" cellspacing="1">
                <tr>
                    <xsl:call-template name="HeadingRow"/>
                </tr>
                
                <xsl:for-each select="$charMatch">
                    <xsl:sort select="Surname"/>
                    <xsl:call-template name="UserRow"/>
                </xsl:for-each>
            </table>
        </div>
    </xsl:if>
</xsl:template>




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: XSLT passing a variable to starts-with Pin
bjmallon21-Feb-17 10:24
bjmallon21-Feb-17 10:24 
QuestionHow to generate XML file with serialisation in vb.net Pin
Member 1280320219-Oct-16 8:06
Member 1280320219-Oct-16 8:06 
Rant[REPOST] How to generate XML file with serialisation in vb.net Pin
Richard Deeming19-Oct-16 9:28
mveRichard Deeming19-Oct-16 9:28 
QuestionTransform the date format from yyyy/mm/dd to mm/dd/yyyy Pin
Member 1278840611-Oct-16 15:21
Member 1278840611-Oct-16 15:21 
AnswerRe: Transform the date format from yyyy/mm/dd to mm/dd/yyyy Pin
Richard Deeming12-Oct-16 3:26
mveRichard Deeming12-Oct-16 3:26 
QuestionRead xml string Pin
trungysp198610-Oct-16 14:48
trungysp198610-Oct-16 14:48 
AnswerRe: Read xml string Pin
Richard MacCutchan10-Oct-16 21:54
mveRichard MacCutchan10-Oct-16 21:54 
AnswerRe: Read xml string Pin
Swinkaran11-Oct-16 16:09
professionalSwinkaran11-Oct-16 16:09 
QuestionXML Pin
Member 1273144310-Sep-16 3:41
Member 1273144310-Sep-16 3:41 
AnswerRe: XML Pin
OriginalGriff10-Sep-16 3:44
mveOriginalGriff10-Sep-16 3:44 
GeneralRe: XML Pin
Member 1273144310-Sep-16 3:48
Member 1273144310-Sep-16 3:48 
GeneralRe: XML Pin
Member 1273144310-Sep-16 3:52
Member 1273144310-Sep-16 3:52 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 4:06
mveOriginalGriff10-Sep-16 4:06 
GeneralRe: XML Pin
Member 1273144310-Sep-16 4:18
Member 1273144310-Sep-16 4:18 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 4:27
mveOriginalGriff10-Sep-16 4:27 
GeneralRe: XML Pin
Member 1273144310-Sep-16 4:38
Member 1273144310-Sep-16 4:38 
GeneralRe: XML Pin
OriginalGriff10-Sep-16 4:45
mveOriginalGriff10-Sep-16 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.