all groups > dotnet xml > february 2005 >
You're in the

dotnet xml

group:

with-param not working in XSLT


with-param not working in XSLT indyjones48 NO[at]SPAM yahoo.com
2/25/2005 8:28:01 AM
dotnet xml:
Hi,

I'm using msxml4 sp1 to transform some xml. My template looks like
this:

<xsl:call-template name="rowCounter">
<xsl:with-param name="max_cols" select="2"/>
<xsl:with-param name="N" select="1"/>
</xsl:call-template>

<xsl:template name="rowCounter">
<xsl:param name="max_cols"/>
<xsl:param name="N"/>
<!-- If there are any entries in any section
with a position number of $N then we produce a
new table row -->
param:<xsl:value-of select="$N"/>
</xsl:template>

The N value shows up empty in the resulting output. I've had this same
trouble with with-param for the last 6 months -- just never REALLY
needed to have it work, so I found ways to work around it.

Now, though, I need it. Any ideas, why it's not working? Thx in
advance.
Re: with-param not working in XSLT indyjones48 NO[at]SPAM yahoo.com
2/25/2005 10:51:40 AM
Hi Martin,

Thanks for the response. If you look at the template, there's really
no XML involved. Obviously, there's an XML source, but it's not
relevant to the calling of the template.

This section:
<xsl:template name="rowCounter">
<xsl:param name="max_cols"/>
<xsl:param name="N"/>
<!-- If there are any entries in any section
with a position number of $N then we produce a
new table row -->
param:<xsl:value-of select="$N"/>
</xsl:template>

outputs

param:

It should output

param:1

For some reason I can't understand, the <with-param> value is getting
dropped.

Unfortunately, it *is* an msxml parser 4.x issue, as I copied this
snippet from others in a different group who used it successfully with
a different parser. Also, I've used msxml3.0 in the past, and have
used <with-param> with success.

One other thing to note, is that I'm using old-school:

xmlDOC.transformNode(xsltDoc)

to perform the transform, where xmlDoc is a DOMDocument.4.0

The parser is msxml4.dll sp1.

Best
Re: with-param not working in XSLT Martin Honnen
2/25/2005 5:53:36 PM


[quoted text, click to view]


[quoted text, click to view]

Can you show us more context, show us a minimal XML input and minimal
stylesheet where that stuff fails. But you might want to do that in the
xsl group as your question is not related to .NET.


--

Martin Honnen
Re: with-param not working in XSLT _AnonCoward
2/25/2005 10:17:06 PM

[quoted text, click to view]
: Hi,
:
: I'm using msxml4 sp1 to transform some xml. My template looks like
: this:
:
: <xsl:call-template name="rowCounter">
: <xsl:with-param name="max_cols" select="2"/>
: <xsl:with-param name="N" select="1"/>
: </xsl:call-template>
:
: <xsl:template name="rowCounter">
: <xsl:param name="max_cols"/>
: <xsl:param name="N"/>
: <!-- If there are any entries in any section
: with a position number of $N then we produce a
: new table row -->
: param:<xsl:value-of select="$N"/>
: </xsl:template>
:
: The N value shows up empty in the resulting output. I've had this
: same trouble with with-param for the last 6 months -- just never
: REALLY needed to have it work, so I found ways to work around it.
:
: Now, though, I need it. Any ideas, why it's not working? Thx in
: advance.


I tested this with my msxml4 parser (SP 1) and I'm not seeing the
problem.


XML: (filename: data.xml)
<DATA/>

XSL: (filename: xform.xsl)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/DATA">
<xsl:element name="OUTPUT">
<xsl:call-template name="rowCounter">
<xsl:with-param name="N" select="1"/>
</xsl:call-template>
</xsl:element>
</xsl:template>

<xsl:template name="rowCounter">
<xsl:param name="max_cols"/>
<xsl:param name="N"/>
param: <xsl:value-of select="$N"/>
</xsl:template>
</xsl:stylesheet>

Test Code: (filename: test.vbs)
dim xml
dim xsl
Dim s

set xml = createobject("MSXML2.DOMDocument.4.0")
set xsl = createobject("MSXML2.DOMDocument.4.0")

xml.load("data.xml")
xsl.load("xform.xsl")

s = xml.transformnode(xsl)
createObject("Scripting.FileSystemObject").CreateTextFile( _
"output.xml").Write(s)

Output:
<?xml version="1.0"?><OUTPUT>
param: 1</OUTPUT>

Ralf

Re: with-param not working in XSLT Martin Honnen
2/26/2005 2:18:50 PM


[quoted text, click to view]


[quoted text, click to view]


[quoted text, click to view]

Still don't see why you post in dotnet.xml then but as you do not
provide a test case I have made one:

minimal XSLT stylesheet is

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

<xsl:output method="text" />

<xsl:template match="/">
<xsl:call-template name="rowCounter">
<xsl:with-param name="max_cols" select="2"/>
<xsl:with-param name="N" select="1"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="rowCounter">
<xsl:param name="max_cols"/>
<xsl:param name="N"/>
<!-- If there are any entries in any section
with a position number of $N then we produce a
new table row -->
param:<xsl:value-of select="$N"/>
</xsl:template>

</xsl:stylesheet>

JScript program to test is:

var dummyXMLSource = '<root />';

var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.4.0');
xmlDocument.async = false;
xmlDocument.loadXML(dummyXMLSource);

var xslDocument = new ActiveXObject('Msxml2.DOMDocument.4.0');
xslDocument.async = false;
xslDocument.load('test2005022602Xsl.xml');

alert(xmlDocument.transformNode(xslDocument))

That program shows
param:1

so I can't reproduce the problem.

--

Martin Honnen
AddThis Social Bookmark Button