xsl-list
[Top] [All Lists]

RE: [xsl] Do some elements contain strings from other elements?

2011-01-27 09:50:42
Andrew,

Martin's answer was perfect.

Languishing in the xsl1 backwaters I've been watching the pack move away and
had actually assumed that boolean() didn't work in XSL1. It's a problem
because I see these neat solutions on the xsl-list and most of the time now
they are xsl2 only.

You live and learn:)


William Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net


-----Original Message-----
From: Andrew Welch [mailto:andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com] 
Sent: 27 January 2011 15:33
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Do some elements contain strings from other elements?

Hi Martin,

On 27 January 2011 15:25, Martin Honnen <Martin(_dot_)Honnen(_at_)gmx(_dot_)de> 
wrote:
W Charlton wrote:

I have the following XML.
<XML>
            <SplitNameList>
                        <SplitName>
                                    <GivenName>ANDREW</GivenName>
                                    <FamilyName>SMITH</FamilyName>
                        </SplitName>
                        <SplitName>
                                    <GivenName>DONALD</GivenName>
                                    <FamilyName>DUCK</FamilyName>
                        </SplitName>
            </SplitNameList>
            <FulNameList>
                        <FullName>DAVID JONES</FullName>
                        <FullName>ANDREW J SMITH</FullName>
                        <FullName>JOHN SMITH</FullName>
            </FulNameList>
</XML>

I need to know if any of the Family Names match in the two lists. Either
of these two lists could be quite long and this is in the middle of a
load
of logic. All I need here is a True/False. It doesn’t have to be an exact
match just as long as it matches the FamilyName.


 <xsl:template match="SplitNameList">
   <xsl:variable name="test">
     <xsl:for-each select="SplitName/FamilyName">
       <xsl:value-of select="boolean(/XML/FulNameList/FullName[contains(.,
current())])"/>
     </xsl:for-each>
   </xsl:variable>
   <xsl:if test="contains($test, 'true')">..</xsl:if>
 </xsl:template>

This will return true if the FamilyName is the same as someones first
name, or say some substring of the surname.

Guessing the requirements, I think would want to tokenize the FullName
and then compare the FamilyName to the last item... but cant be sure.

-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--