Passing a parameter to .XSL file

S

Stu

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

A. Bolmarcich

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
 
H

Hermann Peifer

Stu said:
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,
 
S

Stu

Stu said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top