Passing a parameter to .XSL file

Discussion in 'XML' started by Stu, Mar 24, 2008.

  1. Stu

    Stu Guest

    I am using libxml2 xsltproc and I am trying to pass a parameter and
    have not been successful yet.

    I tried a million and one variations of the following command but was
    unable to get the value passed in from the command line to be
    substituted correctly. Can somebody please point me in the right
    directiuon.

    Thanks in advance to all who answer this post

    command
    ========
    xsltproc.exe --param data_path2, "'e:/tmp/stu/123'" dbmap.xsl
    dbmap.xml

    My .xsl file looks like this:
    ===================

    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:param name="data_path2" select = "'UNDEFINED'"/>

    <xsl:template match="@* | node()">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </xsl:template>

    <xsl:template match="actual_volume[. = '{VAR}' and ../
    logical_library/text(
    = 'DATA']">
    <xsl:copy>
    <xsl:value-of select="$data_path2"/>
    </xsl:copy>
    </xsl:template>

    Data file
    ======

    <dbmap_entries>
    <dbmap_entry>
    <logical_library>&amp;TMP</logical_library>
    <actual_library>.</actual_library>
    <actual_volume>CTRONTMPDIR</actual_volume>
    </dbmap_entry>
    <dbmap_entry>
    <logical_library>LOG</logical_library>
    <actual_library>logs</actual_library>
    <actual_volume>{VAR}</actual_volume>
    </dbmap_entry>
    <dbmap_entry>
    <logical_library>CONFIG</logical_library>
    <actual_library>config</actual_library>
    <actual_volume>${CTRONHOME}</actual_volume>
    </dbmap_entry>
    <dbmap_entry>
    <logical_library>DATA</logical_library>
    <actual_library>data</actual_library>
    <actual_volume>{VAR}</actual_volume>
    </dbmap_entry>
    <dbmap_entry>
    <logical_library>DB</logical_library>
    <actual_library>db</actual_library>
    <actual_volume>{VAR}</actual_volume>
    </dbmap_entry>
    </dbmap_entries>
     
    Stu, Mar 24, 2008
    #1
    1. Advertising

  2. On 2008-03-24, Stu <> wrote:
    > I am using libxml2 xsltproc and I am trying to pass a parameter and
    > have not been successful yet.
    >
    > I tried a million and one variations of the following command but was
    > unable to get the value passed in from the command line to be
    > substituted correctly. Can somebody please point me in the right
    > directiuon.
    >
    > Thanks in advance to all who answer this post
    >
    > command
    >========
    > xsltproc.exe --param data_path2, "'e:/tmp/stu/123'" dbmap.xsl
    > dbmap.xml


    What happens if you use

    xsltproc.exe --param data_path2 "'e:/tmp/stu/123'" dbmap.xsl dbmap.xml

    without the "," at the end of "data_path2,"? Another concern is
    whether the command processor that is being used removes the double
    quote marks from the argument value presented to the executable. If
    it does not, try

    xsltproc.exe --param data_path2 'e:/tmp/stu/123' dbmap.xsl dbmap.xml
     
    A. Bolmarcich, Mar 24, 2008
    #2
    1. Advertising

  3. Stu wrote:
    > I am using libxml2 xsltproc and I am trying to pass a parameter and
    > have not been successful yet.
    >
    > I tried a million and one variations of the following command but was
    > unable to get the value passed in from the command line to be
    > substituted correctly. Can somebody please point me in the right
    > directiuon.
    >
    > Thanks in advance to all who answer this post
    >
    > command
    > ========
    > xsltproc.exe --param data_path2, "'e:/tmp/stu/123'" dbmap.xsl
    > dbmap.xml
    >
    > My .xsl file looks like this:
    > ===================
    >
    > <xsl:stylesheet
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > version="1.0">
    >
    > <xsl:param name="data_path2" select = "'UNDEFINED'"/>
    >
    > <xsl:template match="@* | node()">
    > <xsl:copy>
    > <xsl:apply-templates select="@* | node()"/>
    > </xsl:copy>
    > </xsl:template>
    >
    > <xsl:template match="actual_volume[. = '{VAR}' and ../
    > logical_library/text(
    > = 'DATA']">
    > <xsl:copy>
    > <xsl:value-of select="$data_path2"/>
    > </xsl:copy>
    > </xsl:template>
    >
    > Data file
    > ======
    >
    > <dbmap_entries>
    > <dbmap_entry>
    > <logical_library>&amp;TMP</logical_library>
    > <actual_library>.</actual_library>
    > <actual_volume>CTRONTMPDIR</actual_volume>
    > </dbmap_entry>
    > <dbmap_entry>
    > <logical_library>LOG</logical_library>
    > <actual_library>logs</actual_library>
    > <actual_volume>{VAR}</actual_volume>
    > </dbmap_entry>
    > <dbmap_entry>
    > <logical_library>CONFIG</logical_library>
    > <actual_library>config</actual_library>
    > <actual_volume>${CTRONHOME}</actual_volume>
    > </dbmap_entry>
    > <dbmap_entry>
    > <logical_library>DATA</logical_library>
    > <actual_library>data</actual_library>
    > <actual_volume>{VAR}</actual_volume>
    > </dbmap_entry>
    > <dbmap_entry>
    > <logical_library>DB</logical_library>
    > <actual_library>db</actual_library>
    > <actual_volume>{VAR}</actual_volume>
    > </dbmap_entry>
    > </dbmap_entries>
    >


    I would a) fix the stylesheet (see below) and b) run the command
    without comma.

    Quoting in Windows environment needs special attention. You might need
    some escape characters: \" or \' or something like this,


    > Premature end of data in tag stylesheet line 1


    > XPath error : Missing closing curly brace
    > . = '{VAR}' and ../logical_library/text(= 'DATA'
    > ^
    > compilation error: file dbmap.xsl line 13 element template
    > Failed to compile predicate
     
    Hermann Peifer, Mar 24, 2008
    #3
  4. Stu

    Stu Guest

    On Mar 24, 5:51 pm, Hermann Peifer <> wrote:
    > Stu wrote:
    > > I am using libxml2 xsltproc and I am trying to pass a parameter and
    > > have not been successful yet.

    >
    > > I tried a million and one variations of the following command but was
    > > unable to get the value passed in from the command line to be
    > > substituted correctly. Can somebody please point me in the right
    > > directiuon.

    >
    > > Thanks in advance to all who answer this post

    >
    > > command
    > > ========
    > > xsltproc.exe --param data_path2, "'e:/tmp/stu/123'" dbmap.xsl
    > > dbmap.xml

    >
    > > My .xsl file looks like this:
    > > ===================

    >
    > > <xsl:stylesheet
    > >    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > >    version="1.0">

    >
    > >    <xsl:param name="data_path2" select = "'UNDEFINED'"/>

    >
    > >    <xsl:template match="@* | node()">
    > >      <xsl:copy>
    > >        <xsl:apply-templates select="@* | node()"/>
    > >      </xsl:copy>
    > >    </xsl:template>

    >
    > >    <xsl:template match="actual_volume[. = '{VAR}' and ../
    > > logical_library/text(
    > > = 'DATA']">
    > >      <xsl:copy>
    > >        <xsl:value-of select="$data_path2"/>
    > >      </xsl:copy>
    > >    </xsl:template>

    >
    > > Data file
    > > ======

    >
    > > <dbmap_entries>
    > >         <dbmap_entry>
    > >             <logical_library>&amp;TMP</logical_library>
    > >             <actual_library>.</actual_library>
    > >             <actual_volume>CTRONTMPDIR</actual_volume>
    > >         </dbmap_entry>
    > >         <dbmap_entry>
    > >             <logical_library>LOG</logical_library>
    > >             <actual_library>logs</actual_library>
    > >             <actual_volume>{VAR}</actual_volume>
    > >         </dbmap_entry>
    > >         <dbmap_entry>
    > >             <logical_library>CONFIG</logical_library>
    > >             <actual_library>config</actual_library>
    > >             <actual_volume>${CTRONHOME}</actual_volume>
    > >         </dbmap_entry>
    > >         <dbmap_entry>
    > >             <logical_library>DATA</logical_library>
    > >             <actual_library>data</actual_library>
    > >             <actual_volume>{VAR}</actual_volume>
    > >         </dbmap_entry>
    > >         <dbmap_entry>
    > >             <logical_library>DB</logical_library>
    > >             <actual_library>db</actual_library>
    > >             <actual_volume>{VAR}</actual_volume>
    > >         </dbmap_entry>
    > > </dbmap_entries>

    >
    > I would a) fix the stylesheet (see below)  and b) run the command
    > without comma.
    >
    > Quoting in Windows environment needs special attention. You might need
    > some escape characters: \"  or \'  or something like this,
    >
    >  > Premature end of data in tag stylesheet line 1
    >
    >  > XPath error : Missing closing curly brace
    >  > . = '{VAR}' and ../logical_library/text(= 'DATA'
    >  >                                        ^
    >  > compilation error: file dbmap.xsl line 13 element template
    >  > Failed to compile predicate- Hide quoted text -
    >
    > - Show quoted text -


    This appears to work. Thanks all

    xsltproc.exe --param data_path2 "'e:/tmp/stu/xx'" dbmap.xsl dbmap.xml
     
    Stu, Mar 25, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Flood
    Replies:
    0
    Views:
    1,052
    Kevin Flood
    Sep 8, 2004
  2. Kevin Flood
    Replies:
    1
    Views:
    2,811
    Kevin Flood
    Sep 13, 2004
  3. Luke Airig
    Replies:
    1
    Views:
    1,138
    Ed Beroset
    Dec 29, 2003
  4. Replies:
    1
    Views:
    3,687
    A. Bolmarcich
    May 27, 2005
  5. Mister B
    Replies:
    8
    Views:
    599
    Nick Keighley
    Aug 26, 2010
Loading...

Share This Page