xsl-list
[Top] [All Lists]

RE: Filter XML base on partial matching element value

2004-05-06 14:10:43
I'm guessing that you want to assign the variable a value?

If so, in XSLT, you only can assign it a value to the element content like
your example shows, or use a select attribute containing an Xpath
expression, like this:

<xsl:variable name="parFieldValue" select="Activities/Activity[(_at_)attrx=
'abc']" />

After that you can't change the value of the variable anymore, but you can
refer to it using $parFieldValue anywhere it is in scope. The scope of the
variable can be global or local (within a template), it depends where you
declare the variable.

HTH,
<prs/>

-----Original Message-----
From: Horacio Escalada [mailto:HEscalada(_at_)cpso(_dot_)on(_dot_)ca] 
Sent: Thursday, May 06, 2004 3:48 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Filter XML base on partial matching element value

Thank you Pieter,

I am using contains() with a conditional xsl:if test and it is working.


Now another question for the list. 
I would like to get the value of a random Element by passing the Element
Name in a variable

<xsl:variable name="parFieldValue">Name</xsl:variable >

....
....

Then 

<xsl:value-of select="Activities/Activity[$parFieldValue]" />

Should return the value of

<xsl:value-of select="Activities/Activity/Name" />


Horacio

-----Original Message-----
From: Pieter Reint Siegers Kort 
[mailto:pieter(_dot_)siegers(_at_)elnorte(_dot_)com]
Sent: May 6, 2004 1:31 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Filter XML base on partial matching element value


Hi Horacio, 

The way you're referring to 'wildcards', you could use the XSLT
start-with() or contains() string functions.

HTH,
<prs/>

-----Original Message-----
From: Horacio Escalada [mailto:HEscalada(_at_)cpso(_dot_)on(_dot_)ca] 
Sent: Thursday, May 06, 2004 12:23 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Filter XML base on partial matching element value

Hi all,

It is possible to use 'wildcards' while selecting elements containing
partial matching values.

My XML source looks like this:

<Activities>
        <Activity>
                <Id>4865</Id>
                <Status>Open</Status>
                <Name>Paul</Name>
        </Activity>
        
        <Activity>
                <Id>6765</Id>
                <Status>Open Pending</Status>
                <Name>John</Name>
        </Activity>

        <Activity>
                <Id>66567</Id>
                <Status>Open</Status>
                <Name>Joseph</Name>
        </Activity>

        <Activity>
                <Id>54565</Id>
                <Status>Close</Status>
                <Name>Susan</Name>
        </Activity>
</Activities>


I would like to get the following result

<Activities>

        <Activity>
                <Id>6765</Id>
                <Status>Open Pending</Status>
                <Name>John</Name>    ----------> Matching 'Jo'
        </Activity>

        <Activity>
                <Id>66567</Id>
                <Status>Open</Status>
                <Name>Joseph</Name>    ----------> Matching 'Jo'
        </Activity>

</Activities>


Thank you in advance

Horacio

--+------------------------------------------------------------------
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>
--+--


--+------------------------------------------------------------------
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>
--+--


<Prev in Thread] Current Thread [Next in Thread>