[英]how to use SOH and ETX in xslt-1.0
how to set SOH and ETX by using xslt -1.0 如何使用xslt -1.0设置SOH和ETX
I have tried numerous ways i dint reached output, since numeric code are not accepting this xslt-1.0 and here encoding is utf-8. 由于数字代码不接受此xslt-1.0,并且此处的编码为utf-8,因此我尝试了多种方法来实现输出。
how to use this hexadecimal code in it ...it was not working what do i need to do for make it work 如何在其中使用此十六进制代码...不起作用我需要做些什么才能使其起作用
SOH : 
SOH: 
ETX : 
ETX: 
I have tried this below one also for to achieve the resultant output but it was not ..guys kindly suggest some thing...nah 我也尝试过以下一种以获得最终输出,但这不是..guys友善地建议一些事情... nah
<?xml version="1.0" encoding="US-ASCII" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:char="java.lang.Character" version="1.0">
<xsl:output method="text" encoding="US-ASCII" />
<xsl:template match="/">
<xsl:value-of select="char:toString(1)"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
I have applied the above logic in my xslt when i use this it was throwing error : 当我使用xslt时,我在上面抛出了错误:
XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}运行时,XPathNavigator {urn:schemas-microsoft-com:xslt-debug}当前,双{urn:schemas-microsoft-com:xslt-debug}位置,双{ urn:schemas-microsoft-com:xslt-debug}最后,IList`1 {urn:schemas-microsoft-com:xslt-debug}命名空间
and file was creating with 0KB 和文件正在创建与0KB
<xsl:value-of select="char:toString(1)">
if just comment on that it was working fine... 如果只是评论说它工作正常...
here is below xslt 在xslt下面
<?xml version="1.0" encoding="us-ascii"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:char="java.lang.Character" version="1.0" >
<xsl:output method="text" indent="no" omit-xml-declaration ="yes" encoding="us-ascii"/>
<xsl:param name="PackageId" />
<xsl:param name="SequenceNum" />
<xsl:template match="/">
<xsl:value-of select="char:toString(1)"></xsl:value-of>
<xsl:apply-templates mode="block1" select="NewDataSet/Table1[CTC_PACKAGE_ID =$PackageId][position()=1]"/>
<xsl:apply-templates mode="block2" select="NewDataSet/Table[CTD_CTD_PKG_ID =$PackageId][CTD_SEQ_NUM =$SequenceNum]"/>
</xsl:template>
<xsl:template mode="block1" match="Table1">
...some code....
</xsl:template>
<xsl:template mode="block2" match="Table">
...some code....
</xsl:template>
I am not sure what exception you had since what you showed does not seem to be complete. 我不确定您有什么例外,因为您所显示的内容似乎并不完整。 0x01 is not a valid Xml character and this might be the reason for the exception. 0x01不是有效的Xml字符,这可能是导致异常的原因。 I created a slightly different version of your stylesheet that looks like this: 我为样式表创建了一个稍有不同的版本,如下所示:
<?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" xmlns:myScripts="myScripts">
<xsl:output method="text" indent="yes"/>
<msxsl:script implements-prefix="myScripts" language="C#">
public string SOH()
{
return '\u0001'.ToString();
}
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="myScripts:SOH()"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
To prevent it from failing due to the invalid character I needed to disable character checking in the writer that writes the response: 为了防止由于无效字符而导致失败,我需要在编写响应的编写器中禁用字符检查:
var xslt = new XslCompiledTransform();
xslt.Load(@"C:\Temp\xsl.xsl", new XsltSettings() { EnableScript = true }, null);
var xml = new XPathDocument(new StringReader("<root/>"));
var writerSettigns = xslt.OutputSettings.Clone();
writerSettigns.CheckCharacters = false;
xslt.Transform(xml, XmlWriter.Create(Console.Out, writerSettigns));
what resulted in the following output: 什么导致以下输出:
☺Press any key to continue . . .
As you can see the character was written to the output without and there was no exception. 如您所见,该字符不带任何写入输出,也不例外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.