Need Help in XSLT Transform
Posted: Thu Sep 27, 2018 2:42 am
hi I have a an method that i want to use to transform a XML
It receives an XML a XSL and a list of parameters iit uses the xsl to transform the xml but it was suposed to change the values in the xsl based on the parameters, this is part of the xsl that was suposed to add to xml:
and the params list was username valueA and password valueB, for some reason when the transform is invoked the hardcoded value in the XSLT is included in the xml instead of the param, so the new XML has username xxxxx instead of valueA, can someone tell me what is missing here?
thx
Code: Select all
public void MssXsl_Transform(string ssXml, string ssXsl, RLXsltParamRecordList ssParams, out string ssTransformedContent)
{
//XslCompiledTransform t = new XslCompiledTransform();
XslTransform t = new XslTransform();
StringReader sr_xsl = new StringReader(ssXsl); //String com o XSL
XmlTextReader xtr_xsl = new XmlTextReader(sr_xsl);
StringReader sr_xml = new StringReader(ssXml); // String com o XML
XmlTextReader xtr_xml = new XmlTextReader(sr_xml);
//t.Load(xtr_xsl, new XsltSettings(true, true), null);
t.Load(xtr_xsl);
MemoryStream m = new MemoryStream();
//XmlWriterSettings s = t.OutputSettings.Clone();
//s.CheckCharacters = false;
//t.Transform(xtr_xml, null, XmlWriter.Create(m, s));
XPathDocument d = new XPathDocument(xtr_xml);
XsltArgumentList args = new XsltArgumentList();
foreach (RCXsltParamRecord record in ssParams)
{
args.AddParam(record.ssSTXsltParam.ssName, "", record.ssSTXsltParam.ssValue);
}
t.Transform(d, args, m, null);
m.Position = 0;
ssTransformedContent = new StreamReader(m).ReadToEnd();
} // MssXsl_Transform
Code: Select all
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<xsl:variable name="XMLCopy">
<xsl:copy-of select="AIMSBI/CliXML/*"/>
</xsl:variable>
<soapenv:Header/>
<soapenv:Body>
<tem:AddVehicle xmlns="XXXXXXXXXXXXXXXXXXXXXXXXXXX">
<tem:username>xxxxx</tem:username>
<tem:password>yyyyy</tem:password>
<tem:vehicleInspectionXML>
<xsl:value-of select="user:XMLEncode($XMLCopy)"/>
</tem:vehicleInspectionXML>
</tem:AddVehicle>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
thx