我正在使用XSLT使用Crystal Report 2011 Export,并且出于某种原因无法在XSLT中使用标记namespace-alias。
我有以下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来执行它。
任何帮助表示感谢。
由于 克雷格
答案 0 :(得分: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">