xsl-list
[Top] [All Lists]

RE: dynamic variable name/implementation question

2005-08-26 08:55:03
ok.  I see.
My goal here is to be able to pass in dynamic data to a transformation
that is part of a web application.  I was just using xalan to unit test
the exsl:node-set(), but am using php/sablotron for the app.  Does
anyone know of a way to get dynamic run-time data into a stylesheet
using php/sablotron?  That is, without the stylesheet knowing the name
of the parameter, but rather can be specified in the source document?
I don't beleive using the document() function would work to retrive the
result of a php script as XML, because calling a php page from within
sablotron would probably just return the source, not the executed
output, correct?

-------- Original Message --------
Subject: RE: [xsl] dynamic variable name/implementation question
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Date: Fri, August 26, 2005 10:31 am
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>

The exsl:node-set() function converts a result tree fragment to a node-set,
it doesn't parse source XML to create a document node.

The simplest (most standard) approach if you're invoking the transformation
from the command line is probably to put the XML in a file, pass the URI of
that file as a stylesheet parameter, and then load the document from within
the stylesheet using the document() function.

In Saxon you could pass the parameter as +parameters=doc.xml, the "+" sign
would cause the contents of the file doc.xml to be parsed, and the resulting
document node would be the value of the parameter. AFAIK Xalan has no
equivalent mechanism.

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

-----Original Message-----
From: Ed S [mailto:lists(_at_)highpeakssoftware(_dot_)com] 
Sent: 26 August 2005 15:11
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] dynamic variable name/implementation question



 
The usual solution is that instead of passing your stylesheet three
parameters x, y, and z, you should pass it an XML document 

<param>
  <x>1</x>
  <y>2</y>
  <z>3</z>
</param>

and then you can navigate this document at will using XPath.

I'm having a bit of trouble doing this.
I'm running xalan as follows:
java org.apache.xalan.xslt.Process -IN ext.xml -OUT 
ext_out.xml -XSL ext.xsl -PARAM parameters 
"<param-list><a>hello</a><b>goodbye</b></param-list>"

however, when I execute:
<xsl:value-of select="exsl:node-set($parameters)"/>
I would expect to get the values of all of the text nodes within, ie:
hellogoodbye

however, $parameters is resolved as a string:
&lt;param-list&gt;&lt;a&gt;hello&lt;/a&gt;&lt;b&gt;goodbye&lt;
/b&gt;&lt;/param-list&gt;

Maybe I don't understand the purpose of node-set()...


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


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