473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with xslt

I have XML that looks like below from which I want to make the VALUE
tags that are empty (ie <Value/>) default to <Value>0.00</Valueand
then I want to pull out certain values, for which I already have the
XSLT for, which is also seen below. Can someone please help me with
how to do this? Thanks

***Data to be processed ***
<GetNamedProfileReturn>
<NamedProfile>
<ProfileId>115512</ProfileId>
<ProfileRef>
<ProfileName>Dewpoint</ProfileName>
<ProfileType>BTU|Weather Data</ProfileType>
</ProfileRef>
<LastModified>2007-08-01T10:00:05</LastModified>
<Version>5693</Version>
<DataTypeCode>N</DataTypeCode>
<PeriodTypeCode>H</PeriodTypeCode>
<SummarizeTypeCode>A</SummarizeTypeCode>
<ReferenceUOM/>
<ReferenceSummarizedUOM/>
<DecimalPrecision>0</DecimalPrecision>
<Description>Hourly Weather Data</Description>
<Profile>
<Entry>
<Start>2007-07-30T00:00:00</Start>
<Stop>2007-07-30T01:00:00</Stop>
<Value/>
</Entry>
<Entry>
<Start>2007-07-30T01:00:00</Start>
<Stop>2007-07-30T02:00:00</Stop>
<Value/>
</Entry>
<Entry>
<Start>2007-07-30T02:00:00</Start>
<Stop>2007-07-30T03:00:00</Stop>
<Value/>
</Entry>
<Entry>
<Start>2007-07-30T03:00:00</Start>
<Stop>2007-07-30T04:00:00</Stop>
<Value/>
</Entry>
<Entry>
<Start>2007-07-30T04:00:00</Start>
<Stop>2007-07-30T05:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T05:00:00</Start>
<Stop>2007-07-30T06:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T06:00:00</Start>
<Stop>2007-07-30T07:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T07:00:00</Start>
<Stop>2007-07-30T08:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T08:00:00</Start>
<Stop>2007-07-30T09:00:00</Stop>
<Value>75</Value>
</Entry>
<Entry>
<Start>2007-07-30T09:00:00</Start>
<Stop>2007-07-30T10:00:00</Stop>
<Value>75</Value>
</Entry>
<Entry>
<Start>2007-07-30T10:00:00</Start>
<Stop>2007-07-30T11:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T11:00:00</Start>
<Stop>2007-07-30T12:00:00</Stop>
<Value>72</Value>
</Entry>
<Entry>
<Start>2007-07-30T12:00:00</Start>
<Stop>2007-07-30T13:00:00</Stop>
<Value>70</Value>
</Entry>
<Entry>
<Start>2007-07-30T13:00:00</Start>
<Stop>2007-07-30T14:00:00</Stop>
<Value>71</Value>
</Entry>
<Entry>
<Start>2007-07-30T14:00:00</Start>
<Stop>2007-07-30T15:00:00</Stop>
<Value>71</Value>
</Entry>
<Entry>
<Start>2007-07-30T15:00:00</Start>
<Stop>2007-07-30T16:00:00</Stop>
<Value>71</Value>
</Entry>
<Entry>
<Start>2007-07-30T16:00:00</Start>
<Stop>2007-07-30T17:00:00</Stop>
<Value>70</Value>
</Entry>
<Entry>
<Start>2007-07-30T17:00:00</Start>
<Stop>2007-07-30T18:00:00</Stop>
<Value>70</Value>
</Entry>
<Entry>
<Start>2007-07-30T18:00:00</Start>
<Stop>2007-07-30T19:00:00</Stop>
<Value>71</Value>
</Entry>
<Entry>
<Start>2007-07-30T19:00:00</Start>
<Stop>2007-07-30T20:00:00</Stop>
<Value>73</Value>
</Entry>
<Entry>
<Start>2007-07-30T20:00:00</Start>
<Stop>2007-07-30T21:00:00</Stop>
<Value>73</Value>
</Entry>
<Entry>
<Start>2007-07-30T21:00:00</Start>
<Stop>2007-07-30T22:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T22:00:00</Start>
<Stop>2007-07-30T23:00:00</Stop>
<Value>74</Value>
</Entry>
<Entry>
<Start>2007-07-30T23:00:00</Start>
<Stop>2007-07-31T00:00:00</Stop>
<Value>73</Value>
</Entry>
</Profile>
</NamedProfile>
</GetNamedProfileReturn>

***xslt that I have that pulls the data that I want****
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet xmlns:x="http://www.softsmiths.com/etms/elink"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="x"
version="1.0">

<xsl:output indent="yes" method="xml" encoding="ISO-8859-1" omit-xml-
declaration="no"/>

<xsl:template match="x:GetNamedProfileResponse">
<NamedProfileList>
<xsl:apply-templates select=".//x:Entry"/>
</NamedProfileList>
</xsl:template>

<xsl:template match="x:Entry">
<NamedProfile>
<ProfileID><xsl:value-of select="../../x:ProfileId"/></
ProfileID>
<Name><xsl:value-of select="../../x:ProfileRef/x:ProfileName"/></
Name>
<Type><xsl:value-of select="../../x:ProfileRef/x:ProfileType"/></
Type>
<StartTime><xsl:value-of select="x:Start"/></StartTime>
<StopTime><xsl:value-of select="x:Stop"/></StopTime>
<Value><xsl:value-of select="x:Value"/></Value>
</NamedProfile>
</xsl:template>
</xsl:stylesheet>

*** What I want the output to look like ****
<NamedProfileList>
<NamedProfile>
<ProfileID>115512</ProfileID>
<Name>Dewpoint</Name>
<Type>BTU|Weather Data</Type>
<StartTime>2007-07-30T00:00:00</StartTime>
<StopTime>2007-07-30T01:00:00</StopTime>
<Value>0.00</Value>
</NamedProfile>
</NamedProfileList>

....instead of
<NamedProfileList>
<NamedProfile>
<ProfileID>115512</ProfileID>
<Name>Dewpoint</Name>
<Type>BTU|Weather Data</Type>
<StartTime>2007-07-30T00:00:00</StartTime>
<StopTime>2007-07-30T01:00:00</StopTime>
<Value/>
</NamedProfile>
</NamedProfileList>

Aug 3 '07 #1
2 1811
TexasAggie96 wrote:
I have XML that looks like below from which I want to make the VALUE
tags that are empty (ie <Value/>) default to <Value>0.00</Valueand
then I want to pull out certain values, for which I already have the
XSLT for, which is also seen below.
<Value>
<xsl:choose>
<xsl:when test="x:Value=''">
<xsl:text>0.00</xsl:text>
<xsl:when>
<xsl:otherwise>
<xsl:value-of select="x:Value"/>
<xsl:/otherwise>
</xsl:choose>
</Value>

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Aug 3 '07 #2
On Aug 3, 2:38 pm, Peter Flynn <peter.n...@m.silmaril.iewrote:
TexasAggie96 wrote:
I have XML that looks like below from which I want to make the VALUE
tags that are empty (ie <Value/>) default to <Value>0.00</Valueand
then I want to pull out certain values, for which I already have the
XSLT for, which is also seen below.

<Value>
<xsl:choose>
<xsl:when test="x:Value=''">
<xsl:text>0.00</xsl:text>
<xsl:when>
<xsl:otherwise>
<xsl:value-of select="x:Value"/>
<xsl:/otherwise>
</xsl:choose>
</Value>

///Peter
--
XML FAQ:http://xml.silmaril.ie/
Worked great! Thanks much for the help.

JW

Aug 3 '07 #3

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

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
5
by: dennis | last post by:
Hi, First of all, hi to you all. I'm working on a Delphi project wich is becoming near it's deadline. I have a very simple XSLT question wich i hope one of you folks can help me with? The...
5
by: | last post by:
Hello Guys, I am trying to render an Xml dataset into HTML using XSLT. When I am loading the XSLT file into transform object to render it. Here is the code snippet: <!-- XslTransform...
7
by: Roshawn Dawson | last post by:
Hi, I have an xslt file located in the root directory. It is used by an aspx pages in both the root directory and a subdirectory. But for some strange reason, the aspx page in the subdirectory...
1
by: byquestion | last post by:
Hi there xslt gurus, i am kinda new to xslt and having difficulty to implement my some iterations. i need to recreate an xml file by using xslt. here is the sample xml file(input for xslt) ...
6
Gaiason
by: Gaiason | last post by:
Hi XML/XSLT masters and gurus, I am a newbie in XML/XSLT and have been reading up XML/XSLT in order to convert a XML generated from a OCR engine to another format of XML. I am truly stuck at this...
2
by: milecimm | last post by:
Hello, I need some help to solve the following problem (if it is possible, that's it): I'm using a xpath expression to programatically get data from my xml file. I want to transform ONLY the...
4
by: Nick | last post by:
I have a critical requirement where I need to club together 4 xml files and display them in an sibngle HTML report. The xmls are generated by Java application by a normal file I/O. Is there a...
2
Dormilich
by: Dormilich | last post by:
Hi, I'm testing my classes for a web page and I stumble upon an error I don't have a clue what it means: Error: Fatal error: Can't use method return value in write context in "output.php" on...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.