2017-06-12 54 views
-1

我是XSL文件的新手,我在解密下面的一段代碼時遇到了一些麻煩。我搜索了互聯網,找不到任何東西來告訴我「nsl」究竟是什麼意思。 有人可以請爲我澄清這一點嗎? 這是SOA系統的一部分。「NSL」在XSL文件中的含義

   <xsl:when test='ns1:Payment/ns1:PaymentHeader/ns1:ConsolidationType = "STANDARD"'> 
        <xsl:for-each select="ns1:Payment/ns1:PaymentModeDetail/ns1:GenericDetail/ns1:GenericLineItem"> 
         <ns0:ApInvoiceLinesInterface> 
          <ns0:invoiceLineId> 
          <xsl:value-of select="oraext:sequence-next-val('AP_INVOICE_LINES_INTERFACE_S',$CONN)"/> 
          </ns0:invoiceLineId> 
          <xsl:choose> 
          <xsl:when test="ns1:CommonInvoiceLineElements/ns1:AdjustmentReasonGid/ns1:Gid/ns1:Xid!=''">         
           <ns0:lineTypeLookupCode> 
            <xsl:text disable-output-escaping="no">MISCELLANEOUS</xsl:text> 
           </ns0:lineTypeLookupCode> 
          </xsl:when> 
          <xsl:otherwise> 
           <ns0:lineTypeLookupCode> 
            <xsl:text disable-output-escaping="no">FREIGHT</xsl:text> 
           </ns0:lineTypeLookupCode> 
          </xsl:otherwise> 
          </xsl:choose> 
          <ns0:amount> 
          <xsl:value-of select="ns1:CommonInvoiceLineElements/ns1:FreightRate/ns1:FreightCharge/ns1:FinancialAmount/ns1:MonetaryAmount"/> 
          </ns0:amount> 
          <ns0:description> 
          <xsl:value-of select='concat(substring-after(../../../ns1:PaymentHeader/ns1:InvoiceRefnum[ns1:InvoiceRefnumQualifierGid/ns1:Gid/ns1:Xid="INVOICE_DESCRIPTION"]/ns1:InvoiceRefnumValue,"BNM."),ns1:CostTypeGid/ns1:Gid/ns1:Xid)'/> 
          </ns0:description> 
          <ns0:taxClassificationCode> 
          <xsl:value-of select='concat(../../../ns1:PaymentHeader/ns1:VatAnalysis/ns1:VatCodeGid/ns1:Gid/ns1:Xid,"%")'/> 
          </ns0:taxClassificationCode> 
          <ns0:distCodeConcatenated> 
          <xsl:value-of select="ns1:CommonInvoiceLineElements/ns1:GeneralLedgerGid/ns1:Gid/ns1:Xid"/> 
          </ns0:distCodeConcatenated> 
         </ns0:ApInvoiceLinesInterface> 
        </xsl:for-each> 
       </xsl:when> 

的是這,我想了解最多的是:

<ns0:amount> 
    <xsl:value-of select="ns1:CommonInvoiceLineElements/ns1:FreightRate/ns1:FreightCharge/ns1:FinancialAmount/ns1:MonetaryAmount"/> 
</ns0:amount> 

我對想這樣的一個理解的原因,是因爲我相信的代碼與此塊以下段將返回當傳遞給它的負數時,該數字爲正值。

在此先感謝!

+1

它不是'nsl',而是'ns1',最後一個字符爲'1'。不幸的是,我沒有時間給出完整的答案,但是查找「XML名稱空間」。這些名稱空間也可以在XPath查詢中使用('select =「」'內的東西)。 – Boldewyn

+1

「我搜查了互聯網......」你需要找到一個更有效的學習策略。如果你不知道ns1是一個命名空間前綴,那麼互聯網不會告訴你。讀一本關於XPath的書(或者甚至閱讀W3C規範)會讓你的答案快得多。 –

回答

2

ns1是用於選擇名稱空間中的元素的前綴。某處在樣式表有一個命名空間聲明綁定這個前綴命名空間URI,在形式:

xmlns:ns1="some/string" 

某處在你的源XML也存在類似的命名空間聲明將其部分或全部元素在這個命名空間。您需要使用綁定到相同名稱空間URI的前綴來選擇此名稱空間中的元素。

相信的代碼與該塊下面的段被用於數返回 正值時,有通過 給它的負數。

我沒有看到這種信念的基礎。爲什麼不發佈顯示問題的(最小化)示例。