473,770 Members | 2,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic XSLT/XSLTC question

I'm using xalan-j_2_6_0 and trying to get an example from Michael
Kay's book to work:

<xsl:template match="/">
<xsl:variable name="rainbow">
<color>red</color>
<color>blue</color>
<color>green</color>
</xsl:variable>

<xsl:for-each select="$rainbo w/color">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

Both XSLTC and XSLT generate errors when they encounter the XPath
expression in the select attribute. I cannot get XSLTC or XSLT to
accept any expression that qualifies a variable in a select statement.

Am I trying to do something that is strictly forbidden here? Am I
misunderstandin g what Michael Kay's example was supposed to do?

Any help is greatly appreciated!!

Justine
Jul 20 '05 #1
3 2142
I guess that you read the second edition of Mike's book, in which he covered
XSLT 1.1.

XSLT 1.1 was never developed by the W3C into a final status and is not a
standard. The current standard of XSLT 1.0 has the concept of RTF (Result
Tree Fragment).

An RTF cannot be treated like a node-set in XPath -- any such attempt
results in raising an error -- this is exactly what you described.

In order to process an RTF as a node-set, one must use an
implementation-defined extension function with the usual name of node-set(),
belonging to an implementation-dependent namespace, or use the
common:node-set() function as defined by EXSLT.

These functions take an RTF and convert it to a regular node-set. Then their
result is a regular tree (a node-set having just one root node) and can be
navigated using XPath.
Therefore, you also have to use whatever implementation-defined
xxx:node-set() extension function is available for your XSLT processor.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Justine Hlista" <jb************ **@yahoo.com> wrote in message
news:3e******** *************** ***@posting.goo gle.com...
I'm using xalan-j_2_6_0 and trying to get an example from Michael
Kay's book to work:

<xsl:template match="/">
<xsl:variable name="rainbow">
<color>red</color>
<color>blue</color>
<color>green</color>
</xsl:variable>

<xsl:for-each select="$rainbo w/color">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

Both XSLTC and XSLT generate errors when they encounter the XPath
expression in the select attribute. I cannot get XSLTC or XSLT to
accept any expression that qualifies a variable in a select statement.

Am I trying to do something that is strictly forbidden here? Am I
misunderstandin g what Michael Kay's example was supposed to do?

Any help is greatly appreciated!!

Justine

Jul 20 '05 #2
Hi,

It is also possible to store "XML constants" inside your stylesheet and
refer to them with the document() function, that will be adressable with
XPath (no extension required) :

<xsl:styleshe et ...
xmlns:xsl="..."
xmlns:data="... ">

<data:structure s>
<rainbow>
<color>red</color>
<color>blue</color>
<color>green</color>
</rainbow>
</data:structures >

<xsl:template match="/">
<xsl:variable name="rainbow"
select="documen t('')/*/data:structures/rainbow"/>
<xsl:for-each select="$rainbo w/color">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Dimitre Novatchev [MVP XML] wrote:
I guess that you read the second edition of Mike's book, in which he covered
XSLT 1.1.

XSLT 1.1 was never developed by the W3C into a final status and is not a
standard. The current standard of XSLT 1.0 has the concept of RTF (Result
Tree Fragment).

An RTF cannot be treated like a node-set in XPath -- any such attempt
results in raising an error -- this is exactly what you described.

In order to process an RTF as a node-set, one must use an
implementation-defined extension function with the usual name of node-set(),
belonging to an implementation-dependent namespace, or use the
common:node-set() function as defined by EXSLT.

These functions take an RTF and convert it to a regular node-set. Then their
result is a regular tree (a node-set having just one root node) and can be
navigated using XPath.
Therefore, you also have to use whatever implementation-defined
xxx:node-set() extension function is available for your XSLT processor.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Justine Hlista" <jb************ **@yahoo.com> wrote in message
news:3e******** *************** ***@posting.goo gle.com...
I'm using xalan-j_2_6_0 and trying to get an example from Michael
Kay's book to work:

<xsl:templa te match="/">
<xsl:variable name="rainbow">
<color>red</color>
<color>blue</color>
<color>green</color>
</xsl:variable>

<xsl:for-each select="$rainbo w/color">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

Both XSLTC and XSLT generate errors when they encounter the XPath
expression in the select attribute. I cannot get XSLTC or XSLT to
accept any expression that qualifies a variable in a select statement.

Am I trying to do something that is strictly forbidden here? Am I
misunderstand ing what Michael Kay's example was supposed to do?

Any help is greatly appreciated!!

Justine


--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #3

"Philippe Poulard" <Ph************ ****@SPAMsophia .inria.fr> wrote in message
news:c2******** **@news-sop.inria.fr...
Hi,

It is also possible to store "XML constants" inside your stylesheet and
refer to them with the document() function, that will be adressable with
XPath (no extension required) :


Yes, and this is a really valuable technique for creating data structures to
be used by the XSLT application.

The example given by the OP can be solved completely that way.

What cannot be done in this way is to access dynamically created nodes.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3621
by: LW | last post by:
I'm using the following free implementation of an XSLT "split" function, as a template: http://www.exslt.org/str/functions/split/str.split.template.xsl.html Basically, it allows me to call it like this... <xsl:call-template name="str:split"> <xsl:with-param name="string" select="string('boy,cat,dog')" /> <xsl:with-param name="pattern" select="string(',')" />
9
3284
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd no longer wait. Some Googling pointed me to several beginner tutorials, and I chose to get myself going with the guide at http://rzserv2.fhnon.de/%7Elg002556/docbuch/
4
2124
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content provider who says we need to use XSLT and Web Services to pull the content from their site. Can someone give me a nutshell definition on how this works??? We use Cold Fusion MX on our web server, but I'm having trouble finding a
0
2631
by: Jordan Willms | last post by:
My xsl stylesheet is as simple as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns="http://ltsc.ieee.org/xsd/LOMv1p0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/> <!-- rename ims datetime tags to IEEE dateTime tags --> <xsl:template match="ims:datetime">
0
1334
by: Meikel | last post by:
Just a hint for others: I got a NullPointerException in org.apache.xalan.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler and wondered what went wrong. I had put the wrong method as output property "pdf" instead of xml. transformer.setOutputProperty(javax.xml.transform.OutputKeys.METHOD, "xml");
0
3303
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections. Each section has a list of questions. Each question has responses. I need to display a list of responses to the questions (i.e. set:distinct), once and only once, each section. My second problem is that these questions can also have corrective...
1
2419
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT stylesheets, that generates .NET assemblies) 2. Performance improvements in the XslCompiledTransform
14
5157
by: Lee | last post by:
I have a xml file, here is sample part: <?xml version="1.0" encoding="UTF-8"?> <ProducsList> <Product id="1"> <SpecList> <Spec> <SpecLabel>Height</SpecLabel> <SpecValue>10</SpecValue> <SpecCat>Dimension</SpecCat> </Spec>
2
2502
by: astroboiii | last post by:
New to the whole xml thing and finding w3schools to be an excellent resource. Now down to my question: I have several xml files I need to parse through and grab relevant information from and produce a new xml file. This needs to be automated through ant. The ant script is working fine, and I am usign the <transform> function to use my xslt file and go through all the required xml files, parse them, style them, and ultimately generate my...
0
9425
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,...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
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
8886
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
7416
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
6678
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
5313
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...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.