473,769 Members | 6,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML transform inconsistency with different processors

Hello all,

I am very new to this subject and learning by example.

I have a small inconsistency in an XML file when transformed using
different processors. I was wondering if someone could shed light on why
this is and if possible how to resolve the inconsistency.

I am attempting to change the element names in the source XML file from
upper to lowercase. I have used (slightly modified) examples from the
XSLT Cookbook, O'Reilly Press.

If I use Xalan (Java 2.5.1 I think) then the transformed XML file has
the following route element and undesired attribute:

<play xmlns:ren="http ://www.ora.com/namespaces/rename">

If I use Saxon 6.5.3 or MSXML4.0, I end up with the desired root element
of:

<play>

The <TITLE> element is always transformed to <title>

I am using oXygen 6.0 as my development environment.

Thanks in advance for any assistance offered.

Peter Clifton
This is the example XML file I am transforming.

---Source.xml

<?xml version="1.0"?>
<PLAY>
<TITLE>Play Title</TITLE>
</PLAY>
This is the stylesheet I am using
--- LowerCase.xsl

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:ren="http ://www.ora.com/namespaces/rename">

<xsl:import href="TableDriv enRename.xsl"/>

<xsl:output method="xml" version="1.0" indent="no" encoding="UTF-8" />

<xsl:variable name="lookup" select="documen t('')/*[ren:*]"/>
<ren:element from="PLAY" to="play"/>
<ren:element from="TITLE" to="title"/>
</xsl:stylesheet>
and these are the referenced stylesheets during the process
--- TableDrivenRena me.xsl

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:ren="http ://www.ora.com/namespaces/rename">

<xsl:import href="copy.xsl"/>

<!--Override in importing stylesheet -->
<xsl:variable name="lookup" select="/.."/>

<xsl:template match="*">
<xsl:choose>
<xsl:when test="$lookup/ren:element[@from=name(curr ent())]">
<xsl:element name="{$lookup/ren:element[@from=name(curr ent())]/
@to}">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsl:otherwis e>
<xsl:apply-imports/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
--- copy.xsl

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

<xsl:template match="/ | node() | @* | comment() | processing-
instruction()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
Jul 20 '05 #1
2 1742

That looks like a bug in xalan: xsl:element should not copy the in scope
ren namespace.

It's a very inefficient way of coding the name change though, having to
parse the stylesheet twice (once as a styleseet and once as an input
document) and then having to look up the element names in your table all
the time. A much more direct way to code things would be to have
copy.xsl as you have it and then templates of the form

<xsl:template match="PLAY|TIT LE">
<xsl:element name="{translat e(name(),'QWERT YUIOPASDFGHJKLZ XCVBNM','qwerty uiopasdfghjklzx cvbnm')}">
<xsl:apply-templates select="@*|node ()"/>
</xsl:element>
</xsl:template>

Or if you want all elements lowercased, replace PLAY|TITLE by *

David
Jul 20 '05 #2
David Carlisle said...

That looks like a bug in xalan: xsl:element should not copy the in scope
ren namespace.

It's a very inefficient way of coding the name change though, having to
parse the stylesheet twice (once as a styleseet and once as an input
document) and then having to look up the element names in your table all
the time. A much more direct way to code things would be to have
copy.xsl as you have it and then templates of the form

<xsl:template match="PLAY|TIT LE">
<xsl:element name="{translat e(name(),'QWERT YUIOPASDFGHJKLZ XCVBNM','qwerty uiopasdfghjklzx cvbnm')}">
<xsl:apply-templates select="@*|node ()"/>
</xsl:element>
</xsl:template>

Or if you want all elements lowercased, replace PLAY|TITLE by *


Thank you so much for responding and supplying a more efficient approach
to solving the problem.

I am taking my first steps into developing an environment for producing
technical documents XML > XSL-FO > PDF

It has taken me a while just to get all the acronyms and XML
technologies straight in my head ;-)

I have begun to realise that the critical glue in all of this is going
to be XSL and associated technologies so this is where I have decided to
start learning.

Thanks once again.

Peter

Jul 20 '05 #3

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

Similar topics

15
2492
by: Roberto A. F. De Almeida | last post by:
I found that when using negative indices, the slice object passed to __getitem__ depends on the number of slices. An example to clarify: class a: def __getitem__(self, index): return index >>> b = a() >>> print b Traceback (most recent call last):
46
4253
by: Scott Chapman | last post by:
There seems to be an inconsistency here: Python 2.3.2 (#1, Oct 3 2003, 19:04:58) on linux2 >>> 1 == True True >>> 3 == True False >>> if 1: print "true" ....
4
2998
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to...
1
1380
by: shaun | last post by:
Is there some way (standard or non-standard) to access an oracle database during an xslt transform to extract some parameters which will appear in the transform? cheers shaun
1
1084
by: Water Cooler v2 | last post by:
Sorry about the basic question. I have an XML file and I have an XSLT stylesheet that has been constructed to translate the XML file. Now, what next? How do you transform an XML file using the XSL?
7
1845
by: Bilal | last post by:
Hello all, I came across this problem while working out the bugs in my identity trasnformation stylesheets but sidestepped it for later to see if there is an easier/better solution. This is essentially following up to my last post so apologies for repeating parts of the post. The transformation stylesheet is (after corrections from kind contributors :) <?xml version="1.0" encoding="UTF-8"?>
2
1694
by: Adam dR. | last post by:
I have an xml file similar to: <menu> <menuitem name="home" show="false"/> <menuitem name="about" show="true"/> <menuitem name="links" show="true"/> <menuitem name="games" show="true"/> <menuitem name="learn" show="true"/> <menuitem name="order" show="true"/> <menuitem name="contact" show="true"/> <menuitem name="support" show="false"/>
8
2039
by: Alex Buell | last post by:
I've just written the below as an exercise (don't worry about the lack of checking), but I was wondering why I needed to write a struct with an operator() as a parameter to supply to the STL transform() function? #include <algorithm> #include <iostream> #include <fstream> #include <iterator> #include <vector> #include <string>
0
992
by: nimitsis | last post by:
hello I have a problem, which in C is simple to get through of it, but in python seems not so easy to me. I have 2 python threads. Each one do a different work. The first do a computation in a variable and the second send the value of the variable to an other processor, via MPI and receive a new one. The main problem is that the computation thread must be executed first and the communication thread must follows and the alternation between...
0
9587
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...
1
9993
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
9863
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
8870
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
7406
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
6672
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
5298
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...
1
3958
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
3
2815
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.