469,356 Members | 2,013 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Problem using msxsl:node-set with xsl:param

ipg
I am running into issues passing a parameter (that is a XML string)
into a stylesheet and using msxsl:node-set to parse the string. Can
someone please explain why.

my html:
var xsl = new ActiveXObject("MSXML2.FreeThreadedDomDocument.3.0" );
xsl.async = false;
xsl.load("campaignHtml.xsl");
var template = new ActiveXObject("MSXML2.XSLTemplate");
template.stylesheet = xsl;
processor = template.createProcessor();
processor.input = xmlDocument;
processor.addParameter(
"conferenceDocument"
,xmlConferenceDocument.documentElement.xml);
processor.transform();
============================================

my xsl:

<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
version="1.1">
<xsl:output method="html" indent="yes"/>

<xsl:param name="conferenceDocument" select="."/>

<!-- the function does not return anything when a parameter is used
-->
<xsl:value-of select=
"msxsl:node-set($conferenceDocument)/ROWSET/ROW/CONFERENCE_CODE" />

....

==============================================

<!-- However when I print the parameter to screen and hardcode the
screen output into a variable tag, the function works fine. -->

<xsl:variable name="conferenceDocument">
<ROWSET><ROW><CONFERENCE_ID>1</CONFERENCE_ID><CONFERENCE_CODE>SEC</CONFERENCE_CODE><CONFERENCE_NAME>Southeastern
Conference</CONFERENCE_NAME></ROW><ROW><CONFERENCE_ID>622</CONFERENCE_ID><CONFERENCE_CODE>NONE</CONFERENCE_CODE><CONFERENCE_NAME>Unassigned</CONFERENCE_NAME></ROW><ROW><CONFERENCE_ID>111</CONFERENCE_ID><CONFERENCE_CODE>ACC</CONFERENCE_CODE><CONFERENCE_NAME>Atlantic
Collegiate Conference</CONFERENCE_NAME></ROW><ROW><CONFERENCE_ID>324</CONFERENCE_ID><CONFERENCE_CODE>B12</CONFERENCE_CODE><CONFERENCE_NAME>Big
XII</CONFERENCE_NAME></ROW></ROWSET>
</xsl:variable>

<xsl:value-of select=
"msxsl:node-set($conferenceDocument)/ROWSET/ROW/CONFERENCE_CODE" />

==================================================

Can someone please explain why. Why is the parameter not being
evaluated like the text written between the var tags above. Please
enlighten me. I have spent 2 days on this.

Thanks,
Patrick
Jul 20 '05 #1
5 8343
ipg wrote:
processor.addParameter(
"conferenceDocument"
,xmlConferenceDocument.documentElement.xml);

Why don't you pass xmlConferenceDocument.documentElement as is? Isn't it weird
to serialize document to string just to pass it to XSLT and then parse it back
again?
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Jul 20 '05 #2
"Dimitre Novatchev" <dn********@yahoo.com> wrote:
Two things:

1. The xxx:node-set() extension function does not parse a string. A string
is not an RTF (Result Tree Fragment). An RTF is a tree of nodes.

2. You should pass as parameter the node-set itself, which you have already
parsed (xmlConferenceDocument.documentElement) and not its string
representation. Then you do not need xxx:node-set() at all, the parameter is
a node-set -- not an RTF.


What's the difference between a "tree of nodes", then, and a
"node-set"?
Jul 20 '05 #3
Mark Johnson wrote:
What's the difference between a "tree of nodes", then, and a
"node-set"?

The difference between result-tree fragment and nodeset:
http://www.w3.org/TR/xslt.html#secti...Tree-Fragments
It's only XSLT 1.0 related data type, XSLT 1.1 and 2.0 managed to get rid of it.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Jul 20 '05 #4
Oleg Tkachenko <oleg@NO_SPAM_PLEASEtkachenko.com> wrote:
Mark Johnson wrote:
What's the difference between a "tree of nodes", then, and a
"node-set"?

The difference between result-tree fragment and nodeset:
http://www.w3.org/TR/xslt.html#secti...Tree-Fragments
Doesn't really say what it is, though. It mentions vague - extension
functions - from a small section further on. But I assume a result
fragment is a node-set representation of part of the result of the
xslt transform. And a node-set, generally, is the subset of the XML as
returned by an XPath expr.

It's only XSLT 1.0 related data type, XSLT 1.1 and 2.0 managed to get rid of it.


So there's only - node-set. I've seen various articles of yours, say
at MSDN. You've been referring to a proposed 2.0. Is it available? Is
it part of an msxml 4? 5?

Jul 20 '05 #5
Mark Johnson wrote:
Doesn't really say what it is, though. It mentions vague - extension
functions - from a small section further on. But I assume a result
fragment is a node-set representation of part of the result of the
xslt transform. And a node-set, generally, is the subset of the XML as
returned by an XPath expr. Well, that's not quite clean explanation too. RTF is actually just a temporary
tree. The only way to produce it is using a variable. Variable is bound to RTF
if it has any content (hence doesn't have select attribute). The same goes for
xsl:param and xsl:with-param actually:
<xsl:variable name="rtf">
<a>foo</a>
</xsl:variable>
It's called result-tree fragment, becuase all you can do with it is to copy it
out (usually to the result tree) either by xsl:value-of or xsl:copy-of.
So there's only - node-set. I've seen various articles of yours, say
at MSDN. You've been referring to a proposed 2.0. Is it available? Is
it part of an msxml 4? 5?

It's still working draft and there is no MS implementation yet. I'm aware of
the only experimental XSLT2.0 impl - Saxon 7.X.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by darkstorm | last post: by
1 post views Thread by darkstorm | last post: by
7 posts views Thread by Tim.D | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.