Platform: Informatica 9.6.1 (XML parcer).
I have a generic XML source file where column names (element names) are stored as attribute (AttributeID) values. I need to write XSLT file and Java code to convert attributes (AttributeID) values into the element (Column_1, Column_2, etc.) and elements values so it can be correctly read by Informatica XML parser. I am new to XSLT.
Here is the sample of the XML source file:
I have to transform this file into the normally formed one (with elements and their value primarily):
Thank you for any help with XSLT code or hits in advance!
I have a generic XML source file where column names (element names) are stored as attribute (AttributeID) values. I need to write XSLT file and Java code to convert attributes (AttributeID) values into the element (Column_1, Column_2, etc.) and elements values so it can be correctly read by Informatica XML parser. I am new to XSLT.
Here is the sample of the XML source file:
Code:
<?xml version="1.0" encoding="utf-8"?> <Products ExportTime="2017-08-21 11:24:43" ExportContext="Context1" ContextID="Context1" WorkspaceID="Main" UseContextLocale="false"> <Product Product_ID="1000"> <Entities> <Entity Entity_ID="100" UserTypeID="SourceRecord1" ParentID="Source Records10" Selected="false1" Referenced="true1"> <Name>Name_1</Name> <Values> <Value AttributeID="Column_1">Value_1</Value> <Value AttributeID="Column_2">Value_2</Value> <Value AttributeID="Column_3" Column_4="Value_4">Value_3</Value> </Values> </Entity> <Entity Entity_ID="101" UserTypeID="SourceRecord2" ParentID="Source Records20" Selected="false2" Referenced="true2"> <Name>Name_2</Name> <Values> <Value AttributeID="Column_1">Value_5</Value> <Value AttributeID="Column_2">Value_6</Value> <Value AttributeID="Column_3" Column_4="Value_8">Value_7</Value> </Values> </Entity> </Entities> </Product> <Product Product_ID="1001"> <Entities> <Entity Entity_ID="102" UserTypeID="SourceRecord3" ParentID="Source Records30" Selected="false3" Referenced="true3"> <Name>Name_3</Name> <Values> <Value AttributeID="Column_1">Value_9</Value> <Value AttributeID="Column_2">Value_10</Value> <Value AttributeID="Column_3" Column_4="Value_12">Value_11</Value> </Values> </Entity> <Entity Entity_ID="103" UserTypeID="SourceRecord4" ParentID="Source Records40" Selected="false4" Referenced="true4"> <Name>Name_4</Name> <Values> <Value AttributeID="Column_1">Value_13</Value> <Value AttributeID="Column_2">Value_14</Value> <Value AttributeID="Column_3" Column_4="Value_16">Value_15</Value> </Values> </Entity> </Entities> </Product> </Products>
Code:
<?xml version="1.0" encoding="utf-8"?> <Products ExportTime="2017-08-21 11:24:43" ExportContext="Context1" ContextID="Context1" WorkspaceID="Main" UseContextLocale="false"> <Product Product_ID="1000"> <Entities> <Entity Entity_ID="100" UserTypeID="SourceRecord" ParentID="Source Records" Selected="false" Referenced="true"> <Name>Name_1</Name> <Item ItemID="1238240"> <Column_1>Value_1</Column_1> <Column_2>Value_2</Column_2> <Column_3>Value_3</Column_3> <Column_4>Value_4</Column_4> </Item> </Entity> <Entity Entity_ID="101" UserTypeID="SourceRecord" ParentID="Source Records" Selected="false" Referenced="true"> <Name>Name_2</Name> <Item> <Column_1>Value_5</Column_1> <Column_2>Value_6</Column_2> <Column_3>Value_7</Column_3> <Column_4>Value_8</Column_4> </Item> </Entity> </Entities> </Product> <Product Product_ID="1001"> <Entities> <Entity Entity_ID="102" UserTypeID="SourceRecord" ParentID="Source Records" Selected="false" Referenced="true"> <Name>Name_3</Name> <Item ItemID="1238240"> <Column_1>Value_9</Column_1> <Column_2>Value_10</Column_2> <Column_3>Value_11</Column_3> <Column_4>Value_12</Column_4> </Item> </Entity> <Entity Entity_ID="103" UserTypeID="SourceRecord" ParentID="Source Records" Selected="false" Referenced="true"> <Name>Name_4</Name> <Item> <Column_1>Value_13</Column_1> <Column_2>Value_14</Column_2> <Column_3>Value_15</Column_3> <Column_4>Value_16</Column_4> </Item> </Entity> </Entities> </Product> </Products>
Comment