0

我正在尝试创建企业目录。生成的 XML 需要使用 XSLT 进行一些工作。我创建了以下 XSLT 来插入必要的样板文件,并根据需要将数据标签和元素组合/显示在一起。

下面的 XSLT 几乎完成了我想要的一切,但它正在做一些我不想要的事情,当我希望它们在同一行时,它会将一些元素放在不同的行上。例如,元素<CorrespondingBankLabel>应该在同一行<CorrespondingBank>

我确信答案很简单,但我一直无法弄清楚。

这是完整的 XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:strip-space elements="*"/>

<xsl:output method="html" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Document</title>
</head>
<body><xsl:apply-templates select="Root/Story/CL"/></body>
</html>
</xsl:template>

<xsl:template match="CityDescription">
<xsl:text>
</xsl:text><CityDescription><xsl:value-of select="."/></CityDescription><xsl:text>  </xsl:text>
</xsl:template>
<xsl:template match="Population">
<Population><xsl:value-of select="."/></Population><xsl:text>
</xsl:text>
</xsl:template>


<xsl:template match="BankName | Address1 | Hours | Established | RoutingNbr | Zip | Fax | Phone | Email | Employee | IBAGroup | FDICNbr | OfficeOfLabel | CO/CityOfficeLabel | CO/CityOfficeAddress1 | CO/CityOfficeZip | CO/CityOfficePhone | CO/CityOfficeAddress2 ">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>

<xsl:template match="BK"><xsl:text>
</xsl:text><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:text> </xsl:text><xsl:apply-templates select="Fax"/>
<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:text> </xsl:text><xsl:apply-templates select="EquityCapital"/><xsl:text>
</xsl:text><xsl:apply-templates select="EH/Employee"/><xsl:text>
</xsl:text><xsl:apply-templates select="IBAGroup"/><xsl:apply-templates select="FDICNbr"/><xsl:text>
</xsl:text><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:template>

<xsl:template match="HoldingCo">
 <HoldingCo>
  <xsl:text>Holding Co: </xsl:text>
  <xsl:value-of select="."/>
 </HoldingCo>
</xsl:template>

<xsl:template match="Address2">
<Address2><xsl:value-of select="."/></Address2><xsl:text>   </xsl:text>
</xsl:template>

<xsl:template match="Email">
 <Email>
  <xsl:text>e-Mail: </xsl:text>
  <xsl:value-of select="."/>
 </Email>
</xsl:template>

<xsl:template match="Web">
 <Web>
  <xsl:text>Web: </xsl:text>
  <xsl:value-of select="."/>
 </Web>
</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: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: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:template>
<xsl:template match="OFF"><OfficeLabel><xsl:value-of select="OfficeLabel"/><xsl:text>: </xsl:text> </OfficeLabel><Office><xsl:value-of select="Office"/></Office></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:template> 

<xsl:template match="CB"><CorrespondingBankLabel><xsl:value-of select="CorrespondingBankLabel"/><xsl:text>: </xsl:text></CorrespondingBankLabel><CorrespondingBank><xsl:value-of select="CorrespondingBank"/></CorrespondingBank></xsl:template> 
</xsl:stylesheet>

这是一些示例 XML:

<?xml version="1.0" encoding="UTF-8"?>
<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 &amp; 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 &amp; 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 &amp; 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 &amp; 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 &amp; 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 &amp; 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 &amp; 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>
4

0 回答 0