我唯一想做的就是获取元素
<CityDescription>
并<Population>
出现在输出的同一行
这部分代码:
<xsl:template match="CityDescription"><CityDescription><xsl:value-of select="."/></CityDescription> <xsl:text>
</xsl:text></xsl:template>
CityDescription
在元素之后显式生成一个 NL 字符。
CityDescription
这会导致额外生成的任何内容出现在元素下方至少一行。
一种明显的解决方案是删除xslt:text
生成 NL 字符的 。
如果 NL 字符仅被几个空格替换,那么问题就消失了。
这是修正后的转换:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="no" />
<xsl:strip-space elements="*"/>
<xsl:output method="xml"/>
<xsl:template match="/">
<Root>
<Story><xsl:apply-templates select="Root/Story/CL"/></Story>
</Root>
</xsl:template>
<xsl:template match="CityDescription"><CityDescription><xsl:value-of select="."/></CityDescription>
<xsl:text> </xsl:text></xsl:template><xsl:template match="CL/Population"><Population><xsl:value-of select="."/></Population></xsl:template>
<xsl:template match="BankName | Address1 | Hours | Established | RoutingNbr | CO/CityOfficePhone | CO/CityOfficeAddress2 "><xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element></xsl:template>
<xsl:template match="BK">
<xsl:apply-templates select="BankName"/><xsl:text> </xsl:text><xsl:apply-templates select="Established"/><xsl:text> </xsl:text><xsl:apply-templates select="RoutingNbr"/><xsl:text>
</xsl:text>
<xsl:apply-templates select="OfficeOfLabel"/>
<xsl:apply-templates select="Address1"/><xsl:text> </xsl:text><xsl:apply-templates select="Hours"/><xsl:text>
</xsl:text>
<xsl:apply-templates select="Address2"/><xsl:apply-templates select="Zip"/>
<xsl:apply-templates select="Phone"/><xsl:apply-templates select="Fax"/><xsl:text>
</xsl:text>
<xsl:apply-templates select="Email"/>
<xsl:apply-templates select="Web"/>
<xsl:apply-templates select="HoldingCo"/>
<xsl:apply-templates select="TotalAssets"/><xsl:apply-templates select="TotalLiabilities"/>
<xsl:apply-templates select="TotalDeposits"/><xsl:apply-templates select="EquityCapital"/>
<xsl:apply-templates select="EH/Employee"/>
<xsl:apply-templates select="D"/>
<xsl:apply-templates select="CB"/>
<xsl:apply-templates select="OFF"/>
<xsl:apply-templates select="CO"/>
<xsl:apply-templates select="MultiBankLabel"/>
<xsl:apply-templates select="IBAGroup"/><xsl:apply-templates select="FDICNbr"/>
</xsl:template>
<xsl:template match="HoldingCo">
<HoldingCo>
<xsl:text>Holding Co: </xsl:text>
<xsl:value-of select="."/></HoldingCo><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="Phone">
<Phone><xsl:value-of select="."/></Phone><xsl:text> </xsl:text></xsl:template>
<xsl:template match="Fax">
<Fax><xsl:value-of select="."/></Fax></xsl:template>
<xsl:template match="EH/Employee">
<Employee><xsl:value-of select="."/></Employee><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="Zip">
<Zip><xsl:value-of select="."/></Zip><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="Address2">
<Address2><xsl:value-of select="."/></Address2><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="Email">
<Email><xsl:value-of select="."/></Email><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="Web">
<Web><xsl:text>Web: </xsl:text><xsl:value-of select="."/></Web><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="TotalAssets">
<TotalAssets><xsl:text>Total Assets $</xsl:text><xsl:value-of select="."/></TotalAssets><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="TotalLiabilities">
<TotalLiabilities><xsl:text>Total Liabilities $</xsl:text>
<xsl:value-of select="."/></TotalLiabilities><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="TotalDeposits">
<TotalDeposits><xsl:text>Total Deposits </xsl:text>
<xsl:value-of select="."/></TotalDeposits><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="EquityCapital">
<EquityCapital><xsl:text>Equity Capital </xsl:text><xsl:value-of select="."/></EquityCapital><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="IBAGroup">
<IBAGroup><xsl:text>IBA Group: </xsl:text><xsl:value-of select="."/></IBAGroup><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="FDICNbr">
<FDICNbr><xsl:text>FDIC Certificate No.: </xsl:text><xsl:value-of select="."/></FDICNbr><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="OFF"><OfficeLabel><xsl:value-of select="OfficeLabel"/><xsl:text>: </xsl:text></OfficeLabel><Office><xsl:value-of select="Office"/></Office><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="D"><DirectorLabel><xsl:value-of select="DirectorLabel"/><xsl:text>: </xsl:text></DirectorLabel><Director><xsl:value-of select="Director"/></Director><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="CB"><CorrespondingBankLabel><xsl:value-of select="CorrespondingBankLabel"/></CorrespondingBankLabel><xsl:text>: </xsl:text><CorrespondingBank><xsl:value-of select="CorrespondingBank"/></CorrespondingBank><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="OfficeOfLabel">
<OfficeOfLabel><xsl:value-of select="."/></OfficeOfLabel><xsl:text>
</xsl:text></xsl:template>
<xsl:template match="CO"><CityOfficeLabel><xsl:value-of select="CityOfficeLabel"/><xsl:text>:
</xsl:text></CityOfficeLabel><CityOfficeAddress1><xsl:value-of select="CityOfficeAddress1"/></CityOfficeAddress1><xsl:text>
</xsl:text><CityOfficeZip><xsl:value-of select="CityOfficeZip"/></CityOfficeZip><xsl:text>
</xsl:text><CityOfficePhone><xsl:value-of select="CityOfficePhone"/></CityOfficePhone><xsl:text>
</xsl:text></xsl:template>
</xsl:stylesheet>
当应用于您上一个问题中提供的 XML 文档时,我正在使用所有九种不同的 XSLT 1.0 和 XSLT 2.0 处理器:
<Root>
<Story>
<CL>
<CityDescription>ACKLEY, HARDIN CO.</CityDescription>
<Population>POP. 1589</Population>
<BK>
<BankName>Ackley State Bank</BankName>
<BankType>BANKS</BankType>
<Established>Est. 1934</Established>
<RoutingNbr>0739-0535-2</RoutingNbr>
<Address1>650 Main St</Address1>
<Hours>Hrs: M-F 8-3</Hours>
<Address2>PO Box 149</Address2>
<Zip>50601-1438</Zip>
<Fax>FAX: (641) 847-2011</Fax>
<Phone>(641) 847-2651</Phone>
<Email>e-Mail: asbinfo@bankasb.com</Email>
<WebURL>Web: www.ackleystatebank.com</WebURL>
<HoldingCo>GNB Bancorporation, Grundy Center</HoldingCo>
<SubChapS>Yes</SubChapS>
<TotalAssets>128,319,000</TotalAssets>
<TotalLiabilities>117,059,000</TotalLiabilities>
<TotalDeposits>89,847,000</TotalDeposits>
<EquityCapital>11,260,000</EquityCapital>
<IBAGroup>7</IBAGroup>
<FDICNbr>14936</FDICNbr>
<EH>
<Employee>Kevin Swalley, Chmn</Employee>
</EH>
<EH>
<Employee>V.J. Barker, Pres</Employee>
</EH>
<EH>
<Employee>Kathy M Eichmeier, VP, Cash</Employee>
</EH>
<EH>
<Employee>Darren Janssen, VP</Employee>
</EH>
<EH>
<Employee>Gene Sandell, CFO</Employee>
</EH>
<EH>
<Employee>Angela M Luhring, SLO</Employee>
</EH>
<EH>
<Employee>Briget Meyer, Mktg</Employee>
</EH>
<EH>
<Employee>Josh Meyer, LO</Employee>
</EH>
<EH>
<Employee>Sharon Pudenz, LO</Employee>
</EH>
<EH>
<Employee>Deb Willms, TO</Employee>
</EH>
<D>
<DirectorLabel>Directors</DirectorLabel>
<Director>Doug Hofmeister, Hollis Janssen, Joseph Wojcik, Bob Johanns, Steve McDowell, Kevin Swalley, Mark Sexton, Verlin (Gus) Barker</Director>
</D>
<CB>
<CorrespondingBankLabel>Correspondent Banks</CorrespondingBankLabel>
<CorrespondingBank>Bankers Bank, Madison; FHLB, Des Moines; Quad City Bank & Trust; UMB, Kansas City; US Bank, NA, Cedar Rapids</CorrespondingBank>
</CB>
<OFF>
<OfficeLabel>Offices</OfficeLabel>
<Office>Geneva, Iowa Falls, Story City</Office>
</OFF>
</BK>
<BK>
<BankName>Green Belt Bank & Trust</BankName>
<RoutingNbr>0739-2167-9</RoutingNbr>
<Address1>419 Sherman Ave</Address1>
<Zip>50601-1206</Zip>
<Fax>FAX: (641) 847-0022</Fax>
<Phone>(641) 847-0011</Phone>
<OfficeOfLabel>Office of Green Belt Bank & Trust, Iowa Falls</OfficeOfLabel>
<EH>
<Employee>Janet DeBerg, VP, OM</Employee>
</EH>
</BK>
<BK>
<BankName>Peoples Savings Bank</BankName>
<Address1>33149 161st St</Address1>
<Zip>50601-7774</Zip>
<Fax>FAX: (641) 847-2602</Fax>
<Phone>(641) 847-3126</Phone>
<OfficeOfLabel>Office of Peoples Savings Bank, Wellsburg</OfficeOfLabel>
<EH>
<Employee>Lance Haupt, LO</Employee>
</EH>
</BK>
</CL>
<CL>
<CityDescription>ADAIR, ADAIR CO.</CityDescription>
<Population>POP. 781</Population>
<BK>
<BankName>Exchange State Bank</BankName>
<BankType>BANKS</BankType>
<Established>Est. 1879</Established>
<RoutingNbr>0739-0680-1</RoutingNbr>
<Address1>322 Audubon</Address1>
<Hours>Hrs: M-TH 9-3 F 9-5</Hours>
<Address2>PO Box 98</Address2>
<Zip>50002-0098</Zip>
<Fax>FAX: (641) 742-3424</Fax>
<Phone>(641) 742-3201</Phone>
<WebURL>Web: www.esbanks.com</WebURL>
<HoldingCo>Exchange Financial Inc., Adair</HoldingCo>
<SubChapS>Yes</SubChapS>
<TotalAssets>51,817,000</TotalAssets>
<TotalLiabilities>46,937,000</TotalLiabilities>
<TotalDeposits>39,503,000</TotalDeposits>
<EquityCapital>4,880,000</EquityCapital>
<IBAGroup>5</IBAGroup>
<FDICNbr>18838</FDICNbr>
<EH>
<Employee>Charles J Gaffey, Pres, CEO</Employee>
</EH>
<EH>
<Employee>Kendall Kerns, EVP, RELO</Employee>
</EH>
<EH>
<Employee>Debra Lemke, VP, Cash</Employee>
</EH>
<EH>
<Employee>Lisa J Plowman, AVP, IT</Employee>
</EH>
<EH>
<Employee>Mel Jorgensen, COO</Employee>
</EH>
<D>
<DirectorLabel>Directors</DirectorLabel>
<Director>Harold Scholl, Rex Noland, W. Edward Littler, Jr., Forrest Schnobrich, Stan Kading, Chris Schafer, Charles Gaffey</Director>
</D>
<CB>
<CorrespondingBankLabel>Correspondent Banks</CorrespondingBankLabel>
<CorrespondingBank>FHLB, Des Moines; MIB, Jefferson City, MO</CorrespondingBank>
</CB>
<OFF>
<OfficeLabel>Office</OfficeLabel>
<Office>Winterset</Office>
</OFF>
</BK>
<BK>
<BankName>Rolling Hills Bank & Trust</BankName>
<Address1>502 Broad Street</Address1>
<Zip>50002</Zip>
<Fax>FAX: (641) 742-3436</Fax>
<Phone>(641) 742-3432</Phone>
<OfficeOfLabel>Office of Rolling Hills Bank & Trust, Atlantic</OfficeOfLabel>
<EH>
<Employee>Mary Beth Petty, VP, BM</Employee>
</EH>
</BK>
</CL>
<CL>
<CityDescription>ADEL, DALLAS CO.</CityDescription>
<Population>POP. 3682</Population>
<BK>
<BankName>Lincoln Savings Bank</BankName>
<BankType>BANKS</BankType>
<Address1>805 Main Street</Address1>
<Zip>50003</Zip>
<Fax>FAX: (515) 253-9502</Fax>
<OfficeOfLabel>Office of Lincoln Savings Bank, Reinbeck</OfficeOfLabel>
</BK>
<BK>
<BankName>Peoples Trust & Savings Bank</BankName>
<Established>Est. 1917</Established>
<RoutingNbr>0739-1921-2</RoutingNbr>
<Address1>804 Greenwood Hills Dr</Address1>
<Hours>Hrs: M-F 9-4 Sat 9-12</Hours>
<Address2>PO Box 98</Address2>
<Zip>50003-0098</Zip>
<Fax>FAX: (515) 993-5681</Fax>
<Phone>(515) 993-5680</Phone>
<Email>e-Mail: info@ptsbank.com</Email>
<WebURL>Web: www.ptsbank.com</WebURL>
<OfficeOfLabel>Office of Peoples Trust & Savings Bank, Clive</OfficeOfLabel>
<EH>
<Employee>Dean W Boettcher, EVP, Mkt Pres</Employee>
</EH>
<EH>
<Employee>Colby Dawes, VP</Employee>
</EH>
<EH>
<Employee>Doran T Ryan, VP</Employee>
</EH>
</BK>
<BK>
<BankName>Raccoon Valley Bank</BankName>
<Established>Est. 1914</Established>
<Address1>1009 Court St</Address1>
<Hours>Hrs: M-F 8-6 SAT 9-12</Hours>
<Zip>50003-1477</Zip>
<Fax>FAX: (515) 993-5127</Fax>
<Phone>(515) 993-4581</Phone>
<Email>e-Mail: roger-platz@raccoonvalleybank.com</Email>
<WebURL>Web: www.raccoonvalleybank.com</WebURL>
<OfficeOfLabel>Office of Raccoon Valley Bank, Perry</OfficeOfLabel>
<EH>
<Employee>Doug Zeigler, VP</Employee>
</EH>
<EH>
<Employee>Joan Barber, AC</Employee>
</EH>
</BK>
<BK>
<BankName>Wells Fargo Bank, N.A.</BankName>
<RoutingNbr>0730-0082-0</RoutingNbr>
<Address1>100 Nile Kinnick Drive</Address1>
<Zip>50003</Zip>
<Fax>FAX: (515) 993-4555</Fax>
<Phone>(515) 993-4551</Phone>
<OfficeOfLabel>Office of Wells Fargo Bank, N.A., Des Moines</OfficeOfLabel>
<EH>
<Employee>Brett A Smith, Dist. Mgr</Employee>
</EH>
</BK>
</CL>
</Story>
</Root>
产生以下结果 - 和元素CityDescription
在Population
同一行:
<Root><Story><CityDescription>ACKLEY, HARDIN CO.</CityDescription> <Population>POP. 1589</Population><BankName>Ackley State Bank</BankName> <Established>Est。1934</Established> <RoutingNbr>0739-0535-2</RoutingNbr> <Address1>650 Main St</Address1> <Hours>Hrs: MF 8-3</Hours> <Address2>PO Box 149</Address2> <邮编>50601-1438</邮编> <电话>(641) 847-2651</电话> <传真>传真:(641) 847-2011</传真> <电子邮件>电子邮件:asbinfo@bankasb.com </Email> <HoldingCo>Holding Co: GNB Bancorporation, Grundy Center</HoldingCo> <TotalAssets>总资产 $128,319,000</TotalAssets> <TotalLiabilities>总负债 $117,059,000< 董事>Doug Hofmeister、Hollis Janssen、Joseph Wojcik、Bob Johanns、Steve McDowell、Kevin Swalley、Mark Sexton、Verlin (Gus) Barker</Director> <CorrespondingBankLabel>Correspondent Banks</CorrespondingBankLabel>:<CorrespondingBank>Bankers Bank, Madison;FHLB,得梅因;四城银行和信托;UMB,堪萨斯城;US Bank, NA, Cedar Rapids</CorrespondingBank> <OfficeLabel>办事处:</OfficeLabel><Office>日内瓦,爱荷华瀑布,故事城</Office> <IBAGroup>IBA 集团:7</IBAGroup> <FDICNbr>FDIC 证书编号:14936</FDICNbr> <BankName>绿带银行和信托</BankName> <RoutingNbr>0739-2167-9</RoutingNbr> <OfficeOfLabel>绿带银行和信托办公室,爱荷华瀑布<
<OfficeOfLabel>威尔斯堡人民储蓄银行办公室</OfficeOfLabel> <Address1>33149 161st St</Address1>
<邮编>50601-7774</邮编> <电话>(641) 847-3126</电话> <传真>传真:(641) 847-2602</Fax> <Employee>Lance Haupt, LO</Employee> < CityDescription>ADAIR, ADAIR CO.</CityDescription> <Population>POP. 781</Population><BankName>Exchange State Bank</BankName> <Established>Est. 1879</Established> <RoutingNbr>0739-0680-1</RoutingNbr> <Address1>322 Audubon</Address1> <Hours>Hrs: M-TH 9-3 F 9-5</Hours> <Address2>邮政信箱98</Address2> <Zip>50002-0098</Zip> <Phone>(641) 742-3201</Phone> <Fax>FAX: (641) 742-3424</Fax> <HoldingCo>Holding Co: Exchange金融公司,阿代尔</HoldingCo> < CorrespondingBankLabel>代理银行</CorrespondingBankLabel>: <CorrespondingBank>FHLB, Des Moines; MIB, Jefferson City, MO</CorrespondingBank> <OfficeLabel>办公室:</OfficeLabel><Office>Winterset</Office> <IBAGroup>IBA 集团:5</IBAGroup> <FDICNbr>FDIC 证书编号:18838</FDICNbr > <BankName>Rolling Hills Bank & Trust</BankName>
<OfficeOfLabel>大西洋 Rolling Hills Bank & Trust 办公室</OfficeOfLabel> <Address1>502 Broad Street</Address1>
<Zip>50002</Zip> <Phone>(641) 742-3432</Phone> <Fax>传真:(641) 742-3436</Fax> <Employee>Mary Beth Petty, VP, BM</Employee> <CityDescription>ADEL, DALLAS CO.</CityDescription> <Population>POP. 3682</Population><BankName>林肯储蓄银行</BankName>
<OfficeOfLabel>林肯储蓄银行办公室,Reinbeck</OfficeOfLabel> <Address1>805 Main Street</Address1> <Zip>50003</Zip> <Fax>传真:(515) 253-9502</Fax> <BankName>人民信托储蓄银行</BankName> <Established>Est。1917</Established> <RoutingNbr>0739-1921-2</RoutingNbr> <OfficeOfLabel>克莱夫人民信托和储蓄银行办公室</OfficeOfLabel> <Address1>804 Greenwood Hills Dr</Address1> <Hours>Hrs: MF 9-4 Sat 9-12</Hours> <Address2>PO Box 98</Address2> <Zip>50003-0098</Zip> <Phone>(515) 993-5680</Phone> <Fax>FAX: ( 515) 993-5681</Fax> <Email>电子邮件:info@ptsbank.com</Email> <Employee>Dean W Boettcher,执行副总裁,Mkt Pres</Employee> <Employee>Colby Dawes,副总裁</Employee> <Employee>Doran T Ryan,副总裁</Employee> <BankName>浣熊谷银行</BankName> <Established>Est。1914</成立>
<OfficeOfLabel>Perry 浣熊谷银行办公室</OfficeOfLabel> <Address1>1009 Court St</Address1> <Hours>Hrs: MF 8-6 SAT 9-12</Hours> <Zip>50003-1477</Zip > <电话>(515) 993-4581</电话> <传真>传真:(515) 993-5127</Fax> <电子邮件>电子邮件:roger-platz@raccoonvalleybank.com</电子邮件> <员工> Doug Zeigler, VP</Employee> <Employee>Joan Barber, AC</Employee> <BankName>Wells Fargo Bank, NA</BankName> <RoutingNbr>0730-0082-0</RoutingNbr> <OfficeOfLabel>富国银行办公室Bank, NA, Des Moines</OfficeOfLabel> <Address1>100 Nile Kinnick Drive</Address1>
<Zip>50003</Zip> <电话>(515) 993-4551</Phone> <Fax>传真:(515) 993-4555</Fax> <Employee>Brett A Smith, Dist. 经理</Employee> </Story></Root>