Solved

Retrieve values from an XML header for display in data rows

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT: Is it possible to assign number format from a variable? 5 53
Macro to import XML in Access 2013 2 81
Wordpress Hacked 1 87
parsing xml using powershell 6 54
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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