473,789 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ***
<GetNamedProfil eReturn>
<NamedProfile >
<ProfileId>1155 12</ProfileId>
<ProfileRef>
<ProfileName>De wpoint</ProfileName>
<ProfileType>BT U|Weather Data</ProfileType>
</ProfileRef>
<LastModified>2 007-08-01T10:00:05</LastModified>
<Version>5693 </Version>
<DataTypeCode>N </DataTypeCode>
<PeriodTypeCode >H</PeriodTypeCode>
<SummarizeTypeC ode>A</SummarizeTypeCo de>
<ReferenceUOM/>
<ReferenceSumma rizedUOM/>
<DecimalPrecisi on>0</DecimalPrecisio n>
<Description>Ho urly 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>
</GetNamedProfile Return>

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

<xsl:styleshe et 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:GetNam edProfileRespon se">
<NamedProfileLi st>
<xsl:apply-templates select=".//x:Entry"/>
</NamedProfileLis t>
</xsl:template>

<xsl:template match="x:Entry" >
<NamedProfile >
<ProfileID><xsl :value-of select="../../x:ProfileId"/></
ProfileID>
<Name><xsl:valu e-of select="../../x:ProfileRef/x:ProfileName"/></
Name>
<Type><xsl:valu e-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:val ue-of select="x:Value "/></Value>
</NamedProfile>
</xsl:template>
</xsl:stylesheet>

*** What I want the output to look like ****
<NamedProfileLi st>
<NamedProfile >
<ProfileID>1155 12</ProfileID>
<Name>Dewpoin t</Name>
<Type>BTU|Weath er Data</Type>
<StartTime>20 07-07-30T00:00:00</StartTime>
<StopTime>200 7-07-30T01:00:00</StopTime>
<Value>0.00</Value>
</NamedProfile>
</NamedProfileLis t>

....instead of
<NamedProfileLi st>
<NamedProfile >
<ProfileID>1155 12</ProfileID>
<Name>Dewpoin t</Name>
<Type>BTU|Weath er Data</Type>
<StartTime>20 07-07-30T00:00:00</StartTime>
<StopTime>200 7-07-30T01:00:00</StopTime>
<Value/>
</NamedProfile>
</NamedProfileLis t>

Aug 3 '07 #1
2 1826
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.0 0</xsl:text>
<xsl:when>
<xsl:otherwis e>
<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.s ilmaril.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.0 0</xsl:text>
<xsl:when>
<xsl:otherwis e>
<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
2749
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 straight XML file http://www.discovertravelandtours.com/test/templates/test.xml?Location=Germany To another XML file http://www.discovertravelandtours.com/test/templates/test2.xml?Location=Germany
4
1833
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
1467
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 problem is i need to transform a xml file from this: <root>
5
1351
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 transCart = new XslTransform(); transCart.Load(Server.MapPath("1.xslt")); showCart.Document = cartFromSession;
7
1250
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 can neither locate the xslt file or the css file needed to get the desired results. What's the problem? Can anyone help me? Thanks, Roshawn
1
1414
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) <Flights> <Flight> <FlightLeg > <BookingClassCodeList> <BookingCode Value="C" /> <BookingCode Value="Y" /> </BookingClassCodeList>
6
1642
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 stage that I really need expert help on what is the thing that I might be missing or not understand. Basically, my desired output is to get the text into the WORD tags like this: <WORD coords="559,518,641,629">12</WORD> <WORD...
2
2365
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 resulting nodes using xslt. In my example below I only want the Academic category to be transformed. Is this possible? (please vb.net or c#). Many thanks. My xml file: <categories> <category> <categorynumber>1</categorynumber> ...
4
1732
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 way I can club them together in a presentable format for reporting purpose ? So for .g. a.xml, b.xml, c.xml and d.xml. These xmls I want to display in an html report say report.html in a 4 columns in java.
2
1999
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 line 142 (line 12 in snippet) the error is caused by this call: empty($inSeite_inp->getValue('PAR_NAME')) method definition see second snippet, lines 142 to 166
0
9511
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
10408
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
10199
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
10139
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
9983
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
6769
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
5417
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...
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.