2

我有一个以前可以工作的 xslt,但现在在转换过程中“跳过”了一个节点,我不明白为什么。下面是 xslt 的一小部分,经过编辑后可以使用。

  <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn" xmlns:com="http://enrollmentservices.humana.com/V2.0/common" xmlns:ent="http://enrollmentservices.humana.com/V2.0/enrollmententities" xmlns:pro="http://enrollmentservices.humana.com/V2.0/product" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pcext="http://enrollmentservices.humana.com/Policy/V2.0/PolicyExtract">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <xsl:variable name="_PolicyPath" select="PolicyExtract/ContractLineOfCoverageList/ContractLineOfCoverage"/>
        <PolicyExtract>
            <xsl:copy-of select="pcext:TotalRecordCount"/>
            <ContractLineOfCoverageList>

            </ContractLineOfCoverageList>
        </PolicyExtract>
    </xsl:template>
</xsl:stylesheet> 

我想要的节点是,当我通过它运行下面的文本时,它“跳过”那个节点(并且只有那个节点)这里的 xml 将适合提供的 xslt。

<?xml version="1.0" encoding="utf-8"?>
<PolicyExtract xmlns:ent="http://enrollmentservices.humana.com/V2.0/enrollmententities" xmlns:pcext="http://enrollmentservices.humana.com/Policy/V2.0/PolicyExtract" xmlns:pro="http://enrollmentservices.humana.com/V2.0/product" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><pcext:TotalRecordCount>4</pcext:TotalRecordCount><ContractLineOfCoverageList></ContractLineOfCoverageList></PolicyExtract>

TotalRecordCount 已计入,但不会转移。我也在调试器中尝试过,它跳过了那条线。

有任何想法吗?

4

1 回答 1

2

xsl:copy-of从此更改您的声明:

<xsl:copy-of select="pcext:TotalRecordCount"/>

对此

<xsl:copy-of select="PolicyExtract/pcext:TotalRecordCount"/>

为了复制pcext:TotalRecordCount元素:

<?xml version="1.0" encoding="UTF-8"?>
<PolicyExtract xmlns:com="http://enrollmentservices.humana.com/V2.0/common"
               xmlns:ent="http://enrollmentservices.humana.com/V2.0/enrollmententities"
               xmlns:pro="http://enrollmentservices.humana.com/V2.0/product"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:pcext="http://enrollmentservices.humana.com/Policy/V2.0/PolicyExtract">
   <pcext:TotalRecordCount>4</pcext:TotalRecordCount>
   <ContractLineOfCoverageList/>
</PolicyExtract>
于 2013-10-29T20:07:45.967 回答