BizTalk Server Tools - Re: Multiple elements to single element (Biztalk Mapper)

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Tools > February 2004 > Re: Multiple elements to single element (Biztalk 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 Re: Multiple elements to single element (Biztalk Mapper)
Jan Eliasen

2004-02-08, 8:42 am

On Tue, 23 Dec 2003 12:34:32 -0700, "Eric Theil"
<etheil@3tsystems.com> wrote:

Could you try to attach your documentspecifications? That'll be 10
minutes less work for me :-)

>I'm trying to figure out a way to go from a collection of types and map that
>into a flat type. Here's the example:
>
>Input:
><DexRaces>
> <DexRace>
> <Code>1</Code>
> </DexRace>
> <DexRace>
> <Code>3</Code>
> </DexRace>
></DexRace>
>
>Desired Output:
><Monitoring>
> <Race1>true</Race1><!-- Inserted if the above Code value is 1 -->
> <Race2>false</Race2><!-- Inserted if the above Code value is 2 -->
> <Race3>true</Race3><!-- Inserted if the above Code value is 3 -->
> <Race4>false</Race4><!-- Inserted if the above Code value is 4 -->
> <Race5>false</Race5><!-- Inserted if the above Code value is 5 -->
></Monitoring>
>
>There can only be a single <DexRaces> element within the source, but
>multiple <DexRace> elements. The problem I'm running into with the Biztalk
>Mapper is that I need a way to loop through the <DexRace> elements, get the
><Code> value and then insert "true" or "false" into the corresponding
><Race[n]> element. When I use any of the functiods, the resulting xslt code
>loops through the <DexRace> elements for each <Race[n]> element, like this:
>
> <xsl:for-each select="DexRace">
> <xsl:variable name="var:v141"
>select="userJScript:CompareValues201("1",string(Code/text()))"/>
> <xsl:if test="string($var:v141)="true"">
> <xsl:variable name="var:v142" select=""true""/>
> <Race1><xsl:value-of select="$var:v142"/></Race1>
> </xsl:if>
> </xsl:for-each>
> <xsl:for-each select="DexRace">
> <xsl:variable name="var:v143"
>select="userJScript:CompareValues201("2",string(Code/text()))"/>
> <xsl:if test="string($var:v143)="true"">
> <xsl:variable name="var:v144" select=""true""/>
> <Race2><xsl:value-of select="$var:v144"/></Race2>
> </xsl:if>
> </xsl:for-each>
>
>I need something like this:
>
> <xsl:for-each select="DexRaces/DexRace">
> <xsl:choose>
> <xsl:when test="Code=1">
> <Race1>true</Race1>
> </xsl:when>
> <xsl:when test="Code=2">
> <Race2>true</Race2>
> </xsl:when>
> <...>
> </xsl:choose>
> </xsl:for-each>
>
>I'd do this manually, but we have too many existing mappings within the file
>and need to continue to use the Mapper. If I add the code, it's wiped out
>when I save the map. Any suggestions?
>
>Thanks,
>
>Eric
>
>


--
Jan Eliasen, representing himself and not the company he works for
Eric Theil

2004-02-08, 8:42 am

Thanks for responding Jan. I've been playing with this on and off and am not
having any luck. What I really need is a way to generate an xsl:choose block
using one or a combination of the functoids, but I just can't seem to find
anything. In essence, I need a way to go from multiple Elements on the left
side to one of a number of elements on the right depending on the value
within the left Element.

In essence, I need to take the DexRaces/DexRace/Code value, check that value
(which is 1 through 7) and then create the appropriate element within the
GOVERNMENT_MONITORING section. So, for instance, if the value of
DexRaces/DexRace/Code is 1 (and there can be 0 to many DexRace elements), I
need to write out a <RaceAIorANHMDA>true</RaceAIorANHMDA> element (there
will only be a single GOVERNMENT_MONITORING/RaceAIorANHMDA element; if the
DexRaces/DexRace/Code value is not present, the element is not added).

As for document specs, here are some schema excerpts:

From:
<ElementType name="DexRaces" content="eltOnly" order="many" model="closed">
<b:RecordInfo/>
<element type="DexRace" maxOccurs="*" minOccurs="0"/>
</ElementType>
<ElementType name="DexRace" content="eltOnly" order="many" model="closed">
<b:RecordInfo/>
<element type="Id" maxOccurs="*" minOccurs="0"/>
<element type="Code" maxOccurs="*" minOccurs="0"/>
<element type="DexCustomerElements" maxOccurs="*" minOccurs="0"/>
</ElementType>

to:
<element type="GOVERNMENT_MONITORING" maxOccurs="*" minOccurs="0"/>
<ElementType name="GOVERNMENT_MONITORING" content="eltOnly" order="many"
model="closed">
<b:RecordInfo/>
<element type="RaceAIorANHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceAIorAN" maxOccurs="*" minOccurs="0"/>
<element type="RaceAsianHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceAsian" maxOccurs="*" minOccurs="0"/>
<element type="RaceBlackorAAHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceBlackorAA" maxOccurs="*" minOccurs="0"/>
<element type="RaceNHorOPIHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceNHorOPI" maxOccurs="*" minOccurs="0"/>
<element type="RaceWhiteHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceWhite" maxOccurs="*" minOccurs="0"/>
<element type="RaceNotProvidedHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceNotApplicableHMDA" maxOccurs="*" minOccurs="0"/>
<element type="RaceNotApplicable" maxOccurs="*" minOccurs="0"/>
<element type="RaceNoCoBrwrHMDA" maxOccurs="*" minOccurs="0"/>
</ElementType>

On an unrelated note, any idea if it will be possible to insert custom XSLT
using Biztalk Mapper 2004 (outside of a functoid)? That would completely
solve my problem.

Thanks in advance for any help you can provide

Eric Theil

"Jan Eliasen" <spam@eliasen.dk> wrote in message
news:2qf0vv8plc9ugfm8bvoe16h52s1t17mnif@
4ax.com...
> On Tue, 23 Dec 2003 12:34:32 -0700, "Eric Theil"
> <etheil@3tsystems.com> wrote:
>
> Could you try to attach your documentspecifications? That'll be 10
> minutes less work for me :-)
>
that[color=blue]
Biztalk[color=blue]
the[color=blue]
code[color=blue]
this:[color=blue]
>
>select="userJScript:CompareValues201("1",string(Code/text()))"/>
>
>select="userJScript:CompareValues201("2",string(Code/text()))"/>
file[color=blue]
>
> --
> Jan Eliasen, representing himself and not the company he works for



Jan Eliasen

2004-02-08, 8:42 am

On Fri, 9 Jan 2004 17:01:45 -0700, "Eric Theil" <etheil@3tsystems.com>
wrote:

Does it work to have seven equals-functoids, which all take the
DexRaces/DexRace/Code as inoput and each have a number between 1 and 7
as the other input. Then, have seven Value Mappening functoids, each
taking one of the equals-functoids as input and the othe rinput should
be what ever should be written in case the equals.-functoid is true.
The output from each value mappening functoid should then go to
whatever element needs to be written.

If this solution gives you empty elements that you do not need, try
adding links from each ewquals-functoid to the appropriate element
that should be created.

Does this make sense? If not, then complain, and I will try making an
example for you.

>Thanks for responding Jan. I've been playing with this on and off and am not
>having any luck. What I really need is a way to generate an xsl:choose block
>using one or a combination of the functoids, but I just can't seem to find
>anything. In essence, I need a way to go from multiple Elements on the left
>side to one of a number of elements on the right depending on the value
>within the left Element.
>
>In essence, I need to take the DexRaces/DexRace/Code value, check that value
>(which is 1 through 7) and then create the appropriate element within the
>GOVERNMENT_MONITORING section. So, for instance, if the value of
>DexRaces/DexRace/Code is 1 (and there can be 0 to many DexRace elements), I
>need to write out a <RaceAIorANHMDA>true</RaceAIorANHMDA> element (there
>will only be a single GOVERNMENT_MONITORING/RaceAIorANHMDA element; if the
>DexRaces/DexRace/Code value is not present, the element is not added).
>
>As for document specs, here are some schema excerpts:
>
>From:
><ElementType name="DexRaces" content="eltOnly" order="many" model="closed">
><b:RecordInfo/>
><element type="DexRace" maxOccurs="*" minOccurs="0"/>
></ElementType>
><ElementType name="DexRace" content="eltOnly" order="many" model="closed">
><b:RecordInfo/>
><element type="Id" maxOccurs="*" minOccurs="0"/>
><element type="Code" maxOccurs="*" minOccurs="0"/>
><element type="DexCustomerElements" maxOccurs="*" minOccurs="0"/>
></ElementType>
>
>to:
><element type="GOVERNMENT_MONITORING" maxOccurs="*" minOccurs="0"/>
><ElementType name="GOVERNMENT_MONITORING" content="eltOnly" order="many"
>model="closed">
><b:RecordInfo/>
><element type="RaceAIorANHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceAIorAN" maxOccurs="*" minOccurs="0"/>
><element type="RaceAsianHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceAsian" maxOccurs="*" minOccurs="0"/>
><element type="RaceBlackorAAHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceBlackorAA" maxOccurs="*" minOccurs="0"/>
><element type="RaceNHorOPIHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceNHorOPI" maxOccurs="*" minOccurs="0"/>
><element type="RaceWhiteHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceWhite" maxOccurs="*" minOccurs="0"/>
><element type="RaceNotProvidedHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceNotApplicableHMDA" maxOccurs="*" minOccurs="0"/>
><element type="RaceNotApplicable" maxOccurs="*" minOccurs="0"/>
><element type="RaceNoCoBrwrHMDA" maxOccurs="*" minOccurs="0"/>
></ElementType>
>
>On an unrelated note, any idea if it will be possible to insert custom XSLT
>using Biztalk Mapper 2004 (outside of a functoid)? That would completely
>solve my problem.
>
>Thanks in advance for any help you can provide
>
>Eric Theil
>
>"Jan Eliasen" <spam@eliasen.dk> wrote in message
> news:2qf0vv8plc9ugfm8bvoe16h52s1t17mnif@
4ax.com...
>that
>Biztalk
>the
>code
>this:
>file
>


--
Jan Eliasen, representing himself and not the company he works for.
MCP in Microsoft BizTalk
Eric Theil

2004-02-08, 8:42 am

Hi Jan,

No luck. I had tried a couple of variations of this same mapping, but the
xsl it produces causes each individual element on the right to loop through
the DexRace items on the left, like this:

<xsl:for-each select="DexRaces/DexRace">
<xsl:variable name="var:v141"
select="userJScript:CompareValues1("1",string(Code/text()))"/>
<xsl:if test="string($var:v141)="true"">
<xsl:variable name="var:v142" select=""true""/>
<RaceAIorANHMDA><xsl:value-of select="$var:v142"/></RaceAIorANHMDA>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="DexRaces/DexRace">
<xsl:variable name="var:v143"
select="userJScript:CompareValues1("1",string(Code/text()))"/>
<xsl:if test="string($var:v143)="true"">
<xsl:variable name="var:v144" select=""true""/>
<RaceAIorAN><xsl:value-of select="$var:v144"/></RaceAIorAN>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="DexRaces/DexRace">
<xsl:variable name="var:v145"
select="userJScript:CompareValues2("2",string(Code/text()))"/>
<xsl:if test="string($var:v145)="true"">
<xsl:variable name="var:v146" select=""true""/>
<RaceAsianHMDA><xsl:value-of select="$var:v146"/></RaceAsianHMDA>
</xsl:if>
</xsl:for-each>
<...>

I tried the Equals functoid and a Scripting functoid with the same results.
The problem here is that if any of the DexRace/Code values are present,
every element on the right is generated. I think I'm going to have to do the
copy and paste thing. I've got an xsl:choose block that works perfectly, but
of course, I can't insert it into the file without it being overwritten by
the mapper when I save changes elsewhere.

If you've got any other suggestions, I'd love to hear them. Otherwise, I
think I'm going to have to continue with manually editing the file.

Thanks again.

Eric

"Jan Eliasen" <spam@eliasen.dk> wrote in message
news:37i400d4k17agb5tssu8fj6td086s8qlrv@
4ax.com...
> On Fri, 9 Jan 2004 17:01:45 -0700, "Eric Theil" <etheil@3tsystems.com>
> wrote:
>
> Does it work to have seven equals-functoids, which all take the
> DexRaces/DexRace/Code as inoput and each have a number between 1 and 7
> as the other input. Then, have seven Value Mappening functoids, each
> taking one of the equals-functoids as input and the othe rinput should
> be what ever should be written in case the equals.-functoid is true.
> The output from each value mappening functoid should then go to
> whatever element needs to be written.
>
> If this solution gives you empty elements that you do not need, try
> adding links from each ewquals-functoid to the appropriate element
> that should be created.
>
> Does this make sense? If not, then complain, and I will try making an
> example for you.
>
not[color=blue]
block[color=blue]
find[color=blue]
left[color=blue]
value[color=blue]
I[color=blue]
the[color=blue]
model="closed">[color=blue]
model="closed">[color=blue]
XSLT[color=blue]
map[color=blue]
get[color=blue]
>
>
the[color=blue]
out[color=blue]
>
> --
> Jan Eliasen, representing himself and not the company he works for.
> MCP in Microsoft BizTalk



Jan Eliasen

2004-02-08, 8:42 am

On Mon, 12 Jan 2004 11:44:40 -0700, "Eric Theil"
<etheil@3tsystems.com> wrote:

Try posting your complete docspecs - I'll have a look.

>Hi Jan,
>
>No luck. I had tried a couple of variations of this same mapping, but the
>xsl it produces causes each individual element on the right to loop through
>the DexRace items on the left, like this:
>
><xsl:for-each select="DexRaces/DexRace">
> <xsl:variable name="var:v141"
>select="userJScript:CompareValues1("1",string(Code/text()))"/>
> <xsl:if test="string($var:v141)="true"">
> <xsl:variable name="var:v142" select=""true""/>
> <RaceAIorANHMDA><xsl:value-of select="$var:v142"/></RaceAIorANHMDA>
> </xsl:if>
></xsl:for-each>
><xsl:for-each select="DexRaces/DexRace">
> <xsl:variable name="var:v143"
>select="userJScript:CompareValues1("1",string(Code/text()))"/>
> <xsl:if test="string($var:v143)="true"">
> <xsl:variable name="var:v144" select=""true""/>
> <RaceAIorAN><xsl:value-of select="$var:v144"/></RaceAIorAN>
> </xsl:if>
></xsl:for-each>
><xsl:for-each select="DexRaces/DexRace">
> <xsl:variable name="var:v145"
>select="userJScript:CompareValues2("2",string(Code/text()))"/>
> <xsl:if test="string($var:v145)="true"">
> <xsl:variable name="var:v146" select=""true""/>
> <RaceAsianHMDA><xsl:value-of select="$var:v146"/></RaceAsianHMDA>
> </xsl:if>
></xsl:for-each>
><...>
>
>I tried the Equals functoid and a Scripting functoid with the same results.
>The problem here is that if any of the DexRace/Code values are present,
>every element on the right is generated. I think I'm going to have to do the
>copy and paste thing. I've got an xsl:choose block that works perfectly, but
>of course, I can't insert it into the file without it being overwritten by
>the mapper when I save changes elsewhere.
>
>If you've got any other suggestions, I'd love to hear them. Otherwise, I
>think I'm going to have to continue with manually editing the file.
>
>Thanks again.
>
>Eric
>
>"Jan Eliasen" <spam@eliasen.dk> wrote in message
> news:37i400d4k17agb5tssu8fj6td086s8qlrv@
4ax.com...
>not
>block
>find
>left
>value
>I
>the
>model="closed">
>model="closed">
>XSLT
>map
>get
>the
>out
>


--
Jan Eliasen, representing himself and not the company he works for.
MCP in Microsoft BizTalk Server
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com