IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: Presente
About
User Name: Presente
Forum Rank: Newbie
Real Name:
Location
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Tuesday, May 22, 2012
Last Visit: Tuesday, October 21, 2014 3:25:00 PM
Number of Posts: 5
[0.03% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: mapping using if-then does not work as expected
Posted: Tuesday, October 21, 2014 3:25:00 PM
Thanks for the clarification.

Ofer
Topic: mapping using if-then does not work as expected
Posted: Tuesday, October 21, 2014 11:54:13 AM
Thanks a lot! We tried your suggestion and it works.

However, I don't understand why the simple 'if-else' doesn't work.

You wrote:
"This won't work with "if" because you want multiple values and from different source contexts which are dependent on each other".

I conclude that there are limitations to using 'if-else' structure, but I couldn't find more information about it in the documentation.

If you have a link that explains it , I would appreciate it.

and thanks again!

Ofer
Topic: mapping using if-then does not work as expected
Posted: Monday, October 20, 2014 7:24:40 PM
Vlad, thanks for the quick response.
Think of the 'equal' with (2,2) as an input variable with value 'true'. If changed to equal (1,2) the variable value is 'false'. Perhaps it was clearer if written as input variable.
I'll try to explain again what the mapping needs to to.
When the boolean is 'true', the result should be all values of the 'a' elements. (2 lines: a1,a2 in my example.
When he boolean value is changed to 'false' the result should be all values of the 'b' elements (5 lines: b1,b2,b3,b4,b5).

Hope it is clear now.

Ofer
Topic: mapping using if-then does not work as expected
Posted: Monday, October 20, 2014 3:09:31 PM
I want to map a simple xml with 2 levels, a & b, each one containing 1 attribute , to a simple text file with a single field.
When I map: 'a' --> 'rows', 'val1' -->'Field1' , result is 2 lines with a1 & a2 , as expected.
When I map: 'b' --> 'rows', 'val2' -->'Field1' , result is 5 lines with the b values, as expected.

The problem is that I want the mapping to map EITHER 'a' values OR 'b' values, depending on a condition.
I tried to use 2 'if-else' , one connected to 'rows' , and one to 'Field1'. See attached mapping. This does NOT work as expected, and result in 2 empty lines, regardless if condition is true or false. Why is that ? How can I fix my mapping?

Thanks a lot in advance!

We use MapForce 2012.

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2012 rel. 2 sp1 (https://www.altova.com)-->
<MyRoot xsi:noNamespaceSchemaLocation="ab.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<a val1="a1">
<b val2="b1"/>
<b val2="b2"/>
<b val2="b3"/>
</a>
<a val1="a2">
<b val2="b4"/>
<b val2="b5"/>
</a>
</MyRoot>
Topic: CAST in where clause
Posted: Tuesday, May 22, 2012 11:23:07 AM
Our mapping maps from SQL to xml. (we have SQL server 2008).
DB columns typically have type of 'nvarchar[n]' (n value vary) and schema corresponding attributes are strings.
Most of the generated queries contain 'where' clause that looks like:

WHERE (CAST(? AS nvarchar(max))) = [key1] and ...

Such queries are very slow, because due to CAST indexes are not used.

When I manually do 'replace' in the generated code to 'Where ? = [key1]', the same query runs 100 times faster.

Altering generated code manually is not a good practice. Is there a way to config MapForce NOT to create queries with CAST in the first place?

(I unchecked 'Cast Values to target types', but it didn't help)

Thanks,

Ofer

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.