在XSLT中全局查找和替换

时间:2013-07-02 09:24:36

标签: xml xslt-2.0

我正在进行XSL转换。在要为任何空值转换的XML中,以XML格式打印的字符是Ø。 有什么方法可以全局查找并替换这个角色。我知道XSL 2.0中有替换功能。但后来我最终为每个字段使用这个替换函数。请建议一些全局替换字符'Ø'的方法。 下面是我的XML和XSL文件。

XML文件

    <?xml version="1.0" encoding="UTF-8" ?><XML_REPORT><REPORT>
    <TRANSMITTER_HEADER>
    <MF>
    <RECORD>
    <TRANSMITTER_ID>24814</TRANSMITTER_ID>
    <FIELD1>2013-07-02T02:07:15</FIELD1>
    <FIELD2>2013-07-02T02:07:15</FIELD2>
    <FIELD3>SUI00010</FIELD3>
    <FIELD4>ESUI0001</FIELD4>
    <FIELD5>Ø</FIELD5>
    </RECORD>
    </MF>
    </TRANSMITTER_HEADER>
    <GRE>
    <EMPLOYER_HEADER>
    <MF>
    <RECORD>
    <TAX_UNIT_ID>24814</TAX_UNIT_ID>
    <FIELD1>1</FIELD1>
    <FIELD2>2013</FIELD2>
    <FIELD3>TEST_REASON</FIELD3>
    <FIELD4>122000331</FIELD4>
    <FIELD5>SUI0001</FIELD5>
    <FIELD6>SJAWID_SMWL BG</FIELD6>
    <FIELD7>Ø</FIELD7>
    <FIELD8>San Francisco</FIELD8>
    <FIELD9>CA</FIELD9>
    <FIELD10>Ø</FIELD10>
    <FIELD11>9140660520</FIELD11>
    <FIELD12>SJAWID_SMWL AUTOGENERATED E</FIELD12>
    <FIELD13>Ø</FIELD13>
    <FIELD14>SJAWID_SMWL IL EMP 1</FIELD14>
    <FIELD15>160543456</FIELD15>
    <FIELD16>Ø</FIELD16>
    <FIELD17>5000.00</FIELD17>
    <FIELD18>0.00</FIELD18>
    <FIELD19>5000.00</FIELD19>
    <FIELD20>.00</FIELD20>
    <FIELD21>0</FIELD21>
    <FIELD22>0</FIELD22>
    <FIELD23>0</FIELD23>
    </RECORD>
    </MF>
    </EMPLOYER_HEADER>
    <EMPLOYEE>
    <MF>
    <RECORD>
    <ASG_ID>76941</ASG_ID>
    <FIELD1>546555024</FIELD1>
    <FIELD2>SJAWID_SMWL AUT</FIELD2>
    <FIELD3>Ø</FIELD3>
    <FIELD4>SJAWID_SMWL FL EMP 1</FIELD4>
    <FIELD5>Ø</FIELD5>
    <FIELD6>5000.00</FIELD6>
    <FIELD7>5000.00</FIELD7>
    <FIELD8>.00</FIELD8>
    <FIELD9>XX</FIELD9>
    <FIELD10>.00</FIELD10>
    </RECORD>
    </MF>
    </EMPLOYEE>
    <A03_HEADER>
    <RECORD_HEADER>
    <AFIELD1_HEADER>Employer Name,</AFIELD1_HEADER>
    <AFIELD2_HEADER>Employer / Agent Employer Identification Number (EIN) ,</AFIELD2_HEADER>
    <AFIELD3_HEADER>Employee Number,</AFIELD3_HEADER>
    <AFIELD4_HEADER>Social Security Number (SSN),</AFIELD4_HEADER>
    <AFIELD5_HEADER>Employee First Name,</AFIELD5_HEADER>
    <AFIELD6_HEADER>Employee Middle Name or Initial,</AFIELD6_HEADER>
    <AFIELD7_HEADER>Employee Last Name,</AFIELD7_HEADER>
    <AFIELD8_HEADER>Employee Suffix,</AFIELD8_HEADER>
    <AFIELD9_HEADER>SUI Reduced Subject Withholdable,</AFIELD9_HEADER>
    <AFIELD10_HEADER>FL SUI Taxable Wages,</AFIELD10_HEADER>
    <AFIELD11_HEADER>FL Out of State Taxable Wages,</AFIELD11_HEADER>
    <AFIELD12_HEADER>FL Out of State Code,</AFIELD12_HEADER>
    <AFIELD13_HEADER>FL Educational Wages,</AFIELD13_HEADER>
    </RECORD_HEADER>
    </A03_HEADER>
    <A03>
    <RECORD>
    <AFIELD1>SJAWID_SMWL BG,</AFIELD1>
    <AFIELD2>122000331,</AFIELD2>
    <AFIELD3>23,</AFIELD3>
    <AFIELD4>546-55-5024,</AFIELD4>
    <AFIELD5>SJAWID_SMWL AutoGenerated Employee,</AFIELD5>
    <AFIELD6>,</AFIELD6>
    <AFIELD7>SJAWID_SMWL FL Emp 1,</AFIELD7>
    <AFIELD8>,</AFIELD8>
    <AFIELD9>5000,</AFIELD9>
    <AFIELD10>5000,</AFIELD10>
    <AFIELD11>0,</AFIELD11>
    <AFIELD12>XX,</AFIELD12>
    <AFIELD13>0,</AFIELD13>
    </RECORD>
    </A03>
    <EMPLOYER_FOOTER>
    <MF>
    <RECORD>
    <TAX_UNIT_ID>24814</TAX_UNIT_ID>
    <FIELD1>1</FIELD1>
    <FIELD2>1</FIELD2>
    <FIELD3>0</FIELD3>
    <FIELD4>0</FIELD4>
    </RECORD>
    </MF>
    </EMPLOYER_FOOTER>
    <A01>
    <RECORD>
    <SUBMITTER_NAME>SJAWID_SMWL BG</SUBMITTER_NAME>
    <SUBMITTER_ADDRESS_LINE_2_3>ADDR2 ADDR3</SUBMITTER_ADDRESS_LINE_2_3>
    <SUBMITTER_ADDRESS_LINE_1>SJAWID_SMWL 123</SUBMITTER_ADDRESS_LINE_1>
    <SUBMITTER_CITY>San Francisco</SUBMITTER_CITY>
    <SUBMITTER_STATE_CODE>CA</SUBMITTER_STATE_CODE>
    <SUBMITTER_COMP_ZIP_CODE></SUBMITTER_COMP_ZIP_CODE>
    <EMPLOYER_NAME>SJAWID_SMWL BG</EMPLOYER_NAME>
    <EMPLOYER_EIN>122000331</EMPLOYER_EIN>
    <EMPLOYER_ADDRESS_LINE_2_3>ADDR2 ADDR3</EMPLOYER_ADDRESS_LINE_2_3>
    <EMPLOYER_ADDRESS_LINE_1>SJAWID_SMWL 123</EMPLOYER_ADDRESS_LINE_1>
    <EMPLOYER_CITY>San Francisco</EMPLOYER_CITY>
    <EMPLOYER_STATE_CODE>CA</EMPLOYER_STATE_CODE>
    <EMPLOYER_COMP_ZIP_CODE>941001234</EMPLOYER_COMP_ZIP_CODE>
    <EMPLOYER_SUI_ACC_NUMBER>SUI00010</EMPLOYER_SUI_ACC_NUMBER>
    <GRE_EMPLOYEE_COUNT>1</GRE_EMPLOYEE_COUNT>
    <ERROR_COUNT>0</ERROR_COUNT>
    <EMPLOYER_MONTH1_COUNT>1</EMPLOYER_MONTH1_COUNT>
    <EMPLOYER_MONTH2_COUNT>0</EMPLOYER_MONTH2_COUNT>
    <EMPLOYER_MONTH3_COUNT>0</EMPLOYER_MONTH3_COUNT>
    <EMPLOYER_SUI_ER_GROSS_QTD>5000</EMPLOYER_SUI_ER_GROSS_QTD>
    <EMPLOYER_SUI_ER_TAX_REDNS_QTD>0</EMPLOYER_SUI_ER_TAX_REDNS_QTD>
    <EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>5000</EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>
    <EMPLOYER_SUI_EXCESS_WAGES_QTD>0</EMPLOYER_SUI_EXCESS_WAGES_QTD>
    <EMPLOYER_SUI_ER_TAXABLE_QTD>5000</EMPLOYER_SUI_ER_TAXABLE_QTD>
    <EMPLOYER_SUI_ER_LIABILITY>0</EMPLOYER_SUI_ER_LIABILITY>
    <EMPLOYER_SIT_GROSS_QTD>0</EMPLOYER_SIT_GROSS_QTD>
    <EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>0</EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>
    <EMPLOYER_SIT_WITHHELD>0</EMPLOYER_SIT_WITHHELD>
    <SUI_TAXABLE_WAGE_BASE></SUI_TAXABLE_WAGE_BASE>
    <SUI_ER_RATE></SUI_ER_RATE>
    </RECORD>
    </A01>
    </GRE>
    <GRE>
    <EMPLOYER_HEADER>
    <MF>
    <RECORD>
    <TAX_UNIT_ID>24856</TAX_UNIT_ID>
    <FIELD1>1</FIELD1>
    <FIELD2>2013</FIELD2>
    <FIELD3>Ø</FIELD3>
    <FIELD4>1234586  </FIELD4>
    <FIELD5>Ø</FIELD5>
    <FIELD6>Ø</FIELD6>
    <FIELD7>Ø</FIELD7>
    <FIELD8>Ø</FIELD8>
    <FIELD9>Ø</FIELD9>
    <FIELD10>Ø</FIELD10>
    <FIELD11>0000000000</FIELD11>
    <FIELD12>Ø</FIELD12>
    <FIELD13>Ø</FIELD13>
    <FIELD14>Ø</FIELD14>
    <FIELD15>Ø</FIELD15>
    <FIELD16>Ø</FIELD16>
    <FIELD17>5000.00</FIELD17>
    <FIELD18>0.00</FIELD18>
    <FIELD19>5000.00</FIELD19>
    <FIELD20>.00</FIELD20>
    <FIELD21>0</FIELD21>
    <FIELD22>0</FIELD22>
    <FIELD23>0</FIELD23>
    </RECORD>
    </MF>
    </EMPLOYER_HEADER>
    <EMPLOYEE>
    <MF>
    <RECORD>
    <ASG_ID>76942</ASG_ID>
    <FIELD1>546555025</FIELD1>
    <FIELD2>SJAWID_SMWL AUT</FIELD2>
    <FIELD3>Ø</FIELD3>
    <FIELD4>SJAWID_SMWL FL EMP 2</FIELD4>
    <FIELD5>Ø</FIELD5>
    <FIELD6>5000.00</FIELD6>
    <FIELD7>5000.00</FIELD7>
    <FIELD8>.00</FIELD8>
    <FIELD9>XX</FIELD9>
    <FIELD10>.00</FIELD10>
    </RECORD>
    </MF>
    </EMPLOYEE>
    <A03>
    <RECORD>
    <AFIELD1>Sheker GRE 2,</AFIELD1>
    <AFIELD2>1234586,</AFIELD2>
    <AFIELD3>24,</AFIELD3>
    <AFIELD4>546-55-5025,</AFIELD4>
    <AFIELD5>SJAWID_SMWL AutoGenerated Employee,</AFIELD5>
    <AFIELD6>,</AFIELD6>
    <AFIELD7>SJAWID_SMWL FL Emp 2,</AFIELD7>
    <AFIELD8>,</AFIELD8>
    <AFIELD9>5000,</AFIELD9>
    <AFIELD10>5000,</AFIELD10>
    <AFIELD11>0,</AFIELD11>
    <AFIELD12>XX,</AFIELD12>
    <AFIELD13>0,</AFIELD13>
    </RECORD>
    </A03>
    <EMPLOYER_FOOTER>
    <MF>
    <RECORD>
    <TAX_UNIT_ID>24856</TAX_UNIT_ID>
    <FIELD1>1</FIELD1>
    <FIELD2>1</FIELD2>
    <FIELD3>0</FIELD3>
    <FIELD4>0</FIELD4>
    </RECORD>
    </MF>
    </EMPLOYER_FOOTER>
    <A01>
    <RECORD>
    <SUBMITTER_NAME></SUBMITTER_NAME>
    <SUBMITTER_ADDRESS_LINE_2_3>ADDR2 ADDR3</SUBMITTER_ADDRESS_LINE_2_3>
    <SUBMITTER_ADDRESS_LINE_1>SJAWID_SMWL 123</SUBMITTER_ADDRESS_LINE_1>
    <SUBMITTER_CITY></SUBMITTER_CITY>
    <SUBMITTER_STATE_CODE></SUBMITTER_STATE_CODE>
    <SUBMITTER_COMP_ZIP_CODE></SUBMITTER_COMP_ZIP_CODE>
    <EMPLOYER_NAME>Sheker GRE 2</EMPLOYER_NAME>
    <EMPLOYER_EIN>1234586</EMPLOYER_EIN>
    <EMPLOYER_ADDRESS_LINE_2_3></EMPLOYER_ADDRESS_LINE_2_3>
    <EMPLOYER_ADDRESS_LINE_1>SJAWID_SMWL 123</EMPLOYER_ADDRESS_LINE_1>
    <EMPLOYER_CITY>Saint Maurice</EMPLOYER_CITY>
    <EMPLOYER_STATE_CODE>LA</EMPLOYER_STATE_CODE>
    <EMPLOYER_COMP_ZIP_CODE>71471</EMPLOYER_COMP_ZIP_CODE>
    <EMPLOYER_SUI_ACC_NUMBER></EMPLOYER_SUI_ACC_NUMBER>
    <GRE_EMPLOYEE_COUNT>1</GRE_EMPLOYEE_COUNT>
    <ERROR_COUNT>0</ERROR_COUNT>
    <EMPLOYER_MONTH1_COUNT>1</EMPLOYER_MONTH1_COUNT>
    <EMPLOYER_MONTH2_COUNT>0</EMPLOYER_MONTH2_COUNT>
    <EMPLOYER_MONTH3_COUNT>0</EMPLOYER_MONTH3_COUNT>
    <EMPLOYER_SUI_ER_GROSS_QTD>5000</EMPLOYER_SUI_ER_GROSS_QTD>
    <EMPLOYER_SUI_ER_TAX_REDNS_QTD>0</EMPLOYER_SUI_ER_TAX_REDNS_QTD>
    <EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>5000</EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>
    <EMPLOYER_SUI_EXCESS_WAGES_QTD>0</EMPLOYER_SUI_EXCESS_WAGES_QTD>
    <EMPLOYER_SUI_ER_TAXABLE_QTD>5000</EMPLOYER_SUI_ER_TAXABLE_QTD>
    <EMPLOYER_SUI_ER_LIABILITY>0</EMPLOYER_SUI_ER_LIABILITY>
    <EMPLOYER_SIT_GROSS_QTD>0</EMPLOYER_SIT_GROSS_QTD>
    <EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>0</EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>
    <EMPLOYER_SIT_WITHHELD>0</EMPLOYER_SIT_WITHHELD>
    <SUI_TAXABLE_WAGE_BASE></SUI_TAXABLE_WAGE_BASE>
    <SUI_ER_RATE></SUI_ER_RATE>
    </RECORD>
    </A01>
    </GRE>
    <A01>
    <RECORD>
    <ALL_EMPLOYER_SUI_ER_GROSS_QTD>0</ALL_EMPLOYER_SUI_ER_GROSS_QTD>
    <ALL_EMPLOYER_SUI_ER_TAX_REDNS_QTD>0</ALL_EMPLOYER_SUI_ER_TAX_REDNS_QTD>
    <ALL_EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>0</ALL_EMPLOYER_SUI_REDUCED_SUBJ_WH_QTD>
    <ALL_EMPLOYER_SUI_EXCESS_WAGES_QTD>0</ALL_EMPLOYER_SUI_EXCESS_WAGES_QTD>
    <ALL_EMPLOYER_SUI_ER_TAXABLE_QTD>0</ALL_EMPLOYER_SUI_ER_TAXABLE_QTD>
    <ALL_EMPLOYER_SUI_ER_LIABILITY>0</ALL_EMPLOYER_SUI_ER_LIABILITY>
    <ALL_EMPLOYER_SIT_GROSS_QTD>0</ALL_EMPLOYER_SIT_GROSS_QTD>
    <ALL_EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>0</ALL_EMPLOYER_SIT_REDUCED_SUBJ_WH_QTD>
    <ALL_EMPLOYER_SIT_WITHHELD>0</ALL_EMPLOYER_SIT_WITHHELD>
    </RECORD>
    </A01>
    </REPORT>
    </XML_REPORT>

XSL File
-----------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns="http://www.irs.gov/efile">
<xsl:output method="xml" encoding="ISO-8859-1"/>

   <xsl:template match="text()|@*"></xsl:template>

   <xsl:template name="crlf">
    <xsl:text>&#x0A;</xsl:text>
   </xsl:template>

   <xsl:template match="/XML_REPORT/REPORT">
       <Transmission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

     <xsl:attribute name="xsi:schemaLocation">
              <xsl:value-of select="'http://www.irs.gov/efile Florida_Schema\DORXML\FSET\schemas\FLTransmission.xsd'"/>
         </xsl:attribute> 

     <xsl:call-template name="crlf"/>

      <xsl:for-each select="./*">
             <xsl:apply-templates select="."/>
          </xsl:for-each> 


       </Transmission>
   </xsl:template>

   <!-- Start of Transmission Header-->
   <xsl:template match="TRANSMITTER_HEADER/MF">
      <TransmissionHeader> 
         <xsl:call-template name="crlf"/>
         <Jurisdiction>Florida</Jurisdiction>
     <xsl:call-template name="crlf"/>
     <TransmissionId>FLUCT2009</TransmissionId> 
     <xsl:call-template name="crlf"/>
     <Timestamp> <xsl:value-of select="RECORD/FIELD1"/> </Timestamp>
     <xsl:call-template name="crlf"/>
     <Transmitter>
        <xsl:call-template name="crlf"/>
        <ETIN>00000</ETIN>
        <xsl:call-template name="crlf"/>
         </Transmitter>
     <xsl:call-template name="crlf"/>
     <ProcessType>P</ProcessType>
     <xsl:call-template name="crlf"/>
     </TransmissionHeader>
     <xsl:call-template name="crlf"/>
     <OriginHeaders>
       <xsl:call-template name="crlf"/>
       <ReturnOriginHeader>
       <xsl:call-template name="crlf"/>
         <OriginId>00000000</OriginId>
         <xsl:call-template name="crlf"/>
             <Timestamp> <xsl:value-of select="RECORD/FIELD1" /> </Timestamp> 
         <xsl:call-template name="crlf"/>
         <OriginManifest itemCount="1">
            <xsl:call-template name="crlf"/>
        <xsl:variable name="sui_comp_state_id" select="RECORD/FIELD3"/>
                <ItemReference contentLocation="{$sui_comp_state_id}"/>
        <xsl:call-template name="crlf"/>
         </OriginManifest>
         <xsl:call-template name="crlf"/>
          <Originator>
             <xsl:call-template name="crlf"/>
             <xsl:choose>
            <xsl:when test="RECORD/FIELD5 != 'Ø'">
                <AgentIdentifier><xsl:value-of select="RECORD/FIELD5" /> </AgentIdentifier>
            </xsl:when>
            <xsl:otherwise>
                <AgentIdentifier><xsl:value-of select="RECORD/FIELD4" /> </AgentIdentifier>
            </xsl:otherwise>
         </xsl:choose>
         <xsl:call-template name="crlf"/>
          </Originator>
          <xsl:call-template name="crlf"/>
       </ReturnOriginHeader>
       <xsl:call-template name="crlf"/>
     </OriginHeaders>
         <xsl:call-template name="crlf"/>
   </xsl:template>
    <!-- End of Transmission Header-->

   <xsl:template match="GRE">
       <ReturnData documentCount="1">
       <xsl:call-template name="crlf"/>
          <!-- Start of Employer Header-->
          <StateReturn>
        <xsl:call-template name="crlf"/>
        <StateUI documentType="Form" documentName="FSET StateUI" documentId="UCT-6">
           <xsl:call-template name="crlf"/>
           <ReturnHeader>
              <xsl:call-template name="crlf"/>
              <Quarter> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD1"/> </Quarter>
          <xsl:call-template name="crlf"/> 
          <Taxyear> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD2"/> </Taxyear>
          <xsl:call-template name="crlf"/>
          <SoftwareId>10001228</SoftwareId>
          <xsl:call-template name="crlf"/>
          <ReturnType>StateUI</ReturnType>
          <xsl:call-template name="crlf"/>
          <Form>UCT-6</Form>
          <xsl:call-template name="crlf"/>
          <FilingAction>
            <xsl:call-template name="crlf"/>
            <Action>Original</Action>
            <xsl:call-template name="crlf"/>
            <Reason> <xsl:value-of select="replace(EMPLOYER_HEADER/MF/RECORD/FIELD3,'Ø','')"/> </Reason>
            <xsl:call-template name="crlf"/> 
          </FilingAction>
          <xsl:call-template name="crlf"/>
          <TIN>
             <xsl:call-template name="crlf"/>
             <TypeTIN>FEIN</TypeTIN>
             <xsl:call-template name="crlf"/>
             <TINTypeValue> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD4"/> </TINTypeValue>
             <xsl:call-template name="crlf"/>
          </TIN>
          <xsl:call-template name="crlf"/>
          <StateEIN>
             <xsl:call-template name="crlf"/>
             <TypeStateEIN>UIAccountNo</TypeStateEIN>
             <xsl:call-template name="crlf"/>
             <StateEINValue> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD5"/> </StateEINValue>
             <xsl:call-template name="crlf"/>
          </StateEIN>
          <xsl:call-template name="crlf"/>
          <BusinessAddress>
            <xsl:call-template name="crlf"/> 
            <BusinessName> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD6"/> </BusinessName>
            <xsl:call-template name="crlf"/>
            <AddressLine> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD7"/> </AddressLine>
            <xsl:call-template name="crlf"/>
            <City> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD8"/> </City>
            <xsl:call-template name="crlf"/>
            <StateOrProvince> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD9"/> </StateOrProvince>
            <xsl:call-template name="crlf"/>
            <ZipCode> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD10"/> </ZipCode>
            <xsl:call-template name="crlf"/>
            <PhoneNumber> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD11"/> </PhoneNumber>
            <xsl:call-template name="crlf"/> 
          </BusinessAddress>
          <xsl:call-template name="crlf"/>
          <Contact>
            <xsl:call-template name="crlf"/>
            <ContactName>
              <xsl:call-template name="crlf"/>
              <FirstName> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD12"/> </FirstName>
              <xsl:call-template name="crlf"/>
              <MiddleName> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD13"/> </MiddleName>
              <xsl:call-template name="crlf"/>
              <LastName> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD14"/> </LastName> 
              <xsl:call-template name="crlf"/>
            </ContactName>
            <xsl:call-template name="crlf"/>
            <Phone> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD15"/> </Phone>
            <xsl:call-template name="crlf"/>
            <EmailAddress> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD16"/> </EmailAddress>
            <xsl:call-template name="crlf"/>
          </Contact>
          <xsl:call-template name="crlf"/>
           </ReturnHeader>
           <xsl:call-template name="crlf"/>
           <UITotalWages> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD17"/> </UITotalWages>
           <xsl:call-template name="crlf"/>
           <ExcessWages> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD18"/> </ExcessWages>
           <xsl:call-template name="crlf"/>
           <UITaxableWages> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD19"/> </UITaxableWages>
           <xsl:call-template name="crlf"/>
           <ContributionRate>0.00</ContributionRate>
           <xsl:call-template name="crlf"/>
           <ContributionDue> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD20"/> </ContributionDue>
           <xsl:call-template name="crlf"/>
           <UIInterest> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD21"/> </UIInterest>
           <xsl:call-template name="crlf"/>
           <UIPenalty> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD22"/> </UIPenalty>
           <xsl:call-template name="crlf"/>
           <UITotalDue> <xsl:value-of select="./EMPLOYER_HEADER/MF/RECORD/FIELD23"/> </UITotalDue>
           <!-- End of Employer Header-->
           <xsl:call-template name="crlf"/>
           <PayRoll>
           <xsl:call-template name="crlf"/>
           <!-- Start of Employee-->
              <xsl:for-each select="./EMPLOYEE/MF/RECORD">
             <Employee>
                 <xsl:call-template name="crlf"/>
                 <SSN> <xsl:value-of select="./FIELD1"/> </SSN>
             <xsl:call-template name="crlf"/>
             <Employee>
                <xsl:call-template name="crlf"/>
                <FirstName> <xsl:value-of select="./FIELD2"/> </FirstName>
                <xsl:call-template name="crlf"/>
                <MiddleName> <xsl:value-of select="./FIELD3"/> </MiddleName>
                <xsl:call-template name="crlf"/>
                <LastName> <xsl:value-of select="./FIELD4"/> </LastName>
                <xsl:call-template name="crlf"/>
                <Suffix> <xsl:value-of select="./FIELD5"/> </Suffix>
                <xsl:call-template name="crlf"/>
             </Employee>
             <xsl:call-template name="crlf"/>
             <TotalWages> <xsl:value-of select="./FIELD6"/>  </TotalWages>
             <xsl:call-template name="crlf"/>
             <TaxableWages> <xsl:value-of select="./FIELD7"/> </TaxableWages>
             <xsl:call-template name="crlf"/>
             <OutOfStateWages>
                <xsl:call-template name="crlf"/>
                <TotalWages>0.00</TotalWages>
                <xsl:call-template name="crlf"/>
                <TaxableWages> <xsl:value-of select="./FIELD8"/> </TaxableWages>
                <xsl:call-template name="crlf"/>
                <TaxState> <xsl:value-of select="./FIELD9"/> </TaxState>
                <xsl:call-template name="crlf"/>
             </OutOfStateWages>
             <xsl:call-template name="crlf"/>
             <EducationalWages>
                <xsl:call-template name="crlf"/>
                <TotalWages> <xsl:value-of select="./FIELD10"/> </TotalWages>
                <xsl:call-template name="crlf"/>
             </EducationalWages>
             </Employee>
             <xsl:call-template name="crlf"/>
          </xsl:for-each>
               <!-- End of Employee-->
           </PayRoll>
           <xsl:call-template name="crlf"/>
           <!-- Start of Employer Footer-->
           <NumberOfEmployees> <xsl:value-of select="./EMPLOYER_FOOTER/MF/RECORD/FIELD1"/> </NumberOfEmployees>
           <xsl:call-template name="crlf"/>
           <Month1Employees> <xsl:value-of select="./EMPLOYER_FOOTER/MF/RECORD/FIELD2"/> </Month1Employees>
           <xsl:call-template name="crlf"/>
           <Month2Employees> <xsl:value-of select="./EMPLOYER_FOOTER/MF/RECORD/FIELD3"/> </Month2Employees>
           <xsl:call-template name="crlf"/>
           <Month3Employees> <xsl:value-of select="./EMPLOYER_FOOTER/MF/RECORD/FIELD4"/> </Month3Employees>
           <!-- End of Employer Footer-->
        </StateUI>
        <xsl:call-template name="crlf"/>
      </StateReturn>
      <xsl:call-template name="crlf"/>
       </ReturnData>
       <xsl:call-template name="crlf"/>
   </xsl:template>


</xsl:stylesheet>

1 个答案:

答案 0 :(得分:0)

我想在每个字段上使用replace()都可以。

解决方案#1

你可以做的是定义你自己的功能包装“标准”替换 - 只是为了节省一些打字并简化将来的最终更改。但你仍然必须在每个单独的领域使用它。

功能可能就像是关注:

<xsl:function name="my:myReplace">
    <xsl:param name="stringForReplacing" />
    <xsl:value-of select="replace($stringForReplacing, 'Ø', '')" />
</xsl:function>

然后你可以称之为

<xsl:value-of select="my:myReplace(EMPLOYER_HEADER/MF/RECORD/FIELD10)"/>

解决方案#2

我也尝试了一些技巧 - 它似乎工作但你应该测试一下。 我定义了“帮助”模板

<xsl:template match="node() | @*" mode="replacing">
    <xsl:copy>
        <xsl:apply-templates select="node() | @*" mode="replacing" />
    </xsl:copy>
</xsl:template>

<xsl:template match="text()" mode="replacing">
    <xsl:value-of select="replace(., 'Ø', '')" />
</xsl:template>

在“main”模板中,我声明了一个变量,该变量由文档的“副本”填充(并且使用帮助器模板替换所需的值)。然后我处理这个变量而不是原始的xml文件。

<xsl:template match="/XML_REPORT/REPORT">
    <Transmission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <xsl:attribute name="xsi:schemaLocation">
            <xsl:value-of select="'http://www.irs.gov/efile Florida_Schema\DORXML\FSET\schemas\FLTransmission.xsd'"/>
        </xsl:attribute>

        <!-- This is a helper variable-->
        <xsl:variable name="replaced">
            <xsl:apply-templates select="node() | @*" mode="replacing"/>
        </xsl:variable>

        <!-- Processing this variable instead of original xml file-->
        <xsl:for-each select="$replaced/*">
            <xsl:apply-templates select="."/>
        </xsl:for-each>

    </Transmission>
</xsl:template>

我希望它能帮到你


顺便说一句,从我的观点来看,使用<xsl:call-template name="crlf"/>似乎是不必要的,因为你可以声明<xsl:output method="xml" encoding="ISO-8859-1" indent="yes"/> - 它会很好地格式化输出。