473,651 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can an XSL stylesheet have 2 root templates ?


Hi,

Can an XSL stylesheet have 2 root templates ? How about 2
templates that match the same set of nodes ? Which one gets executed ?

Regards,
Razvan

Jul 20 '05 #1
2 1173
Hi Razvan,
There are a set of rules defined by the XSLT spec for conflict
resolution for selecting which templates to select. Please do read the
spec for detailed description.

In a normal stylesheet you cannot have two template rules having the
same match pattern. This is also valid for root node. If you have 2
root templates, the processor will usually give an error.

But you may invoke the transform with an initial mode. For e.g. Saxon
provides -im option to specify the initial mode.

So you may have 2 templates for root node as below:
<xsl:template match="/">

</xsl:template>

<xsl:template match="/" mode="x" >

</xsl:template>

These templates both match the root node, but are differentiated by
the mode.

If you invoke the transformation with -im x option, the 2nd rule will
be invoked, otherwise 1st rule will be invoked.

Regards,
Mukul

"Razvan" <mi*****@mailci ty.com> wrote in message news:<11******* *************** @g14g2000cwa.go oglegroups.com> ...
Hi,

Can an XSL stylesheet have 2 root templates ? How about 2
templates that match the same set of nodes ? Which one gets executed ?

Regards,
Razvan

Jul 20 '05 #2

Hi Mukul,

I did not know about this "mode" parameter. Indeed, it can be
useful for selecting a template directly at runtime.

Regards,
Razvan
Mukul Gandhi wrote:
Hi Razvan,
There are a set of rules defined by the XSLT spec for conflict
resolution for selecting which templates to select. Please do read the spec for detailed description.

In a normal stylesheet you cannot have two template rules having the
same match pattern. This is also valid for root node. If you have 2
root templates, the processor will usually give an error.

But you may invoke the transform with an initial mode. For e.g. Saxon
provides -im option to specify the initial mode.

So you may have 2 templates for root node as below:
<xsl:template match="/">

</xsl:template>

<xsl:template match="/" mode="x" >

</xsl:template>

These templates both match the root node, but are differentiated by
the mode.

If you invoke the transformation with -im x option, the 2nd rule will
be invoked, otherwise 1st rule will be invoked.

Regards,
Mukul

"Razvan" <mi*****@mailci ty.com> wrote in message

news:<11******* *************** @g14g2000cwa.go oglegroups.com> ...
Hi,

Can an XSL stylesheet have 2 root templates ? How about 2
templates that match the same set of nodes ? Which one gets executed ?
Regards,
Razvan


Jul 20 '05 #3

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

Similar topics

1
3236
by: Luke Airig | last post by:
I am using the Saxon 6.5.3 engine and I have an xsl stylesheet that merges two files on a date_time field and writes out a tab-delimited flat file. My working version has a hard-coded file name in the xsl file. I dug through the Saxon documenation to find a way to feed a file name param to eliminate the hard-coded file name in the xsl. This version executes but does not appear to do the merge processing and drops the longitude and...
0
1545
by: Sharon | last post by:
Hiya, I have this stylesheet (based on an example @ http://rdcpro.com/xmldev/filterandsort)which I'm trying to modify so that it will work for my own XML and I get some data but it doesn't appear within the table as intended. Does anyone know why this is? This is my XSL followed by my XML. I hope someone can help me! love, Sharon <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"
8
1767
by: Matej Cepl | last post by:
Hello, does anybody have %subj%? I would like to generate some very simple HTML (XHTML?) file from OOImpress, so that I can send it to the friend for review and not bother her with all images, layouts, and the other junk (moreover, she probably never heard about OO.o). Powerpoint of the cursed memory used to have export of outline to RTF. Is there something similar for OOImpress (certainly, I do not care about RTF, OOWriter or HTML would...
7
5202
by: pintihar | last post by:
Hi, As a follow on from an earlier post I have another question about xslt. Is it possible to create the stylsheet programatically? Is this sensible? In the first phase I needed to map element name from inbound xml to my internal elements to standardize disparate input. Now I could just create an xslt stylesheet for each possible inbound format and be done, but I think it would be powerful to be able store this mapping in a database and...
0
1202
by: barney.b | last post by:
Hi, I'm trying to pre-process an XSL stylesheet with another stylesheet, before using the result to transform an XML document. i.e.: stylesheet(xsl) --> preprocessor(xsl) --> temp(xsl) input(xml) --> temp(xsl) --> output(xml) but I'm getting a NullPointerException. I'm not 100% sure exactly what is going on here, so if someone could help I'd be grateful.
0
1422
by: hq4000 | last post by:
Given AStyleSheet.xsl : <AStyleSheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.mytest.mytest2.mytest3.com" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:element name="Test">it works</xsl:element> </xsl:template>
2
6977
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
1
1568
by: doulos05 | last post by:
Ok, I'm sure the answer is right in front of me, but I can't see if for the life of me. Here's my xml document: <price_guide> <group><name>Wacky Widgets</name> <product> <product_id>1</product_id> <description>Widget 1</description> <sell> <quantity>500</quantity>
7
861
by: Andy Fish | last post by:
hi, i'm porting some xsl code from .net 1.1 to 2.0 and I have come across a transform which works in .net 1.1 and works in mxsml but does not work in ..net 2.0. the stylesheet is this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="foo">
0
8278
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
8807
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...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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,...
1
6158
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
5615
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
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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
2
1588
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.