【问题标题】:"NSL" meaning in XSL fileXSL 文件中的“NSL”含义
【发布时间】:2023-03-03 10:59:01
【问题描述】:

我是 XSL 文件的新手,在解读以下代码的作用时遇到了一些麻烦。我搜索了互联网,找不到任何东西可以告诉我“nsl”的确切含义。 有人可以为我解释一下吗? 这是 SOA 系统的一部分。

                <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>

我想了解这一点的原因是,我相信带有此块的以下代码段在传递给它的负数时会为该数字返回一个正值。

提前致谢!

【问题讨论】:

  • 不是nsl,而是ns1,最后一个字符是一个。不幸的是,我没有时间给出完整的答案,但请寻找“XML 名称空间”。这些命名空间也可以在 XPath 查询中使用(select="" 中的内容)。
  • “我已经在网上搜索了...” 你需要找到更有效的学习策略。如果您不知道 ns1 是名称空间前缀,那么互联网不会告诉您。阅读一本关于 XPath 的书(甚至阅读 W3C 规范)会给你更快的答案。

标签: xml xslt soa


【解决方案1】:

ns1 是一个前缀,用于选择命名空间中的元素。在您的样式表的某处有一个命名空间声明将此前缀绑定到命名空间 URI,其形式为:

xmlns:ns1="some/string"

在您的源 XML 中某处有一个类似的命名空间声明,将其部分或全部元素放置在此命名空间中。您需要使用绑定到相同命名空间 URI 的前缀才能选择此命名空间中的元素。

我相信带有此块的以下代码段正在返回 当有一个负数传递时,该数字的正值 给它。

我认为这种信念没有根据。您为什么不发布一个(最小化)示例来说明问题。

【讨论】:

    猜你喜欢
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 2011-12-17
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多