Quantcast

Passing node as a parameter of $paramters set to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?)

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

Passing node as a parameter of $paramters set to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?)

kyung88
One of parameters that I am going to pass to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?) function is a node, but when I retrieve it from xsl file, it seems a string. So, I am having problem with applying xpath to that paramter. Any ideas? By the way, I am using xsl 2.0

Thanks.

Gina
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Passing node as a parameter of $paramters set to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?)

kyung88
I looked at org.exist.xquery.functions.transform.Transform.java class the following is how parameters are get parsed. Since we get String value of a parameter, we can't get node back from xsl file. We only can pass String parameters to transform:transform function.

        private void parseParameters(Properties properties, Node options) throws XPathException {
                if(options.getNodeType() == Node.ELEMENT_NODE && options.getLocalName().equals("parameters")) {
                        Node child = options.getFirstChild();
                        while(child != null) {
                                if(child.getNodeType() == Node.ELEMENT_NODE && child.getLocalName().equals("param")) {
                                        Element elem = (Element)child;
                                        String name = elem.getAttribute("name");
                                        String value = elem.getAttribute("value");
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Passing node as a parameter of $paramters set to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?)

Adam Retter
Yes that is indeed the case, the problem is that there is no real
support in the xquery language to enable passing arbitary nodes as a
single parameter, because once you encapsulate them inside another
node you loose their meaning. The XQuery WG is wrestling with this at
the moment whilst trying to standardise a transform function for
XQuery 3.

In the mean time in eXist-db the best approach is to send the node
inside the content by putting a wrapper around it, and making some
very minor changes to your XSLT -e.g.

transform:transform(<wrapper>{$some-param}{$content}</wrapper>, $xslt, ())



On 26 August 2011 20:26, kyung88 <[hidden email]> wrote:

> I looked at org.exist.xquery.functions.transform.Transform.java class the
> following is how parameters are get parsed. Since we get String value of a
> parameter, we can't get node back from xsl file. We only can pass String
> parameters to transform:transform function.
>
>        private void parseParameters(Properties properties, Node options) throws
> XPathException {
>                if(options.getNodeType() == Node.ELEMENT_NODE &&
> options.getLocalName().equals("parameters")) {
>                        Node child = options.getFirstChild();
>                        while(child != null) {
>                                if(child.getNodeType() == Node.ELEMENT_NODE &&
> child.getLocalName().equals("param")) {
>                                        Element elem = (Element)child;
>                                        String name = elem.getAttribute("name");
>                                        String value = elem.getAttribute("value");
>
> --
> View this message in context: http://exist.2174344.n4.nabble.com/Passing-node-as-a-parameter-of-paramters-set-to-transform-transform-node-tree-as-node-stylesheet-as--tp3771581p3771656.html
> Sent from the exist-open mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management
> Up to 160% more powerful than alternatives and 25% more efficient.
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>



--
Adam Retter

eXist Developer
{ United Kingdom }
[hidden email]
irc://irc.freenode.net/existdb

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Passing node as a parameter of $paramters set to transform:transform($node-tree as node()*, $stylesheet as item(), $parameters as node()?)

kyung88
Thanks Adam. I orginally used Wrapper to include two nodes that I need to pass in as arguments, but instead of using Wrapper passing node as a parameter is cleaner. XSLT2.0 supports applying xpath to node. It would be great in the future we can pass node to transform:transform function.

Thanks.

Gina
Loading...