0

我正在使用 XSLT 使用 Crystal Report 2011 导出,并且由于某种原因无法在 XSLT 中使用标记命名空间别名。

我有以下 XSLT:-

      <xsl:namespace-alias stylesheet-prefix="b" result-prefix="#default"/>

      <xsl:template match="/b:CrystalReport">
        <root>
          <xsl:for-each select="b:Details">
            <person>
              <VRN><xsl:value-of select="b:Section/b:Field[@Name='ITMVEHICLEREGNUM1']/b:FormattedValue"/></VRN>
              <Make><xsl:value-of select="b:Section/b:Field[@Name='ITMMANUDESC1']/b:FormattedValue"/></Make>
              <Model><xsl:value-of select="b:Section/b:Field[@Name='ITMODELDESC1']/b:FormattedValue"/></Model>
              <PolicyNumber><xsl:value-of select="b:Section/b:Field[@Name='POLEXTERNAL11']/b:FormattedValue"/></PolicyNumber>
              <Title><xsl:value-of select="b:Section/b:Field[@Name='TITDESCRIPTION1']/b:FormattedValue"/></Title>
              <FirstName><xsl:value-of select="b:Section/b:Field[@Name='CLIFIRST1']/b:FormattedValue"/></FirstName>
              <LastName><xsl:value-of select="b:Section/b:Field[@Name='CLISURN1']/b:FormattedValue"/></LastName>
              <PostCode><xsl:value-of select="b:Section/b:Field[@Name='ADRPOSTCODE1']/b:FormattedValue"/></PostCode>
              <CoverStartDate><xsl:value-of select="b:Section/b:Field[@Name='POLRENDATE1']/b:FormattedValue"/></CoverStartDate>
              <CoverEndDate><xsl:value-of select="b:Section/b:Field[@Name='POLENDDATE1']/b:FormattedValue"/></CoverEndDate>
              <FullyComp><xsl:value-of select="b:Section/b:Field[@Name='ITMCOVERTYPECDE1']/b:FormattedValue"/></FullyComp>
              <GlassLimit>500</GlassLimit>
              <GlassExcess>75</GlassExcess>
              <VatReg><xsl:value-of select="b:Section/b:Field[@Name='CLIVATREG1']/b:FormattedValue"/></VatReg>
              <AccidentDamageExecess>N/A</AccidentDamageExecess>
              <RepairExcess>0.00</RepairExcess>
              <Insurer><xsl:value-of select="b:Section/b:Field[@Name='INSNAME1']/b:FormattedValue"/></Insurer>
              <Referral><xsl:value-of select="b:Section/b:Field[@Name='CENDESC1']/b:FormattedValue"/></Referral>
            </person>
          </xsl:for-each>
        </root>
      </xsl:template>

    </xsl:stylesheet>

输出看起来像: -

    <root xmlns:b="urn:crystal-reports:schemas:report-detail">  
      <person>  
        <VRN>XXXXXX</VRN>  
        <Make>AUSTIN</Make>  
        <Model>A35</Model>  
        <PolicyNumber>XXXXXXXX</PolicyNumber>  
        <Title>Mr</Title>  
        <FirstName>Gareth</FirstName>  
        <LastName>Jones</LastName>  
        <PostCode>AL23 6TR</PostCode>  
        <CoverStartDate>06.04.2011</CoverStartDate>  
        <CoverEndDate>05.04.2012</CoverEndDate>  
        <FullyComp>01</FullyComp>  
        <GlassLimit>500</GlassLimit>  
        <GlassExcess>75</GlassExcess>  
        <VatReg></VatReg>  
        <AccidentDamageExecess>N/A</AccidentDamageExecess>  
        <RepairExcess>0.00</RepairExcess>  
        <Insurer>My Insurer</Insurer>  
        <Referral>Direct</Referral>  
      </person>  
    </root>

我需要能够从标签中删除命名空间,并且只能使用 1 个 XSLT 来完成。

任何帮助表示赞赏。

谢谢克雷格

4

1 回答 1

1

你不需要在namespace-alias这里使用。结果已经在 null 命名空间中,但如果你想禁止b命名空间声明,你只需要使用exclude-result-prefixes

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:b="urn:crystal-reports:schemas:report-detail"
    exclude-result-prefixes="b">
于 2013-02-05T13:10:18.673 回答