2013-10-29 149 views
2

我有一個xslt,以前用於工作,但現在在轉換過程中「跳過」一個節點,我不明白爲什麼。接下來是xslt editi編輯的一小部分可行。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> 

我希望節點又是當我穿過它下面的文本,它「跳過」該節點(只有該節點)繼承人,將適合通過所提供的XSLT的XML。

<?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被計入但不會轉移。我也在調試器中嘗試過它,並跳過該行。

有什麼想法?

+2

請張貼COM完成了XML和XSLT,或者更好,是表現問題的最小的完整集合。謝謝。 – kjhughes

+0

包含問題的xslt位於頂部,包含相關節點的xml低於該值 – rigamonk

+2

您需要發佈一個小示例輸入文件。沒有輸入的例子,沒有人能夠幫助你。 – PhillyNJ

回答

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

完美。謝謝 – rigamonk