Since there is a misunderstanding of how XSLT is used, i have decided to add a couple of examples.
The below example has several different examples of how to do XML transformation. This is somewhat documented, so you may uncomment/comment the piece that you need or the example that you need.
I will post an example of how to clean up objects in the next couple of days.
EXAMPLE BEGINS HERE.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<!-- copy all nodes and attributes -->
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<!-- ############################################
Remove Last updated by from all sections This is in case the user does not exist in target system
##################################################-->
<xsl:template match="@lastUpdatedBy" />
<!-- remove all XOGOutput Tags These are useless when xogging back in-->
<xsl:template match="XOGOutput" />
<!-- remove General Tags as they are not needed and can cause errors -->
<xsl:template match="General" />
<!-- ##################################################################
remove all Tags whose languageCode whose atribute Language is not en
#####################################################################-->
<xsl:template match="*[@languageCode!='en']" />
<!-- ######################################################
Need to do Project twice on create from template
Here we check to see if isNewFromTemplate is true
If Yes (xsl:when) Then copy project elements twice
######################################################### -->
<xsl:template match="Project">
<xsl:choose>
<xsl:when test="@isNewFromTemplate='true'">
<Project>
<xsl:for-each select="@*">
<xsl:if test="name() = 'active'
or name() = 'finish'
or name() = 'start'
or name() = 'managerResourceID'
or name() = 'name'
or name() = 'projectID'
or name() = 'status'
or name() = 'template'
or name() = 'fromTemplate'
or name() = 'format'">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:if>
</xsl:for-each>
<CustomInformation>
<ColumnValue name="partition_code"><xsl:value-of select="CustomInformation/ColumnValue[@name='partition_code']"/></ColumnValue>
</CustomInformation>
</Project>
<Project>
<xsl:for-each select="@*">
<xsl:if test="name() != 'isNewFromTemplate'
and name() != 'fromTemplate'">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="node()" />
</Project>
</xsl:when>
<xsl:otherwise>
<!-- ######################################################
When it is not isNewFromTemplate we only copy the project elements once
######################################################### -->
<Project>
<xsl:apply-templates select="node()|@*[name(.)!='isNewFromTemplate']" />
</Project>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- escape text nodes (on ColumnValue elements) -->
<xsl:template match="ColumnValue">
<xsl:element name="ColumnValue">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:call-template name="escapeQuote">
<xsl:with-param name="text" select="." />
</xsl:call-template>
</xsl:element>
</xsl:template>
<!-- ##################################################################
Handle Multi Value Lookup This piece of code tokenizes each value as to allow for multiselects
that come inside of the XOG file.
####################################################################-->
<xsl:template match="ColumnValue[@name='xxxAttributeCodexxx']">
<xsl:element name="ColumnValue">
<xsl:attribute name="name">
<xsl:text><xsl:value-of select="@name"/></xsl:text>
</xsl:attribute>
<xsl:call-template name="tokenize">
<xsl:with-param name="ColumnValue" select="text()"/>
</xsl:call-template>
</xsl:element>
</xsl:template>
<!-- ##########################################################################
Remove OBSAssocs when name or id is empty -- THis is important so it does not fail as all 3 values are required
###########################################################################-->
<xsl:template match="OBSAssocs">
<xsl:choose>
<xsl:when test="OBSAssoc/@id">
<OBSAssocs complete="false">
<xsl:apply-templates select="@*|node()"/>
</OBSAssocs>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--###################################################################################
Replace attribute value $CLEAR$ to an empty string -- useful for blanking out records (nodes)
inside of cells. Meaning if client wants to send blank value, they send $CLEAR$
#########################################################################################
-->
<xsl:template match="@*">
<xsl:attribute name="{name()}">
<xsl:choose>
<xsl:when test="current()='$CLEAR$'">
<xsl:text></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="escapeQuote">
<xsl:with-param name="text" select="." />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
<xsl:template match="*/text()[.='$CLEAR$']"></xsl:template>
<!-- Split delimited values into Value tags -->
<xsl:template name="tokenize">
<xsl:param name="ColumnValue" select="."/>
<xsl:param name="separator" select="','"/>
<xsl:choose>
<xsl:when test="not(contains($ColumnValue, $separator))">
<Value>
<xsl:value-of select="normalize-space($ColumnValue)"/>
</Value>
</xsl:when>
<xsl:otherwise>
<Value>
<xsl:value-of select="normalize-space(substring-before($ColumnValue, $separator))"/>
</Value>
<xsl:call-template name="tokenize">
<xsl:with-param name="ColumnValue" select="substring-after($ColumnValue, $separator)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Replace Escaped quotes with un-escaped ones -->
<xsl:template name="escapeQuote">
<xsl:param name="pText" select="."/>
<xsl:if test="string-length($pText) >0">
<xsl:value-of select="substring-before(concat($pText, '\"'), '\"')"/>
<xsl:if test="contains($pText, '\"')">
<xsl:text>"</xsl:text>
<xsl:call-template name="escapeQuote">
<xsl:with-param name="pText" select="substring-after($pText, '\"')"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
<!-- ############################################################################
remove unused OBS's based on a specific value. THis will remove the complete node
#################################################################################
-->
<xsl:template match="OBSAssocs/OBSAssoc[@id='location' or @id='Department OBS' or @id='service_area' ]"/>
<!--
########################################################################################
Adding complete=true to different sections of security parameters. This is handy for migrating group/user/obs rights and making sure that they all get moved/removed from target
########################################################################################
-->
<xsl:template match="obs">
<xsl:copy>
<xsl:attribute name="complete">
<xsl:value-of select="'true'"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="GlobalRights">
<xsl:copy>
<xsl:attribute name="complete">
<xsl:value-of select="'true'"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- Instance Rights-->
<xsl:template match="InstanceRights">
<xsl:copy>
<xsl:attribute name="complete">
<xsl:value-of select="'true'"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- OBS Instance Rights-->
<xsl:template match="InstanceOBSRights">
<xsl:copy>
<xsl:attribute name="complete">
<xsl:value-of select="'true'"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:template>
</xsl:stylesheet>
<!-- ###################################################################################################################
THis code below is handy for other examples of how to use XSLT for transformation Note that this part is all comented out
<!-- Normal Attribute replace id from an external file that contains the 2 id's one from source, one from target-->
<!-- Replace alt_manager-->
<xsl:template match="ColumnValue[@name='alt_manager']">
<xsl:text disable-output-escaping="yes"><ColumnValue name="alt_manager"></xsl:text>
<xsl:variable name='external_lookups'
select="document('F:\Directv\Migration\replace_ids\UserId.xml')/Records/Record[@source_id=current()]/@target_id" />
<xsl:value-of select="$external_lookups" />
<xsl:text disable-output-escaping="yes"></ColumnValue></xsl:text>
</xsl:template>
<!--Set manager as admin as current manager does not exist.
Good when migrating users from one system to the other and all users not present-->
<!-- first run use this code, second one, comment it out-->
<xsl:template match="@managerUserName[parent::Resource]">
<xsl:attribute name="managerUserName">
<xsl:text>admin</xsl:text>
</xsl:attribute>
</xsl:template>
<!--Set user active so all associations can be made then deactivate-->
<!-- first run use this code, second comment it-->
<xsl:template match="@isActive[parent::Resource]">
<xsl:attribute name="isActive">
<xsl:text>true</xsl:text>
</xsl:attribute>
</xsl:template>
################################################################################################################################
-->