Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Add Attributes To XML Tag Using XSLT

$
0
0

Hi,

I am trying to add two attributes to Parameters tag.

<?xml version="1.0" encoding="utf-8"?><Parameters A="True" B="0.05" C="50" xmlns="clr-namespace:Test.Core.Model.Classes;assembly=Test.Core.Model" xmlns:ocme="clr-namespace:Test.Core.Model.Enums;assembly=Test.Core.Model" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Parameters.Searches><scg:List x:TypeArguments="ocme:SearchType" Capacity="8"><ocme:SearchType>Two</ocme:SearchType><ocme:SearchType>Three</ocme:SearchType><ocme:SearchType>Four</ocme:SearchType></scg:List></Parameters.Searches><Parameters.Mutations><scg:List x:TypeArguments="ocme:SearchType" Capacity="8"><ocme:SearchType>Two</ocme:SearchType><ocme:SearchType>Three</ocme:SearchType><ocme:SearchType>Four</ocme:SearchType></scg:List></Parameters.Mutations><Parameters.Searches2><scg:List x:TypeArguments="Search" Capacity="0" /></Parameters.Searches2></Parameters>

I am using this XSLT file.

<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"><xsl:output method="xml" indent="yes"/><xsl:template match="@* | node()"><xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy></xsl:template><xsl:template match="Parameters"><xsl:copy><xsl:attribute name="D">0</xsl:attribute><xsl:attribute name="E">100</xsl:attribute><xsl:apply-templates select="@* | node()"/></xsl:copy></xsl:template></xsl:stylesheet>
But the output xml is same as input xml. Where am i doing wrong?


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>