BizTalk Server General - XSLT scripting functoid.

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > June 2006 > XSLT scripting functoid.





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 XSLT scripting functoid.
Paul

2006-06-11, 1:21 pm

After tunig and tweeking some xslt statements for a while now, I am at a
loss getting it to work. I don't really know any XSLT apart from what I see
biztalk generates from the various functoids. Trying to pick and place from
this, unfortunately still doesnt quite do it in this scenario.

I have two input files, mapping to one output file. The reason for this is
that I gather input from two sources, and need to merge this into one return
xml. Seems like this is not biztalk's strong point. First of all there is no
way to extend an existing map with another input message. you have to throw
away all you have done, and start over from a transform shape in an
orchestration (not to mention what to do if you're not even using an
orchestration :-S). And when you have the new mapping up and running - now
there is no way to test it like with a standard 1to1 mapping - you have to
deploy for every time you have done a change - and this is the core of my
problem - with my limited XSLT knowledge it just takes for ever getting
there by trial and error. So I was hoping for some help.

The thing is that with two input files, both with repeating structures,
biztalk only bothers to run through the instances of the first input file -
the second could have a milion instances of a repeating structure without
biztalk caring for more than the first. So comparing instances from the
first message with the second using functoids in a mapping is useless. I
tried searching for help - and some guy said "you have to use xslt call
template scripting fuctoid", without further details. so here I am - how to
say the following in XSLT:

message1
repeating structure
a
b

message2
repeating structure
c
d

for every instance of a repeating structure in message 1, compare with every
instance of the repeating structure in message2; a=c? - if there is a match,
then combine info b and d into the output message.

This would take any one of us like 5 seconds to do in C#, but it is
seemingly impossible in biztalk.
Any help would be greatly apprechiated.


Greg Forsythe

2006-06-13, 7:22 am

Paul,

Mapping two messages into one is not a standard feature of Xslt. It is a
feature of Biztalk.
Basically the two messages are added as children to a <root> node on a
temporary message.
<root>
<message1/>
<message2/>
</root>
Then this message is transformed.
You have to use a orchestration as this is the only place that will merge
the messages. A pipeline only has one message.

There is an example Xslt below, that will do what you want
You will need to use the customXslt feature of a Biztalk Map to implement.
You need to create a map using the orchestration to specify the two input
messages.
Use the Validate Map to generate the Xslt and then edit this file.

<?xml version="1.0" encoding="UTF-16" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var s0" version="1.0"
xmlns:s0="http://Schema1" xmlns:ns0="http://Schema2">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:key name="matchkey" match="/s0:root/message2/record" use="c"/>
<xsl:template match="/">
<xsl:apply-templates select="/s0:root" />
</xsl:template>
<xsl:template match="/s0:root">
<ns0:Root>
<xsl:for-each select="message1/record">
<xsl:variable name="group" select="key('matchkey', a)"/>
<Record>
<ac>
<xsl:value-of select="a/text()" />
</ac>
<b>
<xsl:value-of select="b/text()" />
</b>
<xsl:for-each select="$group">
<d>
<xsl:value-of select="d" />
</d>
</xsl:for-each>
</Record>
</xsl:for-each>
</ns0:Root>
</xsl:template>
</xsl:stylesheet>

Greg


"Paul" <Me@Communicate.no> wrote in message
news:%23J2TaFVjGHA.4276@TK2MSFTNGP03.phx.gbl...
> After tunig and tweeking some xslt statements for a while now, I am at a
> loss getting it to work. I don't really know any XSLT apart from what I
> see biztalk generates from the various functoids. Trying to pick and place
> from this, unfortunately still doesnt quite do it in this scenario.
>
> I have two input files, mapping to one output file. The reason for this is
> that I gather input from two sources, and need to merge this into one
> return xml. Seems like this is not biztalk's strong point. First of all
> there is no way to extend an existing map with another input message. you
> have to throw away all you have done, and start over from a transform
> shape in an orchestration (not to mention what to do if you're not even
> using an orchestration :-S). And when you have the new mapping up and
> running - now there is no way to test it like with a standard 1to1
> mapping - you have to deploy for every time you have done a change - and
> this is the core of my problem - with my limited XSLT knowledge it just
> takes for ever getting there by trial and error. So I was hoping for some
> help.
>
> The thing is that with two input files, both with repeating structures,
> biztalk only bothers to run through the instances of the first input
> file - the second could have a milion instances of a repeating structure
> without biztalk caring for more than the first. So comparing instances
> from the first message with the second using functoids in a mapping is
> useless. I tried searching for help - and some guy said "you have to use
> xslt call template scripting fuctoid", without further details. so here I
> am - how to say the following in XSLT:
>
> message1
> repeating structure
> a
> b
>
> message2
> repeating structure
> c
> d
>
> for every instance of a repeating structure in message 1, compare with
> every instance of the repeating structure in message2; a=c? - if there is
> a match, then combine info b and d into the output message.
>
> This would take any one of us like 5 seconds to do in C#, but it is
> seemingly impossible in biztalk.
> Any help would be greatly apprechiated.
>



Pankaj

2006-06-15, 1:19 pm

I am looking for Biztalk 2004 samples.

"Pankaj" wrote:
[vbcol=seagreen]
> Similar scenario I am facing. I want to pass multiple/repeating inputs in one
> xml and execute the rules through C# code. But, I only want to make one call
> to Rules Engine for output.
>
> Greg, do you have any sample links which covers this scenario?
>
> Will appreciate a lot.
>
> Pankaj
>
>
> "Greg Forsythe" wrote:
>
Pankaj

2006-06-15, 1:19 pm

Similar scenario I am facing. I want to pass multiple/repeating inputs in one
xml and execute the rules through C# code. But, I only want to make one call
to Rules Engine for output.

Greg, do you have any sample links which covers this scenario?

Will appreciate a lot.

Pankaj


"Greg Forsythe" wrote:

> Paul,
>
> Mapping two messages into one is not a standard feature of Xslt. It is a
> feature of Biztalk.
> Basically the two messages are added as children to a <root> node on a
> temporary message.
> <root>
> <message1/>
> <message2/>
> </root>
> Then this message is transformed.
> You have to use a orchestration as this is the only place that will merge
> the messages. A pipeline only has one message.
>
> There is an example Xslt below, that will do what you want
> You will need to use the customXslt feature of a Biztalk Map to implement.
> You need to create a map using the orchestration to specify the two input
> messages.
> Use the Validate Map to generate the Xslt and then edit this file.
>
> <?xml version="1.0" encoding="UTF-16" ?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
> xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
> exclude-result-prefixes="msxsl var s0" version="1.0"
> xmlns:s0="http://Schema1" xmlns:ns0="http://Schema2">
> <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
> <xsl:key name="matchkey" match="/s0:root/message2/record" use="c"/>
> <xsl:template match="/">
> <xsl:apply-templates select="/s0:root" />
> </xsl:template>
> <xsl:template match="/s0:root">
> <ns0:Root>
> <xsl:for-each select="message1/record">
> <xsl:variable name="group" select="key('matchkey', a)"/>
> <Record>
> <ac>
> <xsl:value-of select="a/text()" />
> </ac>
> <b>
> <xsl:value-of select="b/text()" />
> </b>
> <xsl:for-each select="$group">
> <d>
> <xsl:value-of select="d" />
> </d>
> </xsl:for-each>
> </Record>
> </xsl:for-each>
> </ns0:Root>
> </xsl:template>
> </xsl:stylesheet>
>
> Greg
>
>
> "Paul" <Me@Communicate.no> wrote in message
> news:%23J2TaFVjGHA.4276@TK2MSFTNGP03.phx.gbl...
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com