473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<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()!='Inform ation']"/>
</xsl:variable>
<xsl:element name="fo:block" >
<xsl:if test="not($Posi tion=1 and position()=1)">
<xsl:attribut e 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>12345678 9</NAS>
<Name>
<Surname>John </Surname>
<Given>Doe</Given>
</Name>
<DOB>1944-09-23T12:00:00</DOB>
<Province />
<SpouseName>
<Surname>Johann e</Surname>
<Given>Doe</Given>
</SpouseName>
<Sexe>1</Sexe>
<DOBduConjoin t />
</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 3149
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!tkachen ko.com> wrote in message news:<ua******* *******@TK2MSFT NGP09.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="MemberInf o"
select="/Booklet/Cahier"/>. Now if I use <xsl:value-of
select="$Member Info/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="Particip ant">
<xsl:variable name="TemplateT ype">
<xsl:value-of select="name(pa rent::*/parent::*)"/>
</xsl:variable>

<test><xsl:valu e-of
select="msxsl:n ode-set($TemplateTy pe)"/></test>

<xsl:variable name="BiggerCol ">
<xsl:variable name="Sub">
<xsl:for-each
select="$Layout Info/Booklet_Definit ion/child::*[name()=$Templat eType]/Member/Column">
<xsl:element name="Column">
<xsl:element name="ColumnLen "><xsl:valu e-of
select="count(c hild::Element)"/></xsl:element>
<xsl:element name="Position" ><xsl:value-of
select="positio n()"/></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="$Templa teType" seems now
to be waiting for a node-set! So as you see, I've try <xsl:value-fo
select="msxsl:n ode-set($TemplateTy pe)/> 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="Particip ant">
<xsl:variable name="TemplateT ype">
<xsl:value-of select="name(pa rent::*/parent::*)"/>
</xsl:variable>

<test><xsl:valu e-of
select="msxsl:n ode-set($TemplateTy pe)"/></test>

<xsl:variable name="BiggerCol ">
<xsl:variable name="Sub">
<xsl:for-each
select="$Layout Info/Booklet_Definit ion/child::*[name()=$Templat eType]/Member/Column">
<xsl:element name="Column">
<xsl:element name="ColumnLen "><xsl:valu e-of
select="count(c hild::Element)"/></xsl:element>
<xsl:element name="Position" ><xsl:value-of
select="positio n()"/></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="$Templa teType" seems now
to be waiting for a node-set! So as you see, I've try <xsl:value-fo
select="msxsl:n ode-set($TemplateTy pe)/> 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
2082
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, it comes to me this way. <?xml version="1.0" encoding="iso-8859-1" ?>
4
3725
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> <field_type>dropdown</field_type> <field_choice_text>
6
24375
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 XSLT and replace all occurances of &lt; with < and &gt; with >.
2
1823
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 this. To clarify my question, I have add all the files required to perform the test. First question: Why doesn't this works anymore if I remove the line with "&#x00A0;" in the XSL-file ?
1
1756
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: &lt;test&gt;this is a test&lt;/test&gt; I need to get <test>this is a test</testrather than the escaped data. Any input would be appreciated.
0
1716
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, <PrescriptionRefillMeds> <anyType xsi:type="PrescriptionRefillMed"> <Description>Drug1</Description> I have written code to conert the object in to the serialising/deserialising in C#. XSLT has the required namespacses also,not able to read the...
1
1549
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 output, even though I did nothing explictly to cause this. Now, they are missing in the HTML output. Is this a project setting in stylus studio, or is it an artifact of the various apply-template commands in the XSL file? Or something else. ...
8
12452
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> <xsl:value-of select="Description" disable-output-escaping="yes" /> </td> <td> <xsl:element name="asp:image"> <xsl:attribute name='id'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10247
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.