I have the XML in the below format
<?xml version="1.0" encoding="utf-8"?>
<Data Schema="RSXML4.0" xmlns="http://schemas.riversand.com/mdmcenter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.riversand.com/mdmcenter/RSXml4.0.xsd">
<Entities>
<Entity Id="347" ExternalId="SSI1006"
LongName="School Smart Hand Held Rustproof Carbon Steel Pencil Sharpener, Assorted Color, Pack of 24"
EntityTypeId="18" EntityTypeName="Parent SKU" ContainerId="2"
ContainerName="Collaboration Master" OrganizationName="DL" CategoryId="360"
CategoryName="Sharpners" CategoryLongName="Sharpners"
CategoryPath="SchoolSupplies»School_Office_Supplies»Sharpners" CategoryLongNamePath=""
ParentEntityId="360" ParentExternalId="Sharpners" ParentExtensionEntityId="0"
ParentExtensionEntityExternalId="" ParentExtensionEntityContainerId="0"
ParentExtensionEntityContainerName="" ParentExtensionEntityCategoryId="0"
ParentExtensionEntityCategoryPath="" ParentExtensionEntityCategoryLongNamePath=""
Locale="en_WW" Action="Add">
<Attributes>
<Attribute Id="4039" Name="Parent SKU #" LongName="Product Number"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[9-07466-030]]></Value>
</Values>
</Attribute>
<Attribute Id="4040" Name="Product Name" LongName="Product Name" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[School Smart Hand Held Rustproof Carbon Steel Pencil Sharpener]]></Value>
</Values>
</Attribute>
<Attribute Id="4041" Name="SKU Dimensions" LongName="SKU Dimensions"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[3/4 in x 1 in x 1/2 in]]></Value>
</Values>
</Attribute>
<Attribute Id="4042" Name="MSRP" LongName="MSRP" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4000" AttributeParentName="Core Attribute Group"
AttributeType="Simple" AttributeDataType="Decimal" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[2.49]]></Value>
</Values>
</Attribute>
<Attribute Id="4045" Name="Collection" LongName="Collection" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[School Smart]]></Value>
</Values>
</Attribute>
<Attribute Id="4047" Name="UPC" LongName="UPC" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4000" AttributeParentName="Core Attribute Group"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[892030475006]]></Value>
</Values>
</Attribute>
<Attribute Id="4049" Name="Short Description" LongName="Short Description"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4001"
AttributeParentName="Marketing Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[School Smart hand Pencil Sharpener features plastic housing with hardened and honed rust-proof carbon steel blade.]]></Value>
</Values>
</Attribute>
<Attribute Id="4050" Name="Long Description" LongName="Long Description"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4001"
AttributeParentName="Marketing Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[School Smart hand Pencil Sharpener features plastic housing with hardened and honed rust-proof carbon steel blade. Designed for sharpening of pencils. Hand pencil sharpener comes in assorted colors and is sold as 24 per pack.]]></Value>
</Values>
</Attribute>
<Attribute Id="4122" Name="A-Assets" LongName="Assets" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4003"
AttributeParentName="Media Attribute Group" AttributeType="ComplexCollection"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Attributes>
<Attribute Id="4122" Name="A-Assets Instance Record"
LongName="Assets Instance Record" InstanceRefId="293" Sequence="0"
AttributeParentId="4003" AttributeParentName="Media Attribute Group"
AttributeType="Complex" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Attributes>
<Attribute Id="4126" Name="A-AssetDescription"
LongName="AssetDescription" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4127" Name="A-AssetDisplayName"
LongName="AssetDisplayName" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4128" Name="A-AssetFileName" LongName="AssetFileName"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[SSI1006_SchoolSmart Sharpener_1.jpg]]></Value>
</Values>
</Attribute>
<Attribute Id="4129" Name="A-AssetID" LongName="AssetID"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[991E8697FD394A17A70C0DA7A73ECE87]]></Value>
</Values>
</Attribute>
<Attribute Id="4130" Name="A-AssetImageThumb"
LongName="AssetImageThumb" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4131" Name="A-AssetImageType"
LongName="AssetImageType" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4132" Name="A-AssetKind" LongName="AssetKind"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4133" Name="A-AssetLocalURL" LongName="AssetLocalURL"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[http://smbpoc.riversand.com:8080/MAM76/assets/1/76E608495D23463EA54B253B1FB1D94C/img/991E8697FD394A17A70C0DA7A73ECE87/SSI1006_SchoolSmart_Sharpener_1.jpg]]></Value>
</Values>
</Attribute>
<Attribute Id="4134" Name="A-AssetProductDescription"
LongName="AssetProductDescription" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[]]></Value>
</Values>
</Attribute>
<Attribute Id="4135" Name="A-AssetRenditions"
LongName="AssetRenditions" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[<?xml version="1.0" encoding="utf-16"?><Renditions />]]></Value>
</Values>
</Attribute>
<Attribute Id="4136" Name="A-AssetSize" LongName="AssetSize"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[93194]]></Value>
</Values>
</Attribute>
<Attribute Id="4137" Name="A-AssetThumbnailURL"
LongName="AssetThumbnailURL" InstanceRefId="-1" Sequence="-1"
AttributeParentId="4122" AttributeParentName="A-Assets"
AttributeType="Simple" AttributeDataType="String" Locale="en_WW"
Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[http://smbpoc.riversand.com:8080/MAM76/assets/1/76E608495D23463EA54B253B1FB1D94C/img/991E8697FD394A17A70C0DA7A73ECE87/thumb_991E8697FD394A17A70C0DA7A73ECE87.jpg]]></Value>
</Values>
</Attribute>
<Attribute Id="4138" Name="A-AssetType" LongName="AssetType"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[img]]></Value>
</Values>
</Attribute>
<Attribute Id="4139" Name="A-AssetPrimary" LongName="AssetPrimary"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="2" Sequence="-1"
DisplayValue="Secondary" HasInvalidValue="False"
Locale="en_WW" Action="Add"
><![CDATA[Secondary]]></Value>
</Values>
</Attribute>
<Attribute Id="4140" Name="A-AssetSequence" LongName="AssetSequence"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="Integer" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"><![CDATA[1]]></Value>
</Values>
</Attribute>
<Attribute Id="4142" Name="A-FilePath" LongName="AssetFilePath"
InstanceRefId="-1" Sequence="-1" AttributeParentId="4122"
AttributeParentName="A-Assets" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="-1" Uom="" ValueRefId="0" Sequence="-1"
DisplayValue="" HasInvalidValue="False" Locale="en_WW"
Action="Add"
><![CDATA[C:\Users\RSAdmin\Documents\Templates\Print Images\SSI1006_SchoolSmart_Sharpener_1.jpg]]></Value>
</Values>
</Attribute>
</Attributes>
</Attribute>
</Attributes>
</Attribute>
<Attribute Id="4618" Name="ItemQty" LongName="ItemQty" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[Pack of 24]]></Value>
</Values>
</Attribute>
<Attribute Id="4619" Name="ItemColor" LongName="ItemColor" InstanceRefId="-1"
Sequence="-1" AttributeParentId="4000"
AttributeParentName="Core Attribute Group" AttributeType="Simple"
AttributeDataType="String" Locale="en_WW" Action="Add">
<Values>
<Value Id="0" Uom="" ValueRefId="-1" Sequence="-1" DisplayValue=""
HasInvalidValue="False" Locale="en_WW" Action="Add"
><![CDATA[Assorted]]></Value>
</Values>
</Attribute>
</Attributes>
<Relationships/>
</Entity>
</Entities>
</Data>
I have multiple such Entity nodes. I need to add an attribute in each 'Entity' node as ProductImage = value of the attribute with the name 'A-AssetFileName'. I need to do this using XSLT. Any help would be appreciated. The below XSLT adds the value of each image value to the same Entity node. I want each Entity node to have their corresponding image value from the attribute with the name 'A-AssetFileName'. For eg: my first entity node should become:
<Entity Id="347" ExternalId="SSI1006"
LongName="School Smart Hand Held Rustproof Carbon Steel Pencil Sharpener, Assorted Color, Pack of 24"
EntityTypeId="18" EntityTypeName="Parent SKU" ContainerId="2"
ContainerName="Collaboration Master" OrganizationName="DL" CategoryId="360"
CategoryName="Sharpners" CategoryLongName="Sharpners"
CategoryPath="SchoolSupplies»School_Office_Supplies»Sharpners" CategoryLongNamePath=""
ParentEntityId="360" ParentExternalId="Sharpners" ParentExtensionEntityId="0"
ParentExtensionEntityExternalId="" ParentExtensionEntityContainerId="0"
ParentExtensionEntityContainerName="" ParentExtensionEntityCategoryId="0"
ParentExtensionEntityCategoryPath="" ParentExtensionEntityCategoryLongNamePath=""
Locale="en_WW" Action="Add" ProductImage="SSI1006_SchoolSmart Sharpener_1.jpg">
I am using the below XSLT.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://schemas.riversand.com/mdmcenter">
<xsl:output omit-xml-declaration="yes" indent="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/x:Data/x:Entities/x:Entity">
<xsl:for-each select = "/x:Data/x:Entities/x:Entity">
<xsl:copy>
<!-- <xsl:choose>-->
<!-- <xsl:when test='/x:Data/x:Entities/x:Entity/x:Attributes/x:Attribute/x:Attributes/x:Attribute[@Name = "A-Assets Instance Record"]'>-->
<!-- <xsl:if test='/x:Data/x:Entities/x:Entity/x:Attributes/x:Attribute/x:Attributes/x:Attribute[@Sequence = "0"]'>-->
<xsl:attribute name="ProductImage">
<xsl:for-each select = "/x:Data/x:Entities/x:Entity/x:Attributes/x:Attribute/x:Attributes/x:Attribute/x:Attributes/x:Attribute[@Name = 'A-AssetFileName']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:attribute>
<!--</xsl:if>-->
<!--</xsl:when>-->
<!--</xsl:choose>-->
<!-- <xsl:apply-templates select="@* | node()"/>-->
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<Entity Image="abc.jpg">with any leading/trailing whitespace from the<value>element removed.