xsl-list
[Top] [All Lists]

RE: Using 'contains' function with xsl:key

2005-09-06 07:38:21
Yes, it's possible. Whether it's useful is another question: an index search
may not be faster than a sequential search if there are only two possible
values.

Note that in XSLT 1.0 the "use" expression and the second argument of key()
are both converted to strings before comparison. In 2.0 they are compared in
their native type. So your example will work fine in both, but if the use
expression were a boolean and the argument to key() a string, it wouldn't.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Gjergji Spaho [mailto:gjspaho(_at_)gmail(_dot_)com] 
Sent: 06 September 2005 14:19
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Using 'contains' function with xsl:key

Hi everyone!
I have a XML with elements that have an id attribute.
The value of the id attribute is composed in one of the two ways:
 
1) '_field:' + valid string + number
2)'_group:' + valid string + number
 
All i want is to create two different groups based on the first word
of the attribute value : '_field'  or 'group'.
 
One way is: 
<xsl:key name="ctlkey" match="*" use="substring-before(@id,':')"/>
 
and use it 
key('ctlkey','_field') or key('ctlkey','_group')
 
now my quetion is:
Is it possible to have the xsl:key defined:
 
<xsl:key name="ctlkey" match="*" use="contains(@id,'_field')"/>
 
and then use it
 
key('ctlkey',true()) or key('ctlkey',false()) ??????
 
thanks anyway

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