C#XSLT转换添加和放大器; #xA;和与放大器; #xD;到输出 [英] C# XSLT transform adding 
 and 
 to the output
问题描述
我有一个XSLT转换问题:
风格=WIDTH:{数据/ PercentSpaceUsed}%;
和数据/ PercentSpaceUsed的值为整数3。
和它输出:
风格=WIDTH:放大器; #xD;&安培; #xA; 3及#xD;&放大器; #xA;%;
而不是我所期待的:
风格=宽度:3%;
下面是一条什么代码转换: xslt_xslt
是转换XML, sw.ToString()
包含&放大器; #xD;
和&安培; #xA;
这是我没想到的。
VAR xslTransObj =新XslCompiledTransform() ;
变种读者= XmlTextReader的新(新StringReader(xslt_xslt));
xslTransObj.Load(读卡器);
变种SW =新的StringWriter();
变种作家=新的XmlTextWriter(SW);
xslTransObj.Transform(新的XmlTextReader(新StringReader(xslt_data)),作家);
ResultLiteral.Text = sw.ToString();
的&安培; #xD ;&安培; #xA;
是回车和换行的XML或XSLT内饲料无论是。确保XML是像
< VALUE>第3版; /价值与GT;
而不是
< VALUE>
3
< /价值与GT;
我相信是有办法阻止你的空白转换中被使用,虽然我不`吨知道从我的头顶。
I have an XSLT transform issue:
style="width:{Data/PercentSpaceUsed}%;"
And the value of Data/PercentSpaceUsed is integer 3.
And it outputs:
style="width:
 3
 %;"
instead of what I expected:
style="width:3%;"
Here's the code that does the transform: xslt_xslt
is the transform xml, sw.ToString()
contains the 
and 

which I did not expect.
var xslTransObj = new XslCompiledTransform();
var reader = new XmlTextReader(new StringReader(xslt_xslt));
xslTransObj.Load(reader);
var sw = new StringWriter();
var writer = new XmlTextWriter(sw);
xslTransObj.Transform(new XmlTextReader(new StringReader(xslt_data)), writer);
ResultLiteral.Text = sw.ToString();
The 

are carriage returns and line feeds either within your XML or your XSLT. Make sure the xml is like
<Value>3</Value>
Rather than
<Value>
3
</Value>
I believe there is a way to stop whitespace being used within your transformation although I don`t know it off the top of my head.
这篇关于C#XSLT转换添加和放大器; #xA;和与放大器; #xD;到输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!