on 03-17-2006 5:21 AM
one xml source structure is like this
<E_Students>
<Student>
<ID>1</ID>
<Name>Michael Tang</Name>
</Student>
<Student>
<ID>2</ID>
<Name>Aegean Yin</Name>
</Student>
</E_Students>
the other xml source structure is like this
<C_Students>
<Student>
<ID>2</ID>
<Gender>Female</Gender>
</Student>
<Student>
<ID>1</ID>
<Gender>Male</Gender>
</Student>
</C_Students>
the target xml structure is like this
<Students>
<Student>
<ID>1</ID>
<Name>Michael Tang</Name>
<Gender>Male</Gender>
</Student>
<Student>
<ID>2</ID>
<Name>Aegean Yin</Name>
<Gender>female</Gender>
</Student>
<Students>
the solution I used is multiptle mapping, like this
E_Students.student.id->Students.student.id
E_Students.student.Name->Students.student.Name
C_Students.student.Gender->Students.student.Gender
these two source xml structures may not order by ID, now they must be linked by ID, but when mapped, it did not function, just mapped by sequence, not by ID. who can help me? it is very urgent.
If anyone can provide me other solutions, I will appreciate:)
Message was edited by: Spring Tang
correct xml structure error
Hi,
Some doubts !!
1) Why the student tag empty? In all the three structures...
2) Does ID and name comes in pair?
3) Same for ID and gender.
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Spring,
Please try the following:
<b>Source Structure1:</b><?xml version="1.0" encoding="UTF-8"?>
<E_Students> Occurrence 1...1
|----<Student> Occurrence 1...Unbounded
|----
<ID> Occurrence 1...1
|----
<Name> Occurrence 1...1
<b>Source Structure2:</b>
<?xml version="1.0" encoding="UTF-8"?>
<C_Students> Occurrence 1...1
|----<Student> Occurrence 1...Unbounded
|----
<ID> Occurrence 1...1
|----
<Gender> Occurrence 1...1
<b>Target Structure:</b>
<?xml version="1.0" encoding="UTF-8"?>
< Students> Occurrence 1...1
|----<Student> Occurrence 1...Unbounded
|----
<ID> Occurrence 1...1
|----
<Name> Occurrence 1...1
|----
<Gender> Occurrence 1...1
<b>Mapping rules:</b>
E_Students.student(with context as E_Students)--->Students.student
E_Students.student.id(with context as E_Students)>sort(with lexico graphical case insensitive)>splitbyvalue(each value)->Students.student.id
E_Students.student.id(with context as E_Students)---\
-
|>sortByKey(with lexico graphical case insensitive)>splitbyvalue(each value)->Students.student.Name
E_Students.student.Name(with context as E_Students)-/
E_Students.student.id(with context as E_Students)>sort(with lexico graphical case insensitive)>splitbyvalue(each value)---\
-
|>StringEquals|if\
C_Students.student.id(with context as C_Students)>sort(with lexico graphical case insensitive)>splitbyvalue(each value)---/
-
|---|>C_Students.student.Gender->Students.student.Gender
C_Students.student.id(with context as C_Students)-----\
-
|>sortByKey(with lexico graphical case insensitive)>splitbyvalue(each value)----
|then/
C_Students.student.Gender(with context as C_Students)-/
<b>TextPreview of mapping:</b>
/ns0:Messages/ns0:Message1/Students/Student=/ns0:Messages/ns0:Message1/E_Students/Student=
/ns0:Messages/ns0:Message1/Students/Student/ID=SplitByValue(sort(/ns0:Messages/ns0:Message1/E_Students/Student/ID=))
/ns0:Messages/ns0:Message1/Students/Student/Name=SplitByValue(sortByKey(/ns0:Messages/ns0:Message1/E_Students/Student/ID=, /ns0:Messages/ns0:Message1/E_Students/Student/Name=))
/ns0:Messages/ns0:Message1/Students/Student/Gender=ifWithoutElse(stringEquals(SplitByValue(sort(/ns0:Messages/ns0:Message1/E_Students/Student/ID=)), SplitByValue(sort(/ns0:Messages/ns0:Message2/C_Students/Student/ID=))), SplitByValue(sortByKey(/ns0:Messages/ns0:Message2/C_Students/Student/ID=, /ns0:Messages/ns0:Message2/C_Students/Student/Gender=)))
<b>Test data:</b>
<b>Input:</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
<E_Students>
<Student>
<ID>1</ID>
<Name>Michael Tang</Name>
</Student>
<Student>
<ID>2</ID>
<Name>Aegean Yin</Name>
</Student>
</E_Students>
</ns0:Message1>
<ns0:Message2>
<C_Students>
<Student>
<ID>2</ID>
<Gender>Female</Gender>
</Student>
<Student>
<ID>1</ID>
<Gender>Male</Gender>
</Student>
</C_Students>
</ns0:Message2>
</ns0:Messages>
<b>OutPut:</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
<Students>
<Student>
<ID>1</ID>
<Name>Michael Tang</Name>
<Gender>Male</Gender>
</Student>
<Student>
<ID>2</ID>
<Name>Aegean Yin</Name>
<Gender>Female</Gender>
</Student>
</Students>
</ns0:Message1>
</ns0:Messages>
Regards,
KNS Kumar.
sort and sortbykey will have the <b>lexico graphical case insensitive</b>
SpliByValue has <b>each value</b>
id and gender has context as E_Students or C_Students
E_Students.student.id->sort->splitbyvalue-\
-
|-stringequals-|if..\
C_Students.student.id->sort->splitbyvalue-/
-
|---|>Students.student.Gender
C_Students.student.id----
\
-
|sortBYKEY->splitbyvalue---|then/
C_Students.student.Gender-/
Hi,
Generally mapping is done based on context.
eg:
<root>
---<stud>
-
<id> 1 </id>
-
<Name> A </Name>
---</stud>
---<stud>
-
<id> 2 </id>
-
<Name> B </Name>
---</stud>
---<stud>
-
<id> 3 </id>
-
<Name> C </Name>
---</stud>
Now here if you take <b>id</b> it is wrt <stud>, so the queue will be
1
---
2
---
3
---
If you change the context to root then the queue will be
1
2
3
-
You might have noted the difference...
Now if you have chosen the context as <stud> and after that you have given removeContext then it will be having the same meaning as that of the second queue.
eg:
1 -
1
---
2 => removeContext => 2
---
3 -
3
--- ---
ie no matter whatever be the context it will be removed, and the values will be wrt root node..
Regards
Suraj
Hi,
Then you have to go for user defined function :
First do this
Student(context Student)--Student
ID (context Student)-- ID
Name (context Student) -- Name
Now for gender write this function
here
ID (context Employee)
C_ID (context C_Employee)
Gender (context C_Employee)
<b>
int i = 0, j=0;
for (i=0;i<ID.length;i++)
{
for (j=0;j<C_ID.length;j++)
{
if (ID<i>.equals(C_ID[j]))
result.addValue(" "+Gender[j]);
}
}</b>
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.