Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2010, 06:03 PM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get preceding node child element value

[FONT='Arial','sans-serif']Folks, I need your help:[/FONT]

[FONT='Arial','sans-serif']I am trying to get the preceding node child element value (sourceList/source/sourceID/text(). I am in a for loop but need two values based upon some specific condition but I am not getting the expected result. The variable is coming back with blank. [/FONT]
[FONT='Arial','sans-serif']Also, my xml has a namespace so the root element is not firing when I do template match. I temporarily removed the namespace so it is working in order to make some progress.[/FONT]
[FONT='Arial','sans-serif']Please help with the preceding node issue and namespace.[/FONT]
[FONT='Arial','sans-serif']XML with out the name space (this is the one that I am using to get the preceding node value[/FONT]
<?xml version="1.0"?>
<MultiSpeakMessageHeader>
<TimeStamp>2010-05-25T09:25:08.440-04:00</TimeStamp>
<DocumentID>Show20100525</DocumentID>
<VendorApp>
<AppName>SerViewCom</AppName>
<AppVersion>1.60.7-12613</AppVersion>
<Company>Trilliant Networks</Company>
<Function>LP-CB</Function>
</VendorApp>
<Batch>
<MultiSpeak documentType="dump">
<profileObject objectID="891208672">
<extensions>
<to>2010-04-06T09:24:10.00-04:00</to>
<meterSerialNumber>44725237</meterSerialNumber>
<from>2010-04-05T09:24:10.00-04:00</from>
</extensions>
<sourceList>
<source>
<sourceID>1</sourceID>
<quantityType>summation</quantityType>
<uom>Wh</uom>
<accountability>Q1-4</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>2</sourceID>
<quantityType>summation</quantityType>
<uom>VARh</uom>
<accountability>Q1-2</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>3</sourceID>
<quantityType>summation</quantityType>
<uom>Wh</uom>
<accountability>Q2-3</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>4</sourceID>
<quantityType>summation</quantityType>
<uom>VARh</uom>
<accountability>Q3-4</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
</sourceList>
<loadProfileList>
<loadProfile>
<meterID>891208672</meterID>
<dataSetNumber>1</dataSetNumber>
<channelList>
<channel channelNumber="1" endReadingSourceID="1" intervalSourceID="1">
<blockList>
<block endReading="1.820962347134453E7" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">249.3</interval>
<interval DSTinEffect="true">246.0</interval>
</block>
</blockList>
</channel>
<channel channelNumber="2" endReadingSourceID="2" intervalSourceID="2">
<blockList>
<block endReading="5632062.233924266" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">72.0</interval>
<interval DSTinEffect="true">68.4</interval>
</block>
</blockList>
</channel>
<channel channelNumber="3" endReadingSourceID="3" intervalSourceID="3">
<blockList>
<block endReading="0.0" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
</block>
</blockList>
</channel>
<channel channelNumber="4" endReadingSourceID="4" intervalSourceID="4">
<blockList>
<block endReading="0.0" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
</block>
</blockList>
</channel>
</channelList>
</loadProfile>
</loadProfileList>
</profileObject>
</MultiSpeak>
</Batch>
</
MultiSpeakMessageHeader>

[FONT='Arial','sans-serif']XSLT code
[FONT='Arial','sans-serif']<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" xmlns:lsxd="xalan://com.lodestarcorp.core.xml.xslt" exclude-result-prefixes="java lsxd">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="MultiSpeakMessageHeader">
<ROOT>
<xsl:apply-templates select="Batch/MultiSpeak/profileObject"/>
</ROOT>
</xsl:template>
<!-- Meter Readings Template -->
<xsl:template match="Batch/MultiSpeak/profileObject">
<!-- Parameter Names -->
<xsl:param name="effectiveDate" select="extensions/to"/>
<xsl:param name="startReadTime" select="extensions/from"/>
<xsl:for-each select="loadProfileList/loadProfile/channelList/channel/blockList">
<xsl:variable name="stopval" select="block/@endReading"/>
<xsl:variable name="spi" select="block/@intervalPeriod * 60"/>
<!--<xsl:variable name="rawDcflow" select="block/@intervalPeriod * 60"/>-->
<xsl:variable name="meterID" select="../../../meterID"/>
<xsl:variable name="testID" select="preceding::sourceList/source/sourceID/text()"/>
<xsl:variable name="sourceID" select="../@intervalSourceID"/>
<xsl:variable name="rawuomName">
<xsl:for-each select="preceding::sourceList/source">
<xsl:text>scott</xsl:text>
<!-- sourceList/source sourceID/text() -->
<xsl:if test="sourceID/text() = $sourceID">
<xsl:value-of select="uom"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="rawDCflow">
<xsl:for-each select="preceding::sourceList/source">
<xsl:if test="sourceID/text() = $sourceID">
<xsl:value-of select="accountability"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="dcflowDecode">
<xsl:call-template name="decodeDCFLOW">
<xsl:with-param name="rawDCFlowName" select="$rawDCflow"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="uomCode">
<xsl:call-template name="decodeUom">
<xsl:with-param name="uomName" select="$rawuomName"/>
</xsl:call-template>
</xsl:variable>
<BIRD>
<xsl:attribute name="HEADERSERIALNUMBER"><xsl:value-of select="$meterID"/></xsl:attribute>
<xsl:attribute name="CHANNELID"><xsl:value-of select="$sourceID"/></xsl:attribute>
<xsl:attribute name="UOMCODE"><xsl:value-of select="$uomCode"/></xsl:attribute>
<xsl:attribute name="USAGETYPECODE"><xsl:text>INTERVAL</xsl:text></xsl:attribute>
<xsl:attribute name="EFFECTIVEDATE"><xsl:value-of select="$effectiveDate"/></xsl:attribute>
<METERREADS>
<METERREAD>
<xsl:attribute name="SPI"><xsl:value-of select="$spi"/></xsl:attribute>
<xsl:attribute name="STOPVAL"><xsl:value-of select="$stopval"/></xsl:attribute>
<xsl:attribute name="STARTREADTIME"><xsl:value-of select="$startReadTime"/></xsl:attribute>
<xsl:attribute name="STOPREADTIME"><xsl:value-of select="$effectiveDate"/></xsl:attribute>
<xsl:attribute name="DCFLOW"><xsl:value-of select="$dcflowDecode"/></xsl:attribute>
<!-- Hardcoded DSTPARTICIPANT and TZSTDNAME -->
<xsl:attribute name="DSTPARTICIPANT"><xsl:text>Y</xsl:text></xsl:attribute>
<xsl:attribute name="ORIGIN"><xsl:text>M</xsl:text></xsl:attribute>
<xsl:attribute name="SERIALNUMBER"><xsl:value-of select="$meterID"/></xsl:attribute>
<xsl:attribute name="READDATE"><xsl:value-of select="$effectiveDate"/></xsl:attribute>
<INTS>
<xsl:for-each select="block/interval">
<xsl:variable name="rawReading">
<xsl:value-of select="text()"/>
</xsl:variable>
<I>
<xsl:attribute name="V"><xsl:value-of select="$rawReading"/></xsl:attribute>
</I>
</xsl:for-each>
</INTS>
</METERREAD>
</METERREADS>
</BIRD>
</xsl:for-each>
<!--<xsl:apply-templates/>-->
</xsl:template>

[FONT='Arial','sans-serif']XML with name space (this is the one where the root element will not fire
<?xml version="1.0"?>
<MultiSpeakMessageHeader xmlns="http://www.multispeak.org/Schema/Version2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.2">
<TimeStamp>2010-05-25T09:25:08.440-04:00</TimeStamp>
<DocumentID>Show20100525</DocumentID>
<VendorApp>
<AppName>SerViewCom</AppName>
<AppVersion>1.60.7-12613</AppVersion>
<Company>Trilliant Networks</Company>
<Function>LP-CB</Function>
</VendorApp>
<Batch>
<MultiSpeak documentType="dump">
<profileObject objectID="891208672">
<extensions>
<to>2010-04-06T09:24:10.00-04:00</to>
<meterSerialNumber>44725237</meterSerialNumber>
<from>2010-04-05T09:24:10.00-04:00</from>
</extensions>
<sourceList>
<source>
<sourceID>1</sourceID>
<quantityType>summation</quantityType>
<uom>Wh</uom>
<accountability>Q1-4</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>2</sourceID>
<quantityType>summation</quantityType>
<uom>VARh</uom>
<accountability>Q1-2</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>3</sourceID>
<quantityType>summation</quantityType>
<uom>Wh</uom>
<accountability>Q2-3</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
<source>
<sourceID>4</sourceID>
<quantityType>summation</quantityType>
<uom>VARh</uom>
<accountability>Q3-4</accountability>
<transformerRatio>
<applied>false</applied>
<ct>1.0</ct>
<pt>1.0</pt>
</transformerRatio>
<displayFormat>
<supressLeadingZero>true</supressLeadingZero>
<numberOfDigits>5</numberOfDigits>
<precision>0</precision>
<displayMultiplier>1000.0</displayMultiplier>
</displayFormat>
<multiplierApplied>false</multiplierApplied>
</source>
</sourceList>
<loadProfileList>
<loadProfile>
<meterID>891208672</meterID>
<dataSetNumber>1</dataSetNumber>
<channelList>
<channel channelNumber="1" endReadingSourceID="1" intervalSourceID="1">
<blockList>
<block endReading="1.820962347134453E7" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">249.3</interval>
<interval DSTinEffect="true">246.0</interval>
</block>
</blockList>
</channel>
<channel channelNumber="2" endReadingSourceID="2" intervalSourceID="2">
<blockList>
<block endReading="5632062.233924266" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">72.0</interval>
<interval DSTinEffect="true">68.4</interval>
</block>
</blockList>
</channel>
<channel channelNumber="3" endReadingSourceID="3" intervalSourceID="3">
<blockList>
<block endReading="0.0" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
</block>
</blockList>
</channel>
<channel channelNumber="4" endReadingSourceID="4" intervalSourceID="4">
<blockList>
<block endReading="0.0" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
<interval DSTinEffect="true">0.0</interval>
</block>
</blockList>
</channel>
</channelList>
</loadProfile>
</loadProfileList>
</profileObject>
</MultiSpeak>
</Batch>
</
MultiSpeakMessageHeader>
[/FONT][/FONT][/FONT]

Last edited by smandeh; June 8th, 2010 at 06:09 PM..
Reply With Quote
  #2 (permalink)  
Old June 8th, 2010, 06:40 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

For the namespace problem, please google "FAQ XSLT default namespace".

For the other problem, please supply a simplified example. There's much to much code here for anyone to wade through. You'll find it easier to understand the problem yourself if you reduce it to essentials.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #3 (permalink)  
Old June 8th, 2010, 10:00 PM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For some reason I can not edit my previous post so I had posted a shorter version of my xml and xslt.

xml

<?xml version="1.0" encoding="UTF-8"?>
<MultiSpeakMessageHeader>
<Batch>
<MultiSpeak documentType="dump">
<profileObject objectID="891208672">
<sourceList>
<source>
<sourceID>1</sourceID>
<quantityType>summation</quantityType>
<uom>Wh</uom>
<accountability>Q1-4</accountability>
</source>
<source>
<sourceID>2</sourceID>
<quantityType>summation</quantityType>
<uom>VARh</uom>
<accountability>Q1-2</accountability>
</source>
</sourceList>
<loadProfileList>
<loadProfile>
<meterID>891208672</meterID>
<dataSetNumber>1</dataSetNumber>
<channelList>
<channel channelNumber="1" endReadingSourceID="1" intervalSourceID="1">
<blockList>
<block endReading="1.820962347134453E7" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">249.3</interval>
<interval DSTinEffect="true">246.0</interval>
</block>
</blockList>
</channel>
<channel channelNumber="2" endReadingSourceID="2" intervalSourceID="2">
<blockList>
<block endReading="5632062.233924266" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">72.0</interval>
<interval DSTinEffect="true">68.4</interval>
</block>
</blockList>
</channel>
</channelList>
</loadProfile>
</loadProfileList>
</profileObject>
</MultiSpeak>
</Batch>
</
MultiSpeakMessageHeader>

xslt code

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" xmlns:lsxd="xalan://com.lodestarcorp.core.xml.xslt" exclude-result-prefixes="java lsxd">
<
xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<
xsl:template match="MultiSpeakMessageHeader">
<
ROOT>
<
xsl:apply-templates select="Batch/MultiSpeak/profileObject"/>
</
ROOT>
</
xsl:template>
<!--
Meter Readings Template -->
<
xsl:template match="Batch/MultiSpeak/profileObject">
<xsl:for-each select="loadProfileList/loadProfile/channelList/channel/blockList">
<
xsl:variable name="stopval" select="block/@endReading"/>
<
xsl:variable name="spi" select="block/@intervalPeriod * 60"/>
<
xsl:variable name="sourceID" select="../@intervalSourceID"/>
<xsl:variable name="rawuomName">
<
xsl:for-each select="preceding::sourceList/source">
<
xsl:if test="sourceID/text() = $sourceID">
<
xsl:value-of select="uom"/>
</
xsl:if>
</
xsl:for-each>
</
xsl:variable>
</
xsl:template>
Reply With Quote
  #4 (permalink)  
Old June 9th, 2010, 06:12 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

There are no relevant templates to the below template calls:
Code:
<xsl:call-template name="decodeDCFLOW">
 
<xsl:call-template name="decodeUom">
Your need is bit unclear. Post the required output you need after transformation.
__________________
Rummy
Reply With Quote
  #5 (permalink)  
Old June 9th, 2010, 08:38 AM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rummy,

As per Kay suggestion I posted a shorter verion of the code. Below is a clearer version of my input file: All I am trying to do is how to get the SourceList/Source/SourceID/text() from loadProfileList/loadProfile/channelList/channel/blockList in a for loop based upon a test condition. Because the SourceList has multiple source nodes, I have to loop through it to get the value that I want.

<?xml version="1.0" encoding="UTF-8" ?>
- <MultiSpeakMessageHeader>
- <Batch>
- <MultiSpeak documentType="dump">
- <profileObject objectID="891208672">
- <sourceList>
- <source>
<sourceID>1</sourceID>

<quantityType>summation</quantityType>

<uom>Wh</uom>

<accountability>Q1-4</accountability>

</source>


- <source>
<sourceID>2</sourceID>

<quantityType>summation</quantityType>

<uom>VARh</uom>

<accountability>Q1-2</accountability>

</source>


</sourceList>


- <loadProfileList>
- <loadProfile>
<meterID>891208672</meterID>

<dataSetNumber>1</dataSetNumber>

- <channelList>
- <channel channelNumber="1" endReadingSourceID="1" intervalSourceID="1">
- <blockList>
- <block endReading="1.820962347134453E7" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">249.3</interval>

<interval DSTinEffect="true">246.0</interval>

</block>


</blockList>


</channel>


- <channel channelNumber="2" endReadingSourceID="2" intervalSourceID="2">
- <blockList>
- <block endReading="5632062.233924266" endTime="2010-04-05T14:45:00.00-04:00" intervalPeriod="15" sequenceNumber="670">
<interval DSTinEffect="true">72.0</interval>

<interval DSTinEffect="true">68.4</interval>

</block>


</blockList>


</channel>


</channelList>


</loadProfile>


</loadProfileList>


</profileObject>


</MultiSpeak>


</Batch>


</MultiSpeakMessageHeader>
Reply With Quote
  #6 (permalink)  
Old June 9th, 2010, 08:50 AM
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

I suggest you define and use a key so put
Code:
<xsl:key name="k1" match="source" use="sourceID"/>
as a child of your xsl:stylesheet or xsl:transform element, then use the "key" function to find the "source" element you are looking for e.g.
Code:
<xsl:for-each select="loadProfileList/loadProfile/channelList/channel/blockList">


<xsl:variable name="rawuomName" select="key('k1', ../@intervalSourceID)/uom"/>

</xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #7 (permalink)  
Old June 9th, 2010, 09:08 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

I meant the xslt code you posted first did not have relevant templates to "decodeDCFLOW" and "decodeUom".

Next, I could not find anything wrong in the code. With the below code
Code:
<xsl:template match="MultiSpeakMessageHeader">
<ROOT>
<xsl:apply-templates select="Batch/MultiSpeak/profileObject"/>
</ROOT>
</xsl:template>
<!-- Meter Readings Template -->
<xsl:template match="Batch/MultiSpeak/profileObject">
<xsl:for-each select="loadProfileList/loadProfile/channelList/channel/blockList">
<xsl:variable name="stopval" select="../@intervalSourceID"/>
<xsl:variable name="rawuomName">
<xsl:for-each select="preceding::sourceList/source[sourceID = $sourceID]">
<xsl:value-of select="uom"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$rawuomName"/>
</xsl:for-each>
</xsl:template>
I got the below output
Code:
<ROOT>WhVARh</ROOT>
I used the simplified input you have posted.
__________________
Rummy
Reply With Quote
  #8 (permalink)  
Old June 9th, 2010, 09:50 AM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Martin,

Thank you so much. I used the key as you suggested and it is working as expected.

Also, thanks Kay and Rummy for your inputs.

Regards,
smandeh
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find child node when there is mentioned (child::*) mlohokare XSLT 3 May 12th, 2009 12:40 PM
Accessing a node bases on child node value musman0047 XSLT 1 February 27th, 2009 12:26 PM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
counting the preceding cousins of an element muki XSLT 1 June 15th, 2006 02:29 AM



All times are GMT -4. The time now is 10:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.