Solved

Retrieve values from an XML header for display in data rows

Posted on 2011-09-27
3
194 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
Comment Utility

<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
Comment Utility
Awesome; that is perfect.  Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
welcome
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

12 Experts available now in Live!

Get 1:1 Help Now