xsl-list
[Top] [All Lists]

RE: Variable assignment outside XSL

2003-02-03 11:06:04
Delaney Robin wrote:
Is it possible to assign variables outside of XSL which can be accessed
from
within (during transformation).

Not using system variables, like in a shell script or .bat file.

... skipping to the bottom ...
Or is there
any suggested method to pass info into XSL ?

Yes, you are looking for parameter semantics (<xsl:param>), but the usage is
context-specific.

... skipping back to where we were ...
I need to create extra elements in an XML
file  to hold values like date-time, username, filename(can I get this
from
document()?), servername etc...........

Use this syntax inside the XSLT source:

    <xsl:transform ....>
        <xsl:param name="date-time"/>
        <xsl:param name="username"/>
        <xsl:param name="filename"/>
        <xsl:param name="servername"/>

        .... rest of transform goes here ....

    </xsl:transform>

Outside the transform syntax for passing in parameters varies according to
vendor and execution context.  For example, in Xalan-J, using the java
executable class "Process", you would write a command line something like
this (pardon the long line overflow):

    java org.apache.xalan.xslt.Process -IN file.xml -XSL trans.xsl -PARAM
date-time "2003-02-03T11:35" -PARAM username roger -PARAM filename
file.xml -PARAM servername hikimi

On the other hand, if you were running the transformation from within a java
program, adding the parameters would look something like this:

    javax.xml.transform.Transformer transformer;

    ... other code to instantiate and configure "transformer" omitted ...

    transformer.setParameter("date-time", "2003-02-03T11:35");
    transformer.setParameter("username", "roger");
    transformer.setParameter("filename", "file.xml");
    transformer.setParameter("servername", "hikimi");


I hope this helps!

-- Roger Glover
   glover_roger(_at_)yahoo(_dot_)com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>