本文介绍了platformnotsupportedexception:XSLCompiledTransform.Load(xslt)不会使用</msxsl:script>加载xslt文件..net Core 2.1目标框架中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML文件,我需要将其转换为txt,为此我使用了xslt转换.我的xslt转换文件在

I have a xml file which i need to convert to txt, for which i used xslt transformation.My xslt transform file contains some supporting javascript functions in

如果我在.net Framework 4.5及更高版本中运行代码,则可以成功转换文件,但.net core 2.1却无法执行相同的代码.

I could successfully transform the file if i run my code in .net framework 4.5 and above but same code fails with .net core 2.1.

.netcore 2.1的文档显示了对xslt转换的支持,但它对我不起作用,因为我缺少任何内容.

Documentation of .netcore 2.1 shows support for xslt transformation, but its not working for me, is that anything I am missing.

我的输入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专为转换而设计:

My XSLT designed for Transformation:

<?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 &gt; 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>&#xd;</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>&#xd;</xsl:text>

    <xsl:text>Device: </xsl:text>
    <xsl:value-of select="$Device_Name" />
    <xsl:text>&#xd;</xsl:text>

    <xsl:text>MachineID :</xsl:text>
    <xsl:value-of select="substring-after($Machine_Id, 'M/C Name :')" />

    <xsl:text>&#xd;</xsl:text>
    <xsl:text>Wafer ID: </xsl:text>
    <xsl:value-of select="$Wafer_Id" />

    <xsl:text>&#xd;</xsl:text>
    <xsl:text>BIN 1: </xsl:text>
    <xsl:value-of select="$Bin1_Count" />

    <xsl:text>&#xd;</xsl:text>
    <xsl:text>Total Die: </xsl:text>
    <xsl:value-of select="$Total_Die_Nos" />

    <xsl:text>&#xd;</xsl:text>
    <xsl:text>Notch Direction: </xsl:text>
    <xsl:value-of select="$Notch_Direction" />
    <xsl:text>&#xd;</xsl:text>

    <xsl:value-of select="concat('Column : ', $Column_Value, ', ' , ' Row : ', $Row_Value)" />
    <xsl:text>&#xd;</xsl:text>

    <xsl:text>Empty :</xsl:text>

    <xsl:text>&#xd;</xsl:text>
    <xsl:text>.............................................</xsl:text>
    <xsl:text>&#xd;</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示例应用程序执行转换:

My .net sample application to execute the transformation:

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

This code prefectly works good in .net framework 4.6, but if i run it in .netCore 2.1 then the below point gets platformnotsupportexception

 xslt.Load(transformxsltPath, settings, null);

.netCore 2.1缺少什么?我的xslt版本是1.0,Visual Studio 2017,trarget Framework .netcore2.1我尝试了许多建议,但似乎无济于事请为此提供帮助,

What is missing for .netCore 2.1?My xslt version is 1.0, Visual studio 2017,trarget Framework .netcore2.1I have tried many suggestions, but nothing seemed to workPlease assist me in this,

推荐答案

根据dotnet corefx github存储库,.NET Core不支持该功能,并且目前没有实现该功能的计划.可以在此处

According to the dotnet corefx github repository, the feature is not supported in .NET Core and there are currently no plans to implement it.More details can be found here

不幸的是,它似乎是您目前唯一仍然选择使用.NET Framework的选项.

Unfortunately, it looks like your only option it to stick with .NET Framework for now.

编辑

我确实喜欢挑战,所以我与您的XSLT一起玩耍,找到了可以在.NET Core中运行的解决方案.

I do like a challenge so I've played around with your XSLT and found a solution that will run in .NET Core.

我们需要删除JScript才能消除该错误.因此,我们需要用XSLT方法替换您的JScript方法.

We need to remove the JScript to get rid of that error. So we need to replace your JScript methods with XSLT methods.

要删除 replace-str ,我环顾四周,发现一个XSLT模板将为您替换字符串.这是我使用的答案

To remove replace-str I looked around and found an XSLT template that will do the string replace for you. This is the answer I used

将模板添加到您的XSLT

Add the template to your XSLT

<xsl:template name="string-replace-all">
  <xsl:param name="text" />
  <xsl:param name="replace" />
  <xsl:param name="by" />
  <xsl:choose>
    <xsl:when test="contains($text, $replace)">
      <xsl:value-of select="substring-before($text,$replace)" />
      <xsl:value-of select="$by" />
      <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text" select="substring-after($text,$replace)" />
        <xsl:with-param name="replace" select="$replace" />
        <xsl:with-param name="by" select="$by" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$text" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

,并用答案中的示例替换您的 replace_str 调用

and replace your replace_str calls with the example in the answer

<xsl:variable name="transform-relevant-part">
  <xsl:call-template name="string-replace-all">
    <xsl:with-param name="text" select="$relevant-part" />
    <xsl:with-param name="replace" select="$relevant-part" />
    <xsl:with-param name="by" select="$Pass_Bin_ASE_Code" />
  </xsl:call-template>
</xsl:variable>

现在,您的 when 子句不需要 identify_bin_type JScript函数来查找任何匹配项时,可以使用XSLT contains 方法来进行找到适合您的匹配项:

Now, your when clauses don't need the identify_bin_type JScript function to find any matches, you can use the XSLT contains method to find matches for you:

<xsl:when test="contains($Pass_Bin_Codes, $relevant-part)">

这应该产生所需的输出.

This should produce the required output.

这篇关于platformnotsupportedexception:XSLCompiledTransform.Load(xslt)不会使用&lt;/msxsl:script&gt;加载xslt文件..net Core 2.1目标框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 11:28