467,225 Members | 1,353 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

<xsl:apply-templates> not returning a node-set???

Hi

I've made a stylesheet to transform my data into XSL-FO. This
stylesheet used to work with MSXSL 4.0 but I've got some issues in
..NET. First, I changed removed all the "node-set()" function since
they're not used anymore. But now, I used an <xsl:apply-templates/>
and for some reason, it works in some situation but not in others. I
didn't put the whole XSL file since it's quite big. Here's the part
that bugs

<xsl:template match="Status">
<xsl:variable name="Position">
<xsl:number count="/Cahier/*[name()!='Information']"/>
</xsl:variable>
<xsl:element name="fo:block">
<xsl:if test="not($Position=1 and position()=1)">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:if>
<fo:marker marker-class-name="Status-Number">Status <xsl:value-of
select="../Status/@ID"/></fo:marker>
<fo:marker marker-class-name="Status-Name">Allo</fo:marker>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

And here's a sample of the XML going throught it:

<Cahier>
<Actives>
<Status ID="1">
<Name>Actif</Name>
<Participant>
<NAS>123456789</NAS>
<Name>
<Surname>John</Surname>
<Given>Doe</Given>
</Name>
<DOB>1944-09-23T12:00:00</DOB>
<Province />
<SpouseName>
<Surname>Johanne</Surname>
<Given>Doe</Given>
</SpouseName>
<Sexe>1</Sexe>
<DOBduConjoint />
</Participant>
<Participant>
....
</Participant>
</Status>
</Actives>
</Cahier>

So the "apply-templates" tag continu the process to the <Name> and
<Participant> tags but for some reason, I get an "The expression
passed to this method should result in a NodeSet." exception. I
thought it might be my templates for the above mention tags but I
folow my XmlReader step by step and it really stop right there and I
don't see what's wrong with my XSLT. And both XML and XSLT file are
properly formed. Anybody got an idea?

Thx
Blaise Garant
Nov 12 '05 #1
  • viewed: 2853
Share:
3 Replies
Blaise Garant wrote:
I've made a stylesheet to transform my data into XSL-FO. This
stylesheet used to work with MSXSL 4.0 but I've got some issues in
.NET. First, I changed removed all the "node-set()" function since
they're not used anymore.
Could you elaborate this point? There is no any difference between MSXML
and .NET with regard to node-set() extension function. If you use in in
MSML stylesheet, you have to continue use it in .NET.
So the "apply-templates" tag continu the process to the <Name> and
<Participant> tags but for some reason, I get an "The expression
passed to this method should result in a NodeSet." exception.


I don't believe <xsl:apply-templates/> instruction may cause this
exception. Chances are it's connected with node-set() function you have
removed - it converts a result tree fragment to a nodeset.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
Thx for your fast answer Oleg,

"Oleg Tkachenko [MVP]" <oleg@no_!spam!_please!tkachenko.com> wrote in message news:<ua**************@TK2MSFTNGP09.phx.gbl>...
Blaise Garant wrote:
I've made a stylesheet to transform my data into XSL-FO. This
stylesheet used to work with MSXSL 4.0 but I've got some issues in
.NET. First, I changed removed all the "node-set()" function since
they're not used anymore.
Could you elaborate this point? There is no any difference between MSXML
and .NET with regard to node-set() extension function. If you use in in
MSML stylesheet, you have to continue use it in .NET.


Well, it doesn't seem like it. See, in my XML sample, <Cahier> is in
fact a childnode to <Booklet>. So at the begining of the stylesheet I
made a global variable: <xsl:variable name="MemberInfo"
select="/Booklet/Cahier"/>. Now if I use <xsl:value-of
select="$MemberInfo/Actives/Status/Participant/NAS"> I get the value
of the NAS node of the first Participant node, just like I should
expect (in that sample, 123456789). Now this was impossible with
MSXML, I need the node-set() function to do this. Also, now as soon as
I use node-set(), I get a "Function 'msxsl:node-set()' has failed."
exception.
So the "apply-templates" tag continu the process to the <Name> and
<Participant> tags but for some reason, I get an "The expression
passed to this method should result in a NodeSet." exception.


I don't believe <xsl:apply-templates/> instruction may cause this
exception. Chances are it's connected with node-set() function you have
removed - it converts a result tree fragment to a nodeset.

Ok, you're right, they are partly connected. I use my XMLReader to
read the output line by line. Everything goes well up to that point.
I've got a template for a match with a Participant node, starting with
variables. So I put a empty node just for a test and so, it stop just
after it so you're right, <xsl:apply-templates/> is not the problem.
Here's another XSLT sample:

-------------XSLT---------------
<xsl:template match="Participant">
<xsl:variable name="TemplateType">
<xsl:value-of select="name(parent::*/parent::*)"/>
</xsl:variable>

<test><xsl:value-of
select="msxsl:node-set($TemplateType)"/></test>

<xsl:variable name="BiggerCol">
<xsl:variable name="Sub">
<xsl:for-each
select="$LayoutInfo/Booklet_Definition/child::*[name()=$TemplateType]/Member/Column">
<xsl:element name="Column">
<xsl:element name="ColumnLen"><xsl:value-of
select="count(child::Element)"/></xsl:element>
<xsl:element name="Position"><xsl:value-of
select="position()"/></xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:variable>
.....
</xsl:template>
----------------------------
So it seems the program stoped while doing the BiggerCol variable node
(before I put the <test> node). With the <test> node the program bugs
at the <xsl:value-of> node. $TemplateType should contain the value
"Actives" but the call <xsl:value-of select="$TemplateType" seems now
to be waiting for a node-set! So as you see, I've try <xsl:value-fo
select="msxsl:node-set($TemplateType)/> But I get the same error
(curriously, not the "node-set() failed" exception).

Got an idea?
Blaise
Nov 12 '05 #3
Blaise Garant wrote:
expect (in that sample, 123456789). Now this was impossible with
MSXML, I need the node-set() function to do this. I don't think so if you are talking about MSXML3 and MSXML4. They are as
good as .NET. You don't need node-set() extension function to navigate
over nodes-set bound variable. You need it to navigate over
result-tree-fragment bound variable though (xsl:variable with no select
attribute).
-------------XSLT---------------
<xsl:template match="Participant">
<xsl:variable name="TemplateType">
<xsl:value-of select="name(parent::*/parent::*)"/>
</xsl:variable>

<test><xsl:value-of
select="msxsl:node-set($TemplateType)"/></test>

<xsl:variable name="BiggerCol">
<xsl:variable name="Sub">
<xsl:for-each
select="$LayoutInfo/Booklet_Definition/child::*[name()=$TemplateType]/Member/Column">
<xsl:element name="Column">
<xsl:element name="ColumnLen"><xsl:value-of
select="count(child::Element)"/></xsl:element>
<xsl:element name="Position"><xsl:value-of
select="position()"/></xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:variable>
....
</xsl:template>
----------------------------
So it seems the program stoped while doing the BiggerCol variable node
(before I put the <test> node). With the <test> node the program bugs
at the <xsl:value-of> node. $TemplateType should contain the value
"Actives" but the call <xsl:value-of select="$TemplateType" seems now
to be waiting for a node-set! So as you see, I've try <xsl:value-fo
select="msxsl:node-set($TemplateType)/> But I get the same error
(curriously, not the "node-set() failed" exception).

Got an idea?


<xsl:value-of> doesn't care about argument type. It can outbut both
node-set and rtf. What kind of error do you get?

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by kmunderwood@charter.net | last post: by
4 posts views Thread by Invalidlastname | last post: by
6 posts views Thread by tentstitcher@gmail.com | last post: by
2 posts views Thread by Paul Verbelen | last post: by
1 post views Thread by the_dog_gabby@yahoo.com | last post: by
1 post views Thread by andrew_nuss@yahoo.com | last post: by
reply views Thread by Adict | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.