Solved

Retrieve values from an XML header for display in data rows

Posted on 2011-09-27
3
199 Views
Last Modified: 2012-05-12
I have an XML that consists of two primary nodes: MessageHeader and MessagePayload.  I want to create a comma delimited file of the rows from the MessagePayload.  With each row from the MessagePayload I want to include the Source and DateTime values from the MessageHeader.  This seems rather trivial, but I cannot figure out how to get the values from the Header for each row in the Payload.  Can someone please show me how to accomplish this?  Attached is a sample XML file and the XSL that I have been working with.  sample.xml   sampleBillDeterminant.xsl
0
Comment
Question by:raincloud2011
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 125 total points
ID: 36712249

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:st="http://www.caiso.com/soa/2007-03-12/BillDeterminantData.xsd"
    exclude-result-prefixes="st">
    <xsl:output method="text"/>
    <xsl:template match="st:BillDeterminantData">
         <xsl:apply-templates select="st:MessagePayload"/>
    </xsl:template>
    
    <xsl:template match="st:MessagePayload">
        <xsl:for-each select="st:BillDeterminant">
            <xsl:text>&#10;</xsl:text>
            <xsl:text>"</xsl:text>
            <xsl:value-of select="/st:BillDeterminantData/st:MessageHeader/st:TimeDate"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="/st:BillDeterminantData/st:MessageHeader/st:Source"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@name"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@mrid"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@dataType"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@settlementVer"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@dataSource"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@uom"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@calcLevel"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@precisionLevel"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@configVer"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@intervalCount"/>
            <xsl:text>","</xsl:text>
            <xsl:value-of select="@PTBComments"/>
            <xsl:text>"</xsl:text>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:raincloud2011
ID: 36712394
Awesome; that is perfect.  Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36712939
welcome
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question