xsl-list
[Top] [All Lists]

Re: Defining a key on a RTF inside a Template

2004-12-08 01:46:50
According to XSLT 1.0 specificatoion ( 
http://www.w3.org/TR/1999/REC-xslt-19991116 ), xsl:key is a
top-level element. Therefore you cannot place it outside a 
xsl:stylesheet/xsl:transform .
The easiest solution: do not use keys. Keys are a mechanism to optimize 
performance; their
functionality can be obtained by XPath expressions.
The second way to solve your problem: find a way to declare them globally. 
Generally speaking,
this is application dependent, and without providing at least the context in 
which your key must
be computed (the matched pattern by your template), it is impossible to say 
which would that be.
In particular, I find that your variable "projectSum" and your key 
"countDetail" does not depend
in any way of context node, therefore I think that just by moving them in the 
document element of
your template (xsl:stylesheet/xsl:transform), making them top-level elements, 
you will get your
desired functionality.


--- "Ranjan K. Baisak" <ranjanbaisak(_at_)yahoo(_dot_)com> wrote:

I am creating  a key inside a template with RTF as
below:
<xsl:variable name="projectSum">
      <xsl:for-each select="//project">
              <xsl:variable name="projectname" select="./@name"/>
              <xsl:variable name="projectid" select="@id"/>
              <xsl:variable name="projectref"
select="projectelement/@ref"/>
              <xsl:copy>
                      <xsl:copy-of select="./@name"/>
                      <xsl:copy-of select="./@id"/>
                      <projectsum>
                              <xsl:copy-of
select="count(key('ProjectPartNumber',$projectref))"/>
                      </projectsum>
              </xsl:copy>
      </xsl:for-each>
</xsl:variable>

<xsl:key name="countDetail"
match="exslt:node-set($projectSum)/projectsum"
use="./@id"/>

In XALAN it throws error with message "Incorrect place
of defining Key".
I am not sure whether it is possible to create a key
with RTF within a template?
If not possible, is there any otherway to achive the
same functionality?

regards,
Ranjan



              
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250

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




=====
Marian
http://www.utdallas.edu/~mgo031000/


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250

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