473,390 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

<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
3 3112
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kmunderwood | last post by:
I am trying to combine "if match=" and "when test" I am a newbie, and have made both work separately, but I can not seem to combine them. This is my xml("index.xml")page(I can not change this,...
4
by: Invalidlastname | last post by:
Hi, I have an XML document, created from ADO DataSet, which contains XML data in some nodes shown below: <NewDataSet> <Table> <field_name>My Selection</field_name>...
6
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an...
2
by: Paul Verbelen | last post by:
I have a file with topics. I like to copy them in another file but want to have some blank lines between the different topics. I use <xsl:text> element with as data some blank lines to perform...
1
by: the_dog_gabby | last post by:
Hello, I have a stylesheet that contains C# functions to generate XML. When I apply the stylesheet to my document, everything works perfectly except the data I get back is escaped like so: ...
0
by: Umagowder | last post by:
All I have my class serialised correctly. I have to apply style sheet to that data and display it in some other format. Everything works fine,I can not read the following xml tag, ...
1
by: andrew_nuss | last post by:
Hi, Something mysterious has happened to my stylus studio project as I've added changes to the XSL file that renders html output. Before, the output included the <HEADand <BODYtags for the HTML...
8
by: ismailc | last post by:
Hi, I would like to change the text color of (<xsl:value-of select="Description") onmouseover of image. the javascript works, it's just that i can seem to get the name correct <td>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.