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
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
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Need Help in XSLT Transform
Hi,
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:
you can use them from the XSLT template like this:
and set these parameters from your code.
Regards,
Radu
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"/>
Code: Select all
<tem:username><xsl:value-of select="${username}"/></tem:username>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service