Quantcast

Saxon:evaluate in another context.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Saxon:evaluate in another context.

ROSSEL, Olivier (CIMPA)

In my template, $anotherNode points a node
from another document.

I need to make a saxon:evaluate with that
node as the context, and save the result node-set in a variable.

I thought this code would work:

 <xsl:variable name="result">
  <xsl:for-each select="$currentNode">
   <xsl:value-of select="saxon:evaluate($aXPath)"/>
  </xsl:for-each>
 </xsl:variable>

Unfortunately, the $result variable does not contain the
nodes matched by the saxon:evaluate, it contains just

one node whose generate-id() is completely weird.

In Xalan, the evaluate() function accepts a context node, so
this code works fine:

 <xsl:variable name="result" select="xalan:evaluate($currentNode, $aXPath)/>

What's the normal way to do that with Saxon?





This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Saxon:evaluate in another context.

Michael Kay
The context node for the expression evaluated by saxon:evaluate() is the
same as the context node for the context in which saxon:evaluate() is
invoked. So I don't think this is your problem. Let's see more of the
details of the stylesheet so we can get to the bottom of it.

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> ROSSEL, Olivier (CIMPA)
> Sent: 29 September 2005 13:41
> To: [hidden email]
> Subject: [saxon] Saxon:evaluate in another context.
>
>
> In my template, $anotherNode points a node
> from another document.
>
> I need to make a saxon:evaluate with that
> node as the context, and save the result node-set in a variable.
>
> I thought this code would work:
>
>  <xsl:variable name="result">
>   <xsl:for-each select="$currentNode">
>    <xsl:value-of select="saxon:evaluate($aXPath)"/>
>   </xsl:for-each>
>  </xsl:variable>
>
> Unfortunately, the $result variable does not contain the
> nodes matched by the saxon:evaluate, it contains just
>
> one node whose generate-id() is completely weird.
>
> In Xalan, the evaluate() function accepts a context node, so
> this code works fine:
>
>  <xsl:variable name="result"
> select="xalan:evaluate($currentNode, $aXPath)/>
>
> What's the normal way to do that with Saxon?
>
>
>
>
>
> This e-mail is intended only for the above addressee. It may contain
> privileged information. If you are not the addressee you must
> not copy,
> distribute, disclose or use any of the information in it. If you have
> received it in error please delete it and immediately notify
> the sender.
> Security Notice: all e-mail, sent to or from this address, may be
> accessed by someone other than the recipient, for system
> management and
> security reasons. This access is controlled under Regulation of
> Investigatory Powers Act 2000, Lawful Business Practises.
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Saxon:evaluate in another context.

David Carlisle

>  <xsl:variable name="result">
>   <xsl:for-each select="$currentNode">
>    <xsl:value-of select="saxon:evaluate($aXPath)"/>
>   </xsl:for-each>
>  </xsl:variable>
> Unfortunately, the $result variable does not contain the
> nodes

Note that (in xslt1) value-of always gives the string value of the first
node that is selected, so the above (whatever saxon:evaluate returns)
will make $result into a result tree fragment that represents a single
document node with (at most) a single text node child, and no elements.

perhaps you want copy-of not value-of ?

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Saxon:evaluate in another context.

Michael Kay
The originator has sent me the full stylesheet for investigation, and I
think the intent was probably:

<xsl:variable name="result" select="$currentNode/saxon:evaluate($aXPath)"/>

or equivalently,

<xsl:variable name="result" as="element()*">
  <xsl:for-each select="$currentNode">
    <xsl:sequence select="saxon:evaluate($aXPath)"/>
  </xsl:for-each>
</xsl:variable>

I don't know how you would achieve this effect in XSLT 1.0!

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> David Carlisle
> Sent: 29 September 2005 14:06
> To: [hidden email]
> Subject: Re: [saxon] Saxon:evaluate in another context.
>
>
> >  <xsl:variable name="result">
> >   <xsl:for-each select="$currentNode">
> >    <xsl:value-of select="saxon:evaluate($aXPath)"/>
> >   </xsl:for-each>
> >  </xsl:variable>
> > Unfortunately, the $result variable does not contain the
> > nodes
>
> Note that (in xslt1) value-of always gives the string value
> of the first
> node that is selected, so the above (whatever saxon:evaluate returns)
> will make $result into a result tree fragment that represents a single
> document node with (at most) a single text node child, and no
> elements.
>
> perhaps you want copy-of not value-of ?
>
> David
>
> ______________________________________________________________
> __________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ______________________________________________________________
> __________
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Saxon:evaluate in another context.

ROSSEL, Olivier (CIMPA)
In reply to this post by ROSSEL, Olivier (CIMPA)

question about your first solution:
what happens if the $aXPath contains
'/rootElement'.

will saxon resolve /rootElement in the $currentNode
context, or $currentNode//rootElement ?


-----Message d'origine-----
De : [hidden email]
[mailto:[hidden email]]De la part de Michael Kay
Envoyé : jeudi 29 septembre 2005 19:08
À : [hidden email]
Cc : ROSSEL, Olivier (CIMPA)
Objet : RE: [saxon] Saxon:evaluate in another context.



The originator has sent me the full stylesheet for investigation, and I
think the intent was probably:

<xsl:variable name="result" select="$currentNode/saxon:evaluate($aXPath)"/>

or equivalently,

<xsl:variable name="result" as="element()*">
  <xsl:for-each select="$currentNode">
    <xsl:sequence select="saxon:evaluate($aXPath)"/>
  </xsl:for-each>
</xsl:variable>

I don't know how you would achieve this effect in XSLT 1.0!

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> David Carlisle
> Sent: 29 September 2005 14:06
> To: [hidden email]
> Subject: Re: [saxon] Saxon:evaluate in another context.
>
>
> >  <xsl:variable name="result">
> >   <xsl:for-each select="$currentNode">
> >    <xsl:value-of select="saxon:evaluate($aXPath)"/>
> >   </xsl:for-each>
> >  </xsl:variable>
> > Unfortunately, the $result variable does not contain the
> > nodes
>
> Note that (in xslt1) value-of always gives the string value
> of the first
> node that is selected, so the above (whatever saxon:evaluate returns)
> will make $result into a result tree fragment that represents a single
> document node with (at most) a single text node child, and no
> elements.
>
> perhaps you want copy-of not value-of ?
>
> David
>
> ______________________________________________________________
> __________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ______________________________________________________________
> __________
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.


This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Saxon:evaluate in another context.

Michael Kay
/rootElement selects the outermost element of the document containing the
context node - it's relative to the context node just like any other path
expression, except that it starts by going up to the root.

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> ROSSEL, Olivier (CIMPA)
> Sent: 30 September 2005 09:36
> To: [hidden email]
> Subject: RE: [saxon] Saxon:evaluate in another context.
>
>
> question about your first solution:
> what happens if the $aXPath contains
> '/rootElement'.
>
>
> will saxon resolve /rootElement in the $currentNode
> context, or $currentNode//rootElement ?
>
>
> -----Message d'origine-----
> De : [hidden email]
> [mailto:[hidden email]]De la part de
> Michael Kay
> Envoyé : jeudi 29 septembre 2005 19:08
> À : [hidden email]
> Cc : ROSSEL, Olivier (CIMPA)
> Objet : RE: [saxon] Saxon:evaluate in another context.
>
>
>
> The originator has sent me the full stylesheet for
> investigation, and I
> think the intent was probably:
>
> <xsl:variable name="result"
> select="$currentNode/saxon:evaluate($aXPath)"/>
>
> or equivalently,
>
> <xsl:variable name="result" as="element()*">
>   <xsl:for-each select="$currentNode">
>     <xsl:sequence select="saxon:evaluate($aXPath)"/>
>   </xsl:for-each>
> </xsl:variable>
>
> I don't know how you would achieve this effect in XSLT 1.0!
>
> Michael Kay
> http://www.saxonica.com/
>
>
> > -----Original Message-----
> > From: [hidden email]
>
> > [mailto:[hidden email]] On Behalf Of
>
> > David Carlisle
> > Sent: 29 September 2005 14:06
> > To: [hidden email]
> > Subject: Re: [saxon] Saxon:evaluate in another context.
> >
>
> >
>
> > >  <xsl:variable name="result">
> > >   <xsl:for-each select="$currentNode">
> > >    <xsl:value-of select="saxon:evaluate($aXPath)"/>
> > >   </xsl:for-each>
> > >  </xsl:variable>
> > > Unfortunately, the $result variable does not contain the
> > > nodes
>
> >
>
> > Note that (in xslt1) value-of always gives the string value
>
> > of the first
> > node that is selected, so the above (whatever
> saxon:evaluate returns)
> > will make $result into a result tree fragment that
> represents a single
> > document node with (at most) a single text node child, and no
>
> > elements.
> >
>
> > perhaps you want copy-of not value-of ?
> >
>
> > David
> >
>
> > ______________________________________________________________
> > __________
> > This e-mail has been scanned for all viruses by Star. The
> > service is powered by MessageLabs. For more information on
> a proactive
> > anti-virus service working around the clock, around the
> globe, visit:
> > http://www.star.net.uk
> > ______________________________________________________________
> > __________
> >
>
> >
>
> > -------------------------------------------------------
> > This SF.Net email is sponsored by:
> > Power Architecture Resource Center: Free content, downloads,
>
> > discussions,
> > and more. http://solutions.newsforge.com/ibmarch.tmpl
> > _______________________________________________
> > saxon-help mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
> >
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> This mail has originated outside your organization,
> either from an external partner or the Global Internet.
> Keep this in mind if you answer this message.
>
>
>
> This e-mail is intended only for the above addressee. It may contain
> privileged information. If you are not the addressee you must
> not copy,
> distribute, disclose or use any of the information in it. If you have
> received it in error please delete it and immediately notify
> the sender.
> Security Notice: all e-mail, sent to or from this address, may be
> accessed by someone other than the recipient, for system
> management and
> security reasons. This access is controlled under Regulation of
> Investigatory Powers Act 2000, Lawful Business Practises.
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Loading...