Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample XSLT to generate a package.xml file for Salesforce ANT tool to remove dead fields
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns="http://soap.sforce.com/2006/04/metadata" exclude-result-prefixes="xs xd" version="2.0">
<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:param name="fieldNameColumn" select="'0'"/>
<xsl:param name="statusColumn" select="'5'"/>
<xsl:param name="isDeletable" select="'yes'"/>
<xsl:template match="/">
<Package>
<xsl:apply-templates
select="workbook/sheet[row/cell[@col = $statusColumn and lower-case(text()) = $isDeletable]]"/>
<version>45.0</version>
</Package>
</xsl:template>
<xsl:template match="sheet">
<xsl:variable name="oName" select="replace(@name, ' ', '')"/>
<xsl:element name="types">
<!-- xsl:attribute name="object"><xsl:value-of select="$oName"/></xsl:attribute -->
<xsl:apply-templates
select="row/cell[@col = $statusColumn and lower-case(text()) = $isDeletable]">
<xsl:with-param name="oName" select="$oName"/>
</xsl:apply-templates>
<name>CustomField</name>
</xsl:element>
</xsl:template>
<xsl:template match="cell">
<xsl:param name="oName"/>
<members><xsl:value-of select="$oName"/>.<xsl:value-of select="../cell[@col = $fieldNameColumn]"/></members>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.