Hi, I am fairly new to XML and XSL. I tried reading through a few online tutorials, but have been unable to figure out the best way to transform my xml correctly. Below is a part of my sample XML:
<row>
<row_element column="0" property_name="EventTypeName">Start</row_element>
<row_element column="1" property_name="ObjectName">Process001</row_element>
<row_element column="2" property_name="DateStamp">17-Jan-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process001 ~ object_name = Ready to Load ~ root_object = Package123 ~ task_type = DoTask ~ User = floor1 ~ Comments: = Starting</row_element>
</row>
<row>
<row_element column="0" property_name="EventTypeName">Promote</row_element>
<row_element column="1" property_name="ObjectName">Process001</row_element>
<row_element column="2" property_name="DateStamp">21-Jan-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process001 ~ object_name = Ready to Load ~ root_object = Package123 ~ task_type = GoTask ~ User = floor_manager5 ~ Comments: = Testing</row_element>
</row>
<row>
<row_element column="0" property_name="EventTypeName">Finish</row_element>
<row_element column="1" property_name="ObjectName">Process001</row_element>
<row_element column="2" property_name="DateStamp">27-Jan-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process001 ~ object_name = Ready to Load ~ root_object = Package123 ~ task_type = FinishTask ~ User = floor_cleaup18 ~ Comments: = Testing</row_element>
</row>
<row>
<row_element column="0" property_name="EventTypeName">Start</row_element>
<row_element column="1" property_name="ObjectName">Process022</row_element>
<row_element column="2" property_name="DateStamp">5-FebJan-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process022 ~ object_name = Ready to Load ~ root_object = Package999 ~ task_type = DoTask ~ User = floor1 ~ Comments: = Starting</row_element>
</row>
<row>
<row_element column="0" property_name="EventTypeName">Promote</row_element>
<row_element column="1" property_name="ObjectName">Process022</row_element>
<row_element column="2" property_name="DateStamp">7-Feb-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process022 ~ object_name = Ready to Load ~ root_object = Package999 ~ task_type = GoTask ~ User = floor_manager15 ~ Comments: = Testing</row_element>
</row>
<row>
<row_element column="0" property_name="EventTypeName">Finish</row_element>
<row_element column="1" property_name="ObjectName">Process022</row_element>
<row_element column="2" property_name="DateStamp">15-Feb-2011</row_element>
<row_element column="3" property_name="Data">job_name = Process02201 ~ object_name = Ready to Load ~ root_object = Package999 ~ task_type = FinishTask ~ User = floor_cleaup29 ~ Comments: = Testing</row_element>
</row>
Sample output:
Object Responsible User Start Date Finished Date
Package123 floor_manager5 17-Jan-2011 27-Jan-2011
Package999 floor_manager15 7-Feb-2011 15-Feb-2011
Object column: get the root_object value if the event is 'Start' and has an object_name value of 'Ready to Load'
Responsible User column: get the user value if root_object value matches the root_object value found in the object column and if event is 'Promote' and has an object_name value of 'Ready to Load'
Start Date column: get the DateStamp value from the same 'Start' event from Object column
Finish Date column: get DateStamp value if root_object value matches the root_object value found in the object column and if event is 'Finish' and has an object_name value of 'Ready to Load'
So far I got to list the Object Column, but don't know what to do next to process the rest:
<xsl:template name="genReport">
<xsl:for-each select="row">
<xsl:if test="(row_element[@column='0']/text()='Start') and (substring-before(substring-after(row_element[@column='3']/text(),'object_name = '),' ~')='Ready to Load')">
<Row>
<Cell ss:StyleID="s84">
<Data ss:Type="String">
<xsl:value-of select="substring-before(substring-after(row_element[@column='3']/text(),'root_object = '),' ~')"/>
</Data>
</Cell>
</Row>
</xsl:if>
</xsl:for-each>
</xsl:template>
Please help and thank you in advance.