This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XSLT equality test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSLT equality test" Watch "XSLT equality test" New topic

XSLT equality test

Daniel Walker

Joined: Aug 09, 2001
Posts: 19
Hi all...
I am currently designing a stylesheet which formats an XML dbase of academic publications and displays it in typical bibliographic style (eg. the Harvard system). There are about 15 different types of publication, and each different type must be displyed slightly differently. The stylesheet currently looks like this:

Basically, the "Type" element of each entry in the dbase contains the entry's type, and depending on what this value is I would like to invoke the correct xsl:template (one for each entry type).
However, the code above does not work - the default rule is invoked each time. Does anybody have any idea where I am going wrong? In addition, any sugestions on better ways of doing this would be appreciated too.
I thank you all in advance.
***i fear that i am ordinary...
...just like everyone...***

<B>daniel.walker</B><BR><I>***bleed in your own light...<BR>...dream of your own life...***</I>
Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
Originally posted by Daniel Walker:
However, the code above does not work - the default rule is invoked each time.

It worked for me with Xalan and even IE 5.0. on test file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="bool.xsl"?>
The output:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CCI Publications</title>
<P>This is an article...</P>
<P>This is an inBook...</P>
<P>This is an inProceedings...</P>
Which processor do you use anyway?

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Daniel Walker

Joined: Aug 09, 2001
Posts: 19
Thanks Mapraputa - it seems that my XML file was the problem. I am currently using IE6 (the final product will use a server side transform however, probably with Xalan)
Take a look :

Evidently, it was a problem with whitespace or CR or something. I have now arranged the XML file in the same format as your example, and it works great.
My XSL and XML files now looks like this:

Each entry type will have a section like the "Article" match, except with different formatting etc.
However, I would like to be able to substitute the final comma in each entry with a full stop (period) - do you know of a good way of doing this?
Thanks again.
[This message has been edited by Daniel Walker (edited September 20, 2001).]
[This message has been edited by Daniel Walker (edited September 21, 2001).]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: XSLT equality test
jQuery in Action, 3rd edition