[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Defining a key on a RTF inside a Template


Subject: RE: [xsl] Defining a key on a RTF inside a Template
From: "Ranjan K. Baisak" <ranjanbaisak@xxxxxxxxx>
Date: Wed, 8 Dec 2004 04:25:03 -0800 (PST)

But Michael , I want to select a node in RTF which
contains a context node. In this case context node
comes from the document itself.
This is what I want

-Ranjan

--- Michael Kay <mike@xxxxxxxxxxxx> wrote:

> The key() function selects nodes in the document
> that contains the context
> node. So if the context node is a node in the RTF,
> the key() function will
> search the RTF.
> 
> The easiest way of ensuring this in XSLT 1.0 is to
> use something like:
> 
> <xsl:for-each select="xx:node-set($rtf)">
>   <xsl:value-of select="key('k', 12345)"/>
> </xsl:for-each>
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 
> > -----Original Message-----
> > From: Ranjan K. Baisak
> [mailto:ranjanbaisak@xxxxxxxxx] 
> > Sent: 08 December 2004 10:46
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: RE: [xsl] Defining a key on a RTF inside
> a Template 
> > 
> > Michael,
> >        I am afraid if I understood your suggestion
> > correctly.
> > My key is associated with RTF "projectSum". The I
> am
> > wodering how I can use "projectSum" RTF in my key.
> > "projectsum" is a node in "projectSum" RTF
> variable.
> > 
> > regards,
> > Ranjan
> > --- Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > 
> > > The value of the match attribute must be a valid
> > > pattern
> > > 
> > > match="exslt:node-set($projectSum)/projectsum"
> > > 
> > > should simply be
> > > 
> > > match="projectsum"
> > > 
> > > The xsl:key declaration doesn't define which
> > > document the key is referring
> > > to; that's decided at the time you use the key()
> > > function.
> > > 
> > > Michael Kay
> > > http://www.saxonica.com/ 
> > > 
> > > > -----Original Message-----
> > > > From: Ranjan K. Baisak
> > > [mailto:ranjanbaisak@xxxxxxxxx] 
> > > > Sent: 08 December 2004 09:05
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: RE: [xsl] Defining a key on a RTF
> inside
> > > a Template 
> > > > 
> > > > I am quite agree with Michael because my key
> > > depends
> > > > upon an RTF. So I can take that RTF is the
> context
> > > > node for declaring key.
> > > > 
> > > > In either case, I am getting error during
> > > processing.
> > > > In XALAN : "Incorrect place of defining key"
> > > > In SAXON 8.1.1: XPath syntax error at char 0
> in
> > > > {exslt:node-set($}:;     The only functions
> > > allowed in
> > > > a pattern are id() and key()
> > > > 
> > > > I too tried to declare the key at the top of
> my
> > > > stylesheet but it still throw error.
> > > > 
> > > > 
> > > > regards,
> > > > Ranjan
> > > > 
> > > > --- Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > > 
> > > > > > 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.
> > > > > 
> > > > > No, it's perfectly OK to use keys to search
> > > within
> > > > > an RTF.
> > > > > 
> > > > > Michael Kay
> > > > > http://www.saxonica.com/
> > > > > 
> > > > > > 
> > > > > > --- "Ranjan K. Baisak"
> > > <ranjanbaisak@xxxxxxxxx>
> > > > > 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
> > > > > > > 
> > > > > > > 
> > > > > > 
> > > > > > 
> > > > > > =====
> > > > > > Marian
> > > > > > http://www.utdallas.edu/~mgo031000/
> > > > > > 
> > > > > > 
> > > > > > 		
> > > > > > __________________________________ 
> 
=== message truncated ===



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail


Current Thread
Keywords