on 10-14-2011 6:52 AM
Hi
i need a small help regarding the loigc below for an udf
If value in field Uid= A, B,X, Y,Z or I Value u20185u2019
If value in field Uid = C Value u20184u2019
If value in field Uid = E, H, G,J, M,N & When lanID <45 Value u20183u2019
If value in field Uid = E, H, G,J, M,N & When lanID is >45 & <100 Value u20182u2019
If value in field Uid = E, H, G,J, M,N & When lanID is is >100 Value u20181u2019
Based on Uid and lanID fields in different nodes I need to map the target field.
TIA,
Hello,
You can use this mapping:
Uid --> UDF -> Target
IanId -> /
UDF type is Single Values
Arguments: inp1
inp2
if(inp1.equals("A")|inp1.equals("B")|inp1.equals("X")|inp1.equals("Y")|inp1.equals("Z")|inp1.equals("I")){
return "5";
}
else if(inp1.equals("C")){
return "4";
}
else if(inp1.equals("E")|inp1.equals("H")|inp1.equals("G")|inp1.equals("J")|inp1.equals("M")|inp1.equals("N")){
int temp = Integer.parseInt(inp2);
if(temp<45){
return "3";
}
else if(temp>45&temp<100){
return "2";
}
else if(temp>100){
return "1";
}
else
return "Invalid IanID Value";
}
else
return "Invalid Uid value";
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I can give you example in XSLT:
Create variable"var1" which should refer your source element,like:
<xsl:variable name ="var1" select ="E1EDEM/DEVL/VALUE"/> and create different variable name to match your constant value A,B,C,D,E,F and etc...
<xsl:choose>
<xsl:when test="String($var1) = 'A' and String($var2) = 'B' and String($var3) = 'X' and String($var3) = 'Y' and String($var4) = 'Z' or String($var5) = 'I' "/>
<xsl:value-of select="5"/>
<xsl:when test="String($var6) = 'C' "/>
<xsl:value-of select="4"/>
<xsl:when test="String($var7) = 'E' and String($var8) = 'H' and String($var9) = 'G' and String($var10) = 'J' and String($var11) = 'M' and String($var12) = 'N' and number(lanID) < 45 "/>
<xsl:value-of select="3"/>
<xsl:when test="String($var7) = 'E' and String($var8) = 'H' and String($var9) = 'G' and String($var10) = 'J' and String($var11) = 'M' and String($var12) = 'N' and number(lanID) > 45 "/>
<xsl:value-of select="2"/>
<xsl:when test="String($var7) = 'E' and String($var8) = 'H' and String($var9) = 'G' and String($var10) = 'J' and String($var11) = 'M' and String($var12) = 'N' and number(lanID) > 100 "/>
<xsl:value-of select="1"/>
<xsl:choose>
Hope this helps you
Regards,
Senthil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Prabhas
You can map it without UDF as well.
UID----->fixValue (2)---------------\
UID----->fixValue (1)--------------> IF ------> Target
|
|
Constant : 3 ------------------\ |
LenID--------->less----------->IF----/
Constant : 45-/ |
|
Constant : 3 ----------\ |
LenID---------->less-->IF------/
Constant : 100-/ |
Constant : 1-----------/
Where the notation for fixValue is as :
fixValue (1)
key value
A true
B true
X true
Y true
Z true
C true
E false
H false
G false
J false
M false
N false
Keeping default as to stop mapping
fixValue (2)
key value
A 5
B 5
X 5
Y 5
Z 5
C 4
Regards
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prabhas,
Please try the below logic...this can be achieved with graphical mapping as well. But a UDF looks simple.
public String UDF(String uID , String var2,Container container) throws StreamTransformationException{
String val ="";
int landId = Integer.parseInt(var2);//passs source landId
if(uID == 'A' || uID == 'B' || uID == 'X' || uId== 'Y' || uID == 'Z' || uID == 'I')
val = 5;
else if(uID == 'C')
val = 4;
else if(uID == 'E' ||uID == 'H' || uID == 'G' || uID == 'J' || uID == 'M' || uID == 'N' ){
if(landId <= 45)
val = 3;
else if(landId >45 && landId < 100)
val = 2;
else
val = 1;
}
else
value = "";
return val;
}
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.