【发布时间】:2019-06-09 15:26:21
【问题描述】:
我有一个需要转换为 txt 的 xml 文件,为此我使用了 xslt 转换。 我的 xslt 转换文件在
中包含一些支持的 javascript 函数如果我在 .net framework 4.5 及更高版本中运行我的代码,我可以成功转换文件,但相同的代码在 .net core 2.1 中失败。
.netcore 2.1 的文档显示了对 xslt 转换的支持,但它对我不起作用,是我缺少的任何东西。
我的输入 XML:
<?xml version="1.0" encoding="utf-8"?>
<Maps xmlns:xsi= "https://www.w3.org/TR/xmlschema-1/" xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xmlns= "http://www.semi.org">
<Map SubstrateId= "EMAXA191X0121" SubstrateType= "">
<Device MachineID= "M/C Name : AOI-404" BinType= "Decimal" NullBin= "099" Orientation= "0" OriginLocation= "2" Columns= "59" Rows= "41" CreateDate= "20190111.214309" ProductId= "EMAXA191X0121" LotId= "" WaferSize= "200">
<ReferenceDevice ReferenceDeviceX= "-1" ReferenceDeviceY= "-1" />
<Bin>
<Bin BinCode= "001" BinCount= "1565" BinQuality= "Pass" />
<Bin BinCode= "061" BinCount= "657" BinQuality= "Fail" />
<Bin BinCode= "062" BinCount= "11" BinQuality= "Fail" />
<Bin BinCode= "064" BinCount= "9" BinQuality= "Fail" />
<Bin BinCode= "065" BinCount= "1" BinQuality= "Fail" />
<Bin BinCode= "069" BinCount= "143" BinQuality= "Fail" />
</Bin>
<Data MapName= "MMI G85" Version= "1.0">
<Row> <![CDATA[061 001 061 061 001 061 061 001 061 061 001 061 061 069 061 061 001 061 061 061 061 061 061 001 061 001 061 061 099 099 099 001 001 061 001 061 061 001 001 001 001 001 061 001 001 001 001 001 061 001 061 001 001 061 061 001 061 061 061]]> </Row>
<Row> <![CDATA[061 001 061 061 001 061 001 001 061 061 061 061 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 061 061 001 061 069 001 001 001 001 001 061 061 001 001 001 001 001 061 001 001 061 001 001 061 061 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 061 001 001 001 001 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 061 001 061 001 069 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 069 061 061 061 061 061 061 061 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 001 061 001 001 001 001 001 001 001 001 001 001 061 061 061 001 001 001 001 001 001 061 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 061 001 001 001 001 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 001 061 061 001 001 069 001 061 061 061 001 061 069 001 061 001 061 061 001 001 061 001 061 061 061]]> </Row>
<Row> <![CDATA[069 001 061 001 001 001 001 061 001 001 001 001 001 001 001 061 061 061 061 001 061 061 001 001 001 001 001 001 001 069 001 001 001 069 001 069 001 001 001 001 001 069 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 001 061 001 061 061 001 061 001 069 001 061 001 001 061 061 001 061 001 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[061 061 001 061 001 001 061 001 001 061 001 001 001 001 061 001 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 001 061 069 001 001 001 001 001 001 069 061 061 001 061 061 001 001 061 001 001 001 061 061 061 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 061 001 001 061 001 001 001 061 061 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 001 061 001 001 001 001 061 001 061 001 069 001 061 001 061 001 001 001 001 061 001 001 001 001 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 069 001 001 001 069 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 061 061 061 061 001 061 061 001 061 061 061 001 061 001 001 061 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 001 001 001 001 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 001 061 061 061 061 061 061 061 061 001 061 061 061 061 061 001 001 001 001 001 061 001 061 001 001 001 061 061 001 001 061 001 001 061 001 001 001 001 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 061 001 001 001 001 061 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 069 001 069 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 001 001 001 001 001 001 069 001 069 069 069 001]]> </Row>
<Row> <![CDATA[001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 061 001 061 001 001 001 001 001 001 001 069 069 061 001 061 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 061 061 001 001 001 061 001 061 001 001 061 001 001 001 069 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 061 001 001 001 001 061 061 001 001 001 001 001 001 001 001 001 001 001 001 069 069]]> </Row>
<Row> <![CDATA[061 001 001 001 001 061 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[069 061 001 001 001 001 001 061 001 001 001 001 001 001 001 001 061 001 061 061 001 001 001 061 061 061 061 061 061 069 061 001 061 061 001 061 001 001 061 061 061 061 001 061 061 001 061 001 061 001 001 061 001 001 001 001 061 061 061]]> </Row>
<Row> <![CDATA[069 001 001 001 061 061 061 001 061 001 001 061 061 001 001 001 061 001 061 001 061 061 061 061 061 061 061 061 099 099 099 001 061 001 001 061 001 001 061 061 061 001 061 061 061 001 061 061 001 069 061 001 069 001 061 069 061 061 061]]> </Row>
<Row> <![CDATA[099 099 099 099 001 001 099 099 099 099 099 001 061 061 061 061 061 001 061 061 061 061 061 061 001 061 061 061 099 099 099 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 099 099 099 099 099 001 061 099 099 099 099]]> </Row>
<Row> <![CDATA[061 061 061 061 061 061 061 001 061 001 061 061 061 061 061 001 061 061 061 061 061 061 061 061 061 061 061 061 099 099 099 061 061 061 061 061 001 001 001 061 061 001 061 061 061 061 061 001 061 061 001 061 061 001 061 001 061 061 069]]> </Row>
<Row> <![CDATA[061 061 061 001 061 061 061 061 061 061 001 061 061 061 061 001 061 061 061 001 001 001 001 061 061 001 061 061 061 061 001 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 001 061 061 061]]> </Row>
<Row> <![CDATA[061 001 061 001 001 061 061 061 001 061 061 061 061 001 061 001 061 061 061 061 061 061 061 061 061 061 061 061 061 061 061 001 061 061 061 061 001 061 061 061 061 061 061 061 061 001 061 061 061 061 061 061 061 061 061 061 001 061 061]]> </Row>
<Row> <![CDATA[001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 061 061 001 001 001 069 061 001 001 001 001 001 001 001 001 001 001 061 061 061 061 061 001 069 001 001 001 001 061 001 001 061 001 069 069 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 069 001 001 065 001 001 001 001 001 001 069 069 001 001 069 001 001 001 001 001 001 069 061 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 069]]> </Row>
<Row> <![CDATA[001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 061 001 061 061 069 001 001 001 061 001 001 001 001 001 001 001 001 001 061 061 061 001 001 001 001 001 001 001 001 001 001 001 061 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 061 001 001 001 061 001 001 001 001 069 061 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 061 061 061 069 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 069 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 001 001 001 061 001 001 061 061 001 061 061 061 001 001 001 061 001 061 001 061 001 069]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 061 061 061 001 001 001 061 001 001 061 001 001 001 061 069 001 001 001 001 001 001 001 001 001 001 061 061 001 001 001 001 001 001 061 001 001 001 001 001 061 069 069 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 061 001 069 001 001 001 001 061 069 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 069 001 061 001 001 001 001 061 001 061 061 001 001 001 061 061 001 061 001 001 061 001 061 069 061 001 061 001 001 001 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 069 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 061 061 001 001 001 001 001 001 069 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 069 069 001 069 001 001 001 001 069 001 001 069 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001]]> </Row>
<Row> <![CDATA[069 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 001 001 001 001 069 001 001 001 001 001 001 061 069 001]]> </Row>
<Row> <![CDATA[069 069 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 061 061 069 069 069]]> </Row>
<Row> <![CDATA[069 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 001 069 001 001 001 001 001 001 001 001 001 001 064 062 062 062 062 064 064 064 062 062 062 062 064 064 001 001 001 001 001]]> </Row>
<Row> <![CDATA[001 001 069 001 001 069 001 001 001 001 001 001 001 001 001 001 001 069 069 001 001 001 001 001 001 001 001 001 099 099 099 001 001 001 001 001 001 062 062 064 001 001 001 001 001 001 001 001 001 001 001 001 001 001 064 062 064 001 061]]> </Row>
</Data>
</Device>
</Map>
</Maps>
我的 XSLT 专为转换而设计:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsi= "https://www.w3.org/TR/xmlschema-1/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns= "http://www.semi.org"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:outlet = "http://my.functions">
<msxsl:script implements-prefix="outlet" language="javascript">
<![CDATA[
//script to replace string as XSLT1.0 doesnot support replace()
function replace_str(str_text,str_by)
{
return str_text.replace(str_text,str_by);
}
//script to find the incoming bin code and idendify if pass/fail/null
function identify_bin_type(available_bin_codes,search_string) {
while(available_bin_codes.MoveNext()) {
var current_bin_code = available_bin_codes.Current.Value;
if ( current_bin_code === search_string){
return current_bin_code;
}
}
return "";
}
]]>
</msxsl:script>
<xsl:strip-space elements="*"/>
<!--variable section-->
<xsl:variable name="Company_Name" select="'xxx'"/>
<xsl:variable name="Notch_Direction" select="'DOWN'"/>
<xsl:variable name="Device_Name" select="'EMAX-00'"/>
<xsl:variable name="Pass_Bin_ASE_Code" select="'1'"/>
<xsl:variable name="Fail_Bin_ASE_Code" select="'0'"/>
<xsl:variable name="Null_Bin_ASE_Code" select="'X'"/>
<xsl:variable name="Miss_Bin_ASE_Code" select="'0'"/>
<xsl:variable name="Machine_Id" select="/node()[1]/node()[1]/node()[1]/@MachineID"/>
<xsl:variable name="Wafer_Id" select="/node()[1]/node()[1]/@SubstrateId"/>
<xsl:variable name="Bin1_Count" select="/node()[1]/node()[1]/node()[1]/node()[2]/*[@BinCode='001']/@BinCount"/>
<xsl:variable name="Column_Value" select="/node()[1]/node()[1]/node()[1]/@Columns"/>
<xsl:variable name="Row_Value" select="/node()[1]/node()[1]/node()[1]/@Rows"/>
<xsl:variable name="Actual_Die_Nos" select="number($Column_Value) * number($Row_Value)"/>
<xsl:variable name="Total_Die_Nos" select="sum(/node()[1]/node()[1]/node()[1]/node()[2]/*[@BinCount]/@BinCount)"/>
<xsl:variable name="Device_Rows" select="/node()[1]/node()[1]/node()[1]/node()[3]/*/text()"/>
<xsl:variable name="Pass_Bin_Codes" select="/node()[1]/node()[1]/node()[1]/node()[2]/*[@BinQuality='Pass']/@BinCode"/>
<xsl:variable name="Fail_Bin_Codes" select="/node()[1]/node()[1]/node()[1]/node()[2]/*[@BinQuality='Fail']/@BinCode"/>
<!--<xsl:variable name="Null_Bin_Codes" select="/node()[1]/node()[1]/node()[1]/node()[2]/*[@BinQuality='Null']/@BinCode"/>-->
<xsl:variable name="Null_Bin_Codes" select="/node()[1]/node()[1]/node()[1]/@NullBin"/>
<xsl:output method="text" indent="yes"/>
<!--Transpose template called for each Device Row Data-->
<xsl:template name="find-identify-substitute-bincodes">
<xsl:param name="string"/>
<xsl:variable name="relevantSringLen" select="string-length($string)" />
<xsl:if test="$relevantSringLen > 1">
<xsl:variable name="relevant-part" select="substring-before(substring-after($string,' '),' ')"/>
<xsl:choose>
<!--Check if it a pass bin code and replace with respective pass ASE Code-->
<xsl:when test="contains(outlet:identify_bin_type($Pass_Bin_Codes,$relevant-part),$relevant-part)">
<xsl:variable name="transform-relevant-part" select="outlet:replace_str($relevant-part,$Pass_Bin_ASE_Code)" />
<xsl:value-of select="normalize-space(concat($transform-relevant-part,' '))"/>
</xsl:when>
<!--Check if it a fail bin code and replace with respective fail ASE Code-->
<xsl:when test="contains(outlet:identify_bin_type($Fail_Bin_Codes,$relevant-part),$relevant-part)">
<xsl:variable name="transform-relevant-part" select="outlet:replace_str($relevant-part,$Fail_Bin_ASE_Code)" />
<xsl:value-of select="normalize-space(concat($transform-relevant-part,' '))"/>
</xsl:when>
<!--Check if it a null bin code and replace with respective null ASE Code-->
<xsl:when test="contains(outlet:identify_bin_type($Null_Bin_Codes,$relevant-part),$relevant-part)">
<xsl:variable name="transform-relevant-part" select="outlet:replace_str($relevant-part,$Null_Bin_ASE_Code)" />
<xsl:value-of select="normalize-space(concat($transform-relevant-part,' '))"/>
</xsl:when>
<!--Check if bin code not found and replace with respective miss ASE Code-->
<xsl:otherwise>
<xsl:variable name="transform-relevant-part" select="outlet:replace_str($relevant-part,$Miss_Bin_ASE_Code)" />
<xsl:value-of select="normalize-space(concat($transform-relevant-part,' '))"/>
</xsl:otherwise>
</xsl:choose>
<!--recursively look into the remainder string in the row and continue serch and replace till the end-->
<xsl:variable name="remainder" select="substring-after($string,$relevant-part)"/>
<xsl:call-template name="find-identify-substitute-bincodes">
<xsl:with-param name="string" select="$remainder"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!--Template of Device Data Rows to be called in main Template-->
<xsl:template name="Devicedatarow">
<xsl:for-each select="$Device_Rows">
<xsl:variable name="Device_Row" select="current()"/>
<xsl:variable name="Device_Row_Position" select="position()"/>
<xsl:call-template name="find-identify-substitute-bincodes">
<xsl:with-param name="string" select="$Device_Row" />
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<!--Main Text Template body-->
<xsl:template match="/|@*">
<xsl:text>Company Name: </xsl:text>
<xsl:value-of select="$Company_Name" />
<xsl:text>
</xsl:text>
<xsl:text>Device: </xsl:text>
<xsl:value-of select="$Device_Name" />
<xsl:text>
</xsl:text>
<xsl:text>MachineID :</xsl:text>
<xsl:value-of select="substring-after($Machine_Id, 'M/C Name :')" />
<xsl:text>
</xsl:text>
<xsl:text>Wafer ID: </xsl:text>
<xsl:value-of select="$Wafer_Id" />
<xsl:text>
</xsl:text>
<xsl:text>BIN 1: </xsl:text>
<xsl:value-of select="$Bin1_Count" />
<xsl:text>
</xsl:text>
<xsl:text>Total Die: </xsl:text>
<xsl:value-of select="$Total_Die_Nos" />
<xsl:text>
</xsl:text>
<xsl:text>Notch Direction: </xsl:text>
<xsl:value-of select="$Notch_Direction" />
<xsl:text>
</xsl:text>
<xsl:value-of select="concat('Column : ', $Column_Value, ', ' , ' Row : ', $Row_Value)" />
<xsl:text>
</xsl:text>
<xsl:text>Empty :</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>.............................................</xsl:text>
<xsl:text>
</xsl:text>
<xsl:call-template name="Devicedatarow">
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
我的预期输出:
Company Name: xxx
Device: EMAX-00
MachineID : AOI-404
Wafer ID: EMAXA191X0121
BIN 1: 1565
Total Die: 2386
Notch Direction: DOWN
Column : 59, Row : 41
Empty :
.............................................
0100100100100000100000010100XXX1101001111101111101011001000
01001011000001000000000000001000010011111001111101101100000
01111111101111100000000000000001001111111111111111111111000
01111111111010000000000000000001001111111111111111111111000
01111101111111111100000000000000111111111111111011101010000
01111100000000010000000000000000011011111111110001111110000
01111110111101000000000000000001001001101000100101001101000
01011110111111100001001111111011101011111010111111111111111
01111111111111010000000000000001001010010101011001011111000
00101101101111011000000000000001001001111110001001101110001
01111011011100010000000000000001001011110101010101111011110
01111111111111111101111111111011101111110111111111111111000
01111111101111111000010010001011011111111111111110111111110
01111111111111111001000000001000001111101011100110110111100
01111101111011111101111111110101111111111101111111111010001
11111111111011111101111111111111111101111101011111110001011
01110011101011011101111111111011111111011110011111111111100
01111011111111111011111111111111111111111101111111111111000
00111110111111110100111000000001001011000010010101101111000
0111000101100111010100000000XXX1011011000100010010010100000
XXXX11XXXXX10000010000001000XXX00000000000000001XXXXX10XXXX
0000000101000001000000000000XXX0000011100100000100100101000
00010000001000010001111001000011000000000000000000000101000
01011000100001010000000000000001000010000000010000000000100
11111111111111110111111001110011111111110000010111101101001
01111111111111110101101111110011011111100111110111111111110
11111111111111111001111101000111011111111100011111111111011
01111111011101111001111111111011111111111111111110111100001
01111111111111111001111111111111011111110110010001110101010
01111111111101110001110110111001111111111001111110111110001
01111111111111111011111111111111111111111111011110101111001
01111111111111110101011110100111001011010001011111111111111
01111111111111111101111111111011111111101110111111111111111
01111111111111111101111111110011111111111111111111111111111
01111111111111111001111111110011111111111111111111111111111
01111111111111111011111111110011111111111111101001111110111
01111111111111111101111111110010111101101111111011111111111
01101111111111111111111111111011111111111111011110111111001
00101111111111111001111111111011111110111111111111111100000
01111111111111111011111111111011111111110000000000000011111
1101101111111111100111111111XXX1111110001111111111111100010
我的 .net 示例应用程序来执行转换:
public static void RunXslt1(string currentInputXML,string currentOutputTXT,string transformxsltPath)
{
var fileInUse = "XSLT";
try
{
Console.WriteLine(String.Format("starting XSLT process"));
// Load the style sheet.
var settings = new XsltSettings();
settings.EnableScript = true;
var xslt = new XslCompiledTransform();
xslt.Load(transformxsltPath, settings, null);
// Execute the transform and output the results to a file.
fileInUse = "XML";
xslt.Transform(currentInputXML, currentOutputTXT);
Console.WriteLine(String.Format("Fail occurs on transformation."));
}
catch (FileNotFoundException ex)
{
if (fileInUse.Equals("XSLT"))
{
Console.WriteLine("XSLT file not found.");
Environment.Exit(1);
}
else if (fileInUse.Equals("XML"))
{
Console.WriteLine("XML file not found.");
}
}
catch (Exception ex)
{
Console.WriteLine("Fail occurs on transformation. \nError : " + ex.Message);
}
}
这段代码在 .net framework 4.6 中运行良好,但如果我在 .netCore 2.1 中运行它,那么下面的点会得到 platformnotsupportexception
xslt.Load(transformxsltPath, settings, null);
System.PlatformNotSupportedException:编译 JScript/CSharp 脚本 不支持
.netCore 2.1 缺少什么? 我的xslt版本是1.0,Visual Studio 2017,目标框架.netcore2.1 我尝试了很多建议,但似乎没有任何效果 请帮助我,
【问题讨论】:
标签: .net xml xslt-1.0 .net-core-2.1