Solved

Retrieve values from an XML header for display in data rows

Posted on 2011-09-27
3
195 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now