BizTalk Server General - inline xslt help in mapper

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > January 2005 > inline xslt help in mapper





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author inline xslt help in mapper
jeremy

2005-01-19, 5:51 pm

In the following sample, I have a multiple invoice file that has 1 header
record and a repeating detail record for each invoice. Can someone help me
using inline xslt to sum the detail records of each invoice so that I can get
the total for each invoice. I have seen how to do this just using xslt
instead of the mapper, but I would like to do this within the mapper as I
have other functoids that I am using. It appears I cannot get the cumulative
sum functoid to sum each invoice with the scope parameter; instead it always
seems to sum the entire file or nothing at all.

inbound:

<?xml version="1.0" encoding="UTF-8"?>
<Invoices>
<Invoice>
<Header>
<Credit>-20</Credit>
</Header>
<Detail>
<Debit>10</Debit>
</Detail>
<Detail>
<Debit>9</Debit>
</Detail>
<Detail>
<Debit>1</Debit>
</Detail>
</Invoice>
<Invoice>
<Header>
<Credit>-10</Credit>
</Header>
<Detail>
<Debit>7</Debit>
</Detail>
<Detail>
<Debit>3</Debit>
</Detail>
</Invoice>
</Invoices>


outbound xml:

<?xml version="1.0" encoding="UTF-8"?>
<Invoices>
<TotalFileCredit>-30</TotalFileCredit>
<TotalFileDebit>30</TotalFileCredit>
<Invoice>
<TotalInvoiceCredit>-20</TotalInvoiceCredit>
<TotalInvoiceDebit>20</TotalInvoiceDebit>
<Header>
<Credit>-20</Credit>
</Header>
<Detail>
<Debit>10</Debit>
</Detail>
<Detail>
<Debit>9</Debit>
</Detail>
<Detail>
<Debit>1</Debit>
</Detail>
</Invoice>
<Invoice>
<TotalInvoiceCredit>-10</TotalInvoiceCredit>
<TotalInvoiceDebit>10</TotalInvoiceDebit>
<Header>
<Credit>-10</Credit>
</Header>
<Detail>
<Debit>7</Debit>
</Detail>
<Detail>
<Debit>3</Debit>
</Detail>
</Invoice>
</Invoices>

jeremy

2005-01-19, 5:51 pm

Greg,

This worked great..Thank you.

Could you explain the line in the xslt template:
<xsl:template match="/*[local-name()='Invoices' and
namepace-uri()='']/*[local-name()='Invoice' and namespace-uri()='']"
name="InvoiceSum">

I am not sure where "InvoiceSum" comes into play as it doesnt exist in the
source or destination xml schemas?

"Greg Forsythe" wrote:

> Try the map in this attachment with the example invoice shown.
>
> Greg
>
> "jeremy" <jeremy@discussions.microsoft.com> wrote in message
> news:81162EBD-70FC-4F42-A9A0-CF01C5017F6E@microsoft.com...
> me
> get
> cumulative
> always
>
>
>

Jonathan Wu

2005-01-19, 8:47 pm

I have tried this map

[IMG]http://img132.exs.cx/img132/5792/mapinvoice3zr.jpg[/IMG]

And used the following inline xslt template:

<xsl:template name="MyXsltConcatTemplate">
<xsl:param name="param1" />
<xsl:element name="ns0:TotalInvoiceDebit"
namespace="http://www.google.com">
<xsl:value-of
select="sum(*[local-name()='Detail']/*[local-name()='Debit'])" />
</xsl:element>
</xsl:template>


Jonathan Wu
http://biztalkshow.blogspot.com

Greg Forsythe

2005-01-20, 2:50 am

The "InvoiceSum" is just the name of the template, the mapper uses the
xsl:call-template which uses the template name.
The match="/*[local-name()='Invoices' and
namepace-uri()='']/*[local-name()='Invoice' and namespace-uri()='']" part of
the template is probably redundant

Greg

"jeremy" <jeremy@discussions.microsoft.com> wrote in message
news:D9082B21-EB98-49A5-A22A-A31FD9E8BB60@microsoft.com...[vbcol=seagreen]
> Greg,
>
> This worked great..Thank you.
>
> Could you explain the line in the xslt template:
> <xsl:template match="/*[local-name()='Invoices' and
> namepace-uri()='']/*[local-name()='Invoice' and namespace-uri()='']"
> name="InvoiceSum">
>
> I am not sure where "InvoiceSum" comes into play as it doesnt exist in the
> source or destination xml schemas?
>
> "Greg Forsythe" wrote:
>
header[vbcol=seagreen]
help[vbcol=seagreen]
can[vbcol=seagreen]
xslt[vbcol=seagreen]
as I[vbcol=seagreen]


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com