i have an xml like this
<SyncItemMaster>
<DataArea>
<Sync>
<TenantID>Infor</TenantID>
<AccountingEntityID/>
<LocationID/>
<ActionCriteria>
<ActionExpression actionCode="Replace"/>
</ActionCriteria>
</Sync>
<ItemMaster>
<ItemMasterHeader>
<ItemID>
<ID>frome</ID>
</ItemID>
<UserArea>
<Property>
<NameValue>extra field</NameValue>
</Property>
</UserArea>
</ItemMasterHeader>
</ItemMaster>
</DataArea>
</SyncItemMaster>
and my xslt is this
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ItemMasterHeader/UserArea/Property">
<xsl:variable name="item" select="//ID" />
<Property>
<NameValue>/Item_Image[@Item_Name = "<xsl:value-of select="$item"/>"]</NameValue>
</Property>
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
this code works fine if there is the UserArea tag and return this xml
<?xml version="1.0" encoding="UTF-8"?>
<SyncItemMaster>
<DataArea>
<Sync>
<TenantID>Infor</TenantID>
<AccountingEntityID/>
<LocationID/>
<ActionCriteria>
<ActionExpression actionCode="Replace"/>
</ActionCriteria>
</Sync>
<ItemMaster>
<ItemMasterHeader>
<ItemID>
<ID>frome</ID>
</ItemID>
<UserArea>
<Property>
<NameValue>/Item_Image[@Item_Name = "frome"]</NameValue>
</Property>
<Property>
<NameValue>extra field</NameValue>
</Property>
</UserArea>
</ItemMasterHeader>
</ItemMaster>
</DataArea>
</SyncItemMaster>
what I would like to have is the following XML if in the original there is not the UserArea tag so if my input is this
<SyncItemMaster>
<DataArea>
<Sync>
<TenantID>Infor</TenantID>
<AccountingEntityID/>
<LocationID/>
<ActionCriteria>
<ActionExpression actionCode="Replace"/>
</ActionCriteria>
</Sync>
<ItemMaster>
<ItemMasterHeader>
<ItemID>
<ID>frome</ID>
</ItemID>
</ItemMasterHeader>
</ItemMaster>
</DataArea>
</SyncItemMaster>
i would like to get this
<SyncItemMaster>
<DataArea>
<Sync>
<TenantID>Infor</TenantID>
<AccountingEntityID/>
<LocationID/>
<ActionCriteria>
<ActionExpression actionCode="Replace"/>
</ActionCriteria>
</Sync>
<ItemMaster>
<ItemMasterHeader>
<ItemID>
<ID>frome</ID>
</ItemID>
<UserArea>
<Property>
<NameValue>/Item_Image[@Item_Name = "frome"]</NameValue>
</Property>
</UserArea>
</ItemMasterHeader>
</ItemMaster>
</DataArea>
</SyncItemMaster>
any suggestions? i am not an expert on xslt i tried several option using apply-template but for some reason didn't work at all thanks for your help