I am new to XSLT, just a learner. I downloaded a trial version of Stylus studio Enterprise to see if I can generate XSLT code from source and targe XML. I can see that it does generate, but it hardcodes the elements and nodes which i do not want.
I would appreciate if you guys can help me in creating a XSLT file from my input and output XML.
The input XML is like this
<?xml version="1.0" encoding="UTF-8" ?>
<DateCreated hasQuot="No" type="DATE">2007-04-24</DateCreated>
<FirstName type="CHAR">CAROL J</FirstName>
My output XML should be like this
<?xml version="1.0" encoding="UTF-8"?>
<p1 type = "VARCHAR">mk_INSERT_ConsultantFromSAP_proc</p1>
<p2 type = "VARCHAR">@SAPID = 0000206320</p2>
<p3 type = "VARCHAR">@DateCreated = 2007-04-24</p3>
<p4 type = "VARCHAR">@FirstName = CAROL J</p4>
<p5 type = "VARCHAR">@LastName = VERITY</p5>
<p6 type = "VARCHAR">@AccountGroup = Z001</p6>
<p7 type = "VARCHAR">@CustomerStatus = NULL</p7>
<p8 type = "VARCHAR">@Active = 1</p8>
I think if <p1> tag is hardcoded then its fine, but the value "mk_insert.." should be picked up from table tag in source XML.
Now the difficult part is that p2, p3, pn are dynamic, they should be generated based on number of child nodes in source XML. I need to use something like contact('p',$counter) which will create <p1>, <p2>,,<pn> tags and also i need corresponding </p1></p2></pn> closing tags.
Then i want (key = value) pairs extracted from source XML to be plugged in these p1, pn tags. This process has to be generic as source XML can have varying number of tags, means in the example i have give there are 8 child nodes, but it can go to 12 or 18 or 30. Also the namespace can keep on changing, but i can give you one thing to start with, the action attribute and table element is always there irrespective of any XML input given. I do not know how to use those descendent, sibling ,etc. tags, but i think this complex scenario is possible in XSLT.
Though i am a very good programmer in SAP, XSLT has beaten me. Since last 3 days I am trying to learn and implent this, but struggling. I would greatly appreciate your inputs. Thanks in advance