Hi
I'm a bit of a noob to xslt. I have a data.xml document like this..
input.xml
<energy>
..lots and lots of other data.....
<units>(Watts)< \units>
<value>1000.0<\ value>
</energy>
Now I want to have an xslt stylesheet that will convert it from watts to
kilowatts.
output.xml
<energy>
..lots and lots of other data.....
<units>(KiloWat ts)<\units>
<value>1.0<\val ue>
</energy>
Any ideas?
Thanks 2 2056
Tempore 22:50:17, die Wednesday 09 February 2005 AD, hinc in foro {comp.text.xml} scripsit plopez <plopez@spam_re movethis crazy remove.nrcan.gc .ca>: Hi
I'm a bit of a noob to xslt. I have a data.xml document like this..
input.xml <energy> ..lots and lots of other data.... <units>(Watts)< \units> <value>1000.0<\ value> </energy>
Now I want to have an xslt stylesheet that will convert it from watts to kilowatts.
output.xml <energy> ..lots and lots of other data..... <units>(KiloWat ts)<\units> <value>1.0<\val ue> </energy>
Any ideas?
Hi,
You'll need a conversion table in XML.
Now if only Google would output XHTML... http://www.google.com/search?q=1000....29+in+kilowatt
If the watt->kilowatt is really the only conversion, you can use:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@ *">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="units[.='(Watts)']">
<units>(KiloWat ts)</units>
</xsl:template>
<xsl:template match="value[preceding-sibling::*[1]='(Watts)']">
<value><xsl:val ue-of select="format-number(. div 1000,'#.0')"/></value>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis ( http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
Thanks!!
It my real world problem was a little different.
<name>Cooling </name>
<units>(W)</units>
<binned_data type="monthly">
<index>0</index>
<steps>744</steps>
<active_steps>7 44</active_steps>
<sum>0.000000 </sum>
</binned_data>
But you pointed me in the right direction!
It now my template looks like..
<xsl:template match="//sum[parent::*/preceding-sibling::units= '(W)']">
<sum><xsl:val ue-of select="format-number(. div 1000,'#.0')"/></sum>
</xsl:template>
It probably would be better if I made the "units" value an attribute of
"sum". That way I could use a conversion table for all units and all
entities.
Thanks again!
PL
"Joris Gillis" <ro**@pandora.b e> wrote in message
news:op******** ******@news.pan dora.be... Tempore 22:50:17, die Wednesday 09 February 2005 AD, hinc in foro {comp.text.xml} scripsit plopez <plopez@spam_re movethis crazy remove.nrcan.gc .ca>:
Hi
I'm a bit of a noob to xslt. I have a data.xml document like this..
input.xml <energy> ..lots and lots of other data.... <units>(Watts)< \units> <value>1000.0<\ value> </energy>
Now I want to have an xslt stylesheet that will convert it from watts to kilowatts.
output.xml <energy> ..lots and lots of other data..... <units>(KiloWat ts)<\units> <value>1.0<\val ue> </energy>
Any ideas? Hi,
You'll need a conversion table in XML. Now if only Google would output XHTML... http://www.google.com/search?q=1000....29+in+kilowatt
If the watt->kilowatt is really the only conversion, you can use:
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@ *"> <xsl:copy> <xsl:apply-templates select="node()| @*"/> </xsl:copy> </xsl:template>
<xsl:template match="units[.='(Watts)']"> <units>(KiloWat ts)</units> </xsl:template>
<xsl:template match="value[preceding-sibling::*[1]='(Watts)']"> <value><xsl:val ue-of select="format-number(. div 1000,'#.0')"/></value> </xsl:template>
</xsl:stylesheet>
regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041) Vincit omnia simplicitas Keep it simple This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Stromberg |
last post by:
Is there already a pure python module that can do modular-arithmetic unit
conversions, like converting a huge number of seconds into months,
weeks... or a bandwidth measure into megabits/s or gigabits/s or
megabytes/s or gigabytes/s, whatever's the most useful (ala df -h)?
Thanks!
|
by: |
last post by:
Hi!
I'm looking for unit-testing tools for .NET.
Somthing like Java has --> http://www.junit.org
regards,
gicio
|
by: Jacob |
last post by:
I have compiled a set og unit testing
recommendations based on my own experience
on the concept.
Feedback and suggestions for improvements
are appreciated:
http://geosoft.no/development/unittesting.html
Thanks.
|
by: Stephan Rose |
last post by:
In one of the applications I am developing I have need of working with
numbers in varying unit system. I might be adding 5 mil to 1 inch or
whatever.
What I have come up with works really well, however...it moves about
as fast as a honda civic trying to tow a semi truck.
The basic definition looks like this:
public struct ScalarGeneric : IScalar
|
by: shapper |
last post by:
Hello,
In a custom control property I have the following:
If CStr(ViewState("InfoWidth")) Is Nothing Then ...
I am getting the error:
Conversion from type 'Unit' to type 'String' is not valid.
| |
by: batvanio |
last post by:
Hi,
I am writing unit tests in VS2005 and am having the following problem:
I am trying to test a timeout property of one of my methods. This
timeout exhibits itself in an exceptioin - i.e. I am sending a command
to a hardware device, and if it does not answer in the timeout defined
(i.e. in 2 sec), my software fires an exception.
Now, I am writing an unit test in which I start a timer and I send the
command. Note that I DO expect an...
|
by: Dean |
last post by:
Is there a free js library for doing unit conversions? I am putting
together an app that needs to convert volume and weight, among
others. You'd think that one exists, but I have yet to find it.
Thanks,
--Dean
|
by: Richard Lewis Haggard |
last post by:
We're using VS05 and today the units tests have stopped working in our
development environment. I'm sure that it is something really silly and
simple but I'll be darned if I can figure out what it is.
Here's a failure example: I created a simple little C# program called Test1.
I added a new class that has a public method Sum, which does the brilliant
function of adding two numbers together and returning the result.
I added a unit test...
|
by: Ben Finney |
last post by:
Howdy all,
PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an
enhancement for entry points to Python programs: a module attribute
(named '__main__') that will be automatically called if the module is
run as a program.
The PEP has status "Rejected", citing backward-compatibility issues,
and Guido's pronouncement that "It's not worth the change (in docs,
user habits, etc.) and there's nothing particularly broken."
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |