Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Passing a parameter to .XSL file (http://www.velocityreviews.com/forums/t601400-passing-a-parameter-to-xsl-file.html)

Stu 03-24-2008 08:48 PM

Passing a parameter to .XSL file
 
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. Bolmarcich 03-24-2008 09:51 PM

Re: Passing a parameter to .XSL file
 
On 2008-03-24, Stu <beefstu350@hotmail.com> 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


Hermann Peifer 03-24-2008 09:51 PM

Re: Passing a parameter to .XSL file
 
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


Stu 03-25-2008 02:05 PM

Re: Passing a parameter to .XSL file
 
On Mar 24, 5:51*pm, Hermann Peifer <pei...@gmx.eu> 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


All times are GMT. The time now is 08:50 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.