Took this challenge down a XML tool, and believe this is what is required:
<x:parse var="xsl">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output cdata-section-elements="nsql" method="xml"/>
<xsl:preserve-space elements="nsql"/>
<xsl:template match="Projects">
<xsl:element name="Projects">
<xsl:for-each select = "Project">
<xsl:element name="Project">
<xsl:attribute name="projectID"> <xsl:value-of select = "@projectID[.]"/> </xsl:attribute>
<xsl:attribute name="name"> <xsl:value-of select = "@name[.]"/> </xsl:attribute>
<xsl:element name="Resources">
<xsl:for-each select = "Resources/Resource">
<xsl:if test="@resourceID[.='${v_rows.unique_name}']">
<xsl:element name="Resource">
<xsl:attribute name="resourceID"> <xsl:value-of select = "@resourceID[.]"/> </xsl:attribute>
<xsl:attribute name="staffOBSUnit">'${v_rows.obs_name}'</xsl:attribute>
<xsl:attribute name="availFrom">'${v_rows.prstart}'</xsl:attribute>
<xsl:attribute name="availTo">'${v_rows.prfinish}'</xsl:attribute>
<xsl:element name="AllocCurve">
<xsl:for-each select = "AllocCurve/Segment">
<xsl:element name="Segment">
<xsl:attribute name="finish"><xsl:value-of select = "@finish[.]"/></xsl:attribute>
<xsl:attribute name="start"><xsl:value-of select = "@start[.]"/></xsl:attribute>
<xsl:attribute name="sum"><xsl:value-of select = "@sum[.]"/></xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
<xsl:element name="HardAllocCurve">
<xsl:for-each select = "HardAllocCurve/segment">
<xsl:element name="segment">
<xsl:attribute name="finish"><xsl:value-of select = "@finish[.]"/></xsl:attribute>
<xsl:attribute name="rate"><xsl:value-of select = "@rate[.]"/></xsl:attribute>
<xsl:attribute name="start"><xsl:value-of select = "@start[.]"/></xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="XOGOutput"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
</x:parse>
<x:parse var="xml">
<gel:include select="$v_project_output"/>
</x:parse>
<gel:parse var="v_project_output1">
<x:transform xml="${xml}" xslt="${xsl}"/>
</gel:parse>
It looks extra long, but the output is basically
Project Code and Project Name
Resource ID, Start, Finish, OBS
Resource Allocations
In my case I only want to update particular Team members, so if only outputs the required Team member.
I couldn't work out why my previous version didn't work, but basically any attribute after the ResourceID (which I used for the search key) was not able to be updated. In my case this included the staffOBSUnit, so had to resort to version 2.
The main outtake of this, if you are updating the Team data, you NEED to bring in all the Allocation data, otherwise, it will disappear if you don't XOG it back in again.