Neuron ESB User Network

The Service Bus for the Connected Business

I am, by no means, even a good xml programmer.  In that I currently have a xml document being imported via http that I need to run through the XSL Transformation to get my needed output.

 

I've attached the input XML, the XSLT and the current output that I'm getting (which is nothing like expected).

 

Anybody who is an 'expert' at this stuff ... Your help would be greatly appreciated!

Views: 247

Attachments:

Reply to This

Replies to This Discussion

so...what exactly is the output supposed to look like?

If it only had one properties node the oout would look like:

 

  <Root>
    <Row>
     <ProfitCenter>
      4000
     </ProfitCenter>
     <CostCenter \>
     <PostingDate>
      2015-05-19T00:00:00
     </PostingDate>
     <JournalEntryType>
      Goods Receipt/Invoice Receipt Clearing
     </JournalEntryType>
     <GLAccount>
      500000000002
     </GLAccount>
     <Period>
      5
     </Period>
     <Balance>
      -321.36
     </Balance>
    </Row>
  </Root>

so there seems to be lots of problems with the source document.  you're using use the atom namespace for the default namespace which isn't going to work...so first thing....remove 

xmlns="http://www.w3.org/2005/Atom" from the source doc.

next, you want to first copy over the data you need.....the xslt has to build the document you want. yours wasn't doing that...hhence all you saw was text. an easy way to do that...is use templates...like so:

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

next....the select statement you were using i.e. 

select="entry/content/properties", would never find the node.  basically this needs to be an xpath that can resolve to your document.  there's some free online tools out there....but one that can be used to create valid xpaths for you...is this:
http://xmltoolbox.appspot.com/xpath_generator.html

once you figure out the valid xpath...then the nodes can be found and you can rename them...creating the hierarchy you wwant. after I removed the atom namespace (you could also just add a default namespace as well) , I created the xslt below:



<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0"/>



<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match= "/feed/entry/content[@type='application/xml']/properties">
<row>
<ProfitCenter>
<xsl:value-of select="CPROFITCTR_UUID"/>
</ProfitCenter>
<CostCenter>
<xsl:value-of select="CCOST_CTR_UUID"/>
</CostCenter>
<PostingDate>
<xsl:value-of select="CPOSTING_DATE"/>
</PostingDate>
<JournalEntryType>
<xsl:value-of select="TACCDOCTYPE"/>
</JournalEntryType>
<GLAccount>
<xsl:value-of select="CACC_DOC_UUID"/>
</GLAccount>
<Period>
<xsl:value-of select="CFISCPER"/>
</Period>
<Balance>
<xsl:value-of select="KCBALANCE_CURRCOMP"/>
</Balance>
</row>
</xsl:template>

</xsl:stylesheet>








What if I wanted every properties node set up as a new row, not just one?

I believe that's what the xslt is doing

OK, I see that your xsl works, except, I don't want all the peripheral junk put into my output xml.  All I want is a simple xml that look like the attached file that pulls the needed data out of the input document and trashes everything else.

Attachments:

I think this is what you want...

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0"/>

<xsl:template match="/">

<xsl:copy-of select="/feed/entry/content[@type='application/xml']/node()"/>

</xsl:template>

<xsl:template match="/">
<root>
<xsl:for-each select="/feed/entry/content[@type='application/xml']/properties">
<row>
<ProfitCenter>
<xsl:value-of select="CPROFITCTR_UUID"/>
</ProfitCenter>
<CostCenter>
<xsl:value-of select="CCOST_CTR_UUID"/>
</CostCenter>
<PostingDate>
<xsl:value-of select="CPOSTING_DATE"/>
</PostingDate>
<JournalEntryType>
<xsl:value-of select="TACCDOCTYPE"/>
</JournalEntryType>
<GLAccount>
<xsl:value-of select="CACC_DOC_UUID"/>
</GLAccount>
<Period>
<xsl:value-of select="CFISCPER"/>
</Period>
<Balance>
<xsl:value-of select="KCBALANCE_CURRCOMP"/>
</Balance>
</row>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

Perfect!  Thank you, kind sir.

you owe me a beer :)

RSS

Neuron ESB Product Support Forums and Communities

Latest Activity

Anupama Nair posted a discussion

Marketo Adapter Invalid Token

Hi,We are using the Marketo adapter to push account updates to Marketo. It works well for some time then starts failing with Invalid Token unless restarted. Is there a configuration that can be done so it can auto refresh the token when required?Thanks!See More
Nov 6, 2023
Sayantini Basak posted a discussion

Maximum payload size(REST API) for requests interfacing to NeuronESB

I am new to Neuron ESB and in our current scenario,We need to process batch transactions comprising of ~1000 records and send them to Neuron ESB for further processing. I would like to understand what is the maximum size of payload that can be transferred using REST interface to Neuron ESB.See More
Jul 22, 2022
Profile IconRobert E Dunie and Sayantini Basak joined Neuron ESB User Network
Apr 28, 2022
Profile IconDayanand, Frederic C, Steffen Greve-Oksfeldt and 1 more joined Neuron ESB User Network
Mar 16, 2022
Profile IconCam Vong and Mitja Luznar joined Neuron ESB User Network
Jan 27, 2022
Profile IconWill Hitzges, Chad Parsons, michael larsen and 4 more joined Neuron ESB User Network
Jun 11, 2021
Anupama Nair posted a discussion

ODBC stored proc polling with temporary tables

We have set up an ODBC adapter to poll a stored proc.We found that if the stored proc has a temporary table defined the rows returned are always 0.Any idea why this would be and what we can do to get around it?See More
Dec 14, 2020
Prasanth Kharade is now a member of Neuron ESB User Network
Dec 30, 2019

Badge

Loading…

© 2024   Created by Neuron Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service