Need Help in XSLT Transform

Questions about XML that are not covered by the other forums should go here.
Posts: 1
Joined: Thu Sep 27, 2018 2:33 am

Need Help in XSLT Transform

Post by jumpydady » Thu Sep 27, 2018 2:42 am

hi I have a an method that i want to use to transform a XML

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);
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
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:

Code: Select all

	<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="" xmlns:tem="">
<xsl:variable name="XMLCopy">
<xsl:copy-of select="AIMSBI/CliXML/*"/>
<xsl:value-of select="user:XMLEncode($XMLCopy)"/>
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?


Posts: 7592
Joined: Fri Jul 09, 2004 5:18 pm

Re: Need Help in XSLT Transform

Post by Radu » Thu Sep 27, 2018 8:34 am


This is a forum about using Oxygen XML Editor to edit and process XML documents so maybe you can find an MSXSL specific forum for asking processor related questions.
Coming back to your question, if at the beginning of the XSLT you define two parameters:

Code: Select all

<xsl:param name="username"/><xsl:param name="password"/>
you can use them from the XSLT template like this:

Code: Select all

 <tem:username><xsl:value-of select="${username}"/></tem:username>
and set these parameters from your code.

Radu Coravu
<oXygen/> XML Editor

Post Reply