473,327 Members | 2,081 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,327 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 3110
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.