Solved

Retrieve values from an XML header for display in data rows

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Conditional Formatting 4 41
JPA XML tag definition 2 69
Help with MSXML and Visual Studio 2013 1 49
Excel file not created as expected 7 72
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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