T
TexasAggie96
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</Value> and
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">
<xslutput 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="../../xrofileId"/></
ProfileID>
<Name><xsl:value-of select="../../xrofileRef/xrofileName"/></
Name>
<Type><xsl:value-of select="../../xrofileRef/xrofileType"/></
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>
tags that are empty (ie <Value/>) default to <Value>0.00</Value> and
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">
<xslutput 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="../../xrofileId"/></
ProfileID>
<Name><xsl:value-of select="../../xrofileRef/xrofileName"/></
Name>
<Type><xsl:value-of select="../../xrofileRef/xrofileType"/></
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>