| 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]
|
|
|
|