更新:谢谢你的回答!两个快速的后续问题:我希望能够看到每个项目。我写的代码
<xsl:for-each select="item/totalCharges">
<checkouts><xsl:value-of select="totalCharges"/>
</checkouts> </xsl:for-each>
没有工作。是否有捷径可寻?第二,我怎样才能更新到具体到达?
如果这是一个非常低级别的问题,我提前道歉,但我根本不是程序员,并且已经达到了解决此问题的能力的最终结果。我正在尝试使用以下XLS样式表
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<record>
<xsl:for-each select="catalog">
<itemline>
<title><xsl:value-of select="marc/marcEntry"/></title>
<callNumber><xsl:value-of select="call/callNumber"/></callNumber>
<yearOfPublication><xsl:value-of select="catalog/yearOfPublication"/></yearOfPublication>
<xsl:for-each select="item/totalCharges">
<xsl:value-of select="totalCharges"/>
</xsl:for-each>
</itemline>
</xsl:for-each>
</record>
</xsl:template>
</xsl:stylesheet>
来自我图书馆系统的XML报告。以下是XML
的示例<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sirsi.xsl"?>
<report>
<title>List of Items with Specified Entries</title>
<dateCreated>2017-03-03T12:00:21</dateCreated>
<dateFormat>mm/dd/yyyy</dateFormat>
<catalog>
<flexibleKey>111802</flexibleKey>
<numberOfTitleHolds>0</numberOfTitleHolds>
<totalHolds>0</totalHolds>
<numberOfCallNumbers>1</numberOfCallNumbers>
<bibliographicLevel>FULL</bibliographicLevel>
<catalogFormat>MARC</catalogFormat>
<createdBy>BATCH</createdBy>
<dateCreated>2000-02-17</dateCreated>
<dateCataloged></dateCataloged>
<modifiedBy>BATCH</modifiedBy>
<dateModified>2009-01-08</dateModified>
<catalogKey>95465</catalogKey>
<marc>
<marcEntry tag="245" label="Title" ind="10">Si rosa yan si ana</marcEntry>
</marc>
<call>
<callNumber>XX(95465.1)</callNumber>
<library>UOG-RFK</library>
<item>
<numberOfCharges>0</numberOfCharges>
<numberOfBills>0</numberOfBills>
<numberOfCopyHolds>0</numberOfCopyHolds>
<totalCharges>5</totalCharges>
<inhouseCharges>0</inhouseCharges>
<totalCheckouts>0</totalCheckouts>
<totalRenewals>0</totalRenewals>
<intervalCheckouts>0</intervalCheckouts>
<intervalRenewals>0</intervalRenewals>
<intervalStartDate></intervalStartDate>
<recirculate>YES</recirculate>
<dateLastUsed>2000-04-20</dateLastUsed>
<isReserveItem>false</isReserveItem>
<copyNumber>1</copyNumber>
<itemID>33296001077192</itemID>
<library>UOG-RFK</library>
<libraryDescription>University of Guam - RFK Memorial Library</libraryDescription>
<location>JUVENILE</location>
<homeLocation>JUVENILE</homeLocation>
<price currency="$" >0.00</price>
<type>JUVENILE</type>
<numberOfPieces>1</numberOfPieces>
<dateCreated>2000-02-17</dateCreated>
<isPermanent>true</isPermanent>
</item>
</call>
</catalog>
<catalog>
<flexibleKey>o21002169</flexibleKey>
<numberOfTitleHolds>0</numberOfTitleHolds>
<totalHolds>0</totalHolds>
<numberOfCallNumbers>1</numberOfCallNumbers>
<bibliographicLevel>FULL</bibliographicLevel>
<catalogFormat>MARC</catalogFormat>
<createdBy>TECH</createdBy>
<dateCreated>2010-07-20</dateCreated>
<dateCataloged>2010-07-20</dateCataloged>
<modifiedBy>SYSADMIN</modifiedBy>
<dateModified>2010-07-21</dateModified>
<catalogKey>138981</catalogKey>
<yearOfPublication>1984</yearOfPublication>
<marc>
<marcEntry tag="100" label="Personal Author" ind="1 ">Treviño, Elizabeth Borton de, 1904-</marcEntry>
<marcEntry tag="245" label="Title" ind="10">I, Juan de Pareja / Elizabeth Borton de Treviño.</marcEntry>
<marcEntry tag="250" label="Edition" ind=" ">Sunburst ed.</marcEntry>
<marcEntry tag="260" label="Publication info" ind=" ">New York, NY : Farrar, Straus & Giroux, 1984 (1991 printing)</marcEntry>
<marcEntry tag="300" label="Physical description" ind=" ">xii, 180 p ; 21 cm.</marcEntry>
<marcEntry tag="500" label="General Note" ind=" ">"A Sunburst book."</marcEntry>
<marcEntry tag="500" label="General Note" ind=" ">"A Newbery Medal book"--Cover.</marcEntry>
<marcEntry tag="520" label="Summary" ind=" ">Offers a fictionalized account of the life of Juan de Pareja, a young slave who grew to become an assistant to the painter Velasquez.</marcEntry>
<marcEntry tag="600" label="Personal subject" ind="11">Pareja, Juan de, 1606-1670--Fiction.</marcEntry>
<marcEntry tag="600" label="Personal subject" ind="11">Velʹazquez, Diego, 1599-1660--Fiction.</marcEntry>
<marcEntry tag="600" label="Personal subject" ind="10">Pareja, Juan de, 1606-1670--Juvenile fiction.</marcEntry>
<marcEntry tag="600" label="Personal subject" ind="10">Velázquez, Diego, 1599-1660--Juvenile fiction.</marcEntry>
<marcEntry tag="650" label="Subject term" ind=" 1">Artists--Spain--Fiction.</marcEntry>
</marc>
<call>
<callNumber>PZ 7.T732 I 1984</callNumber>
<library>UOG-RFK</library>
<item>
<numberOfCharges>0</numberOfCharges>
<numberOfBills>0</numberOfBills>
<numberOfCopyHolds>0</numberOfCopyHolds>
<totalCharges>0</totalCharges>
<inhouseCharges>0</inhouseCharges>
<totalCheckouts>0</totalCheckouts>
<totalRenewals>0</totalRenewals>
<intervalCheckouts>0</intervalCheckouts>
<intervalRenewals>0</intervalRenewals>
<intervalStartDate></intervalStartDate>
<recirculate>YES</recirculate>
<dateLastUsed></dateLastUsed>
<isReserveItem>false</isReserveItem>
<copyNumber>1</copyNumber>
<itemID>33296001438444</itemID>
<library>UOG-RFK</library>
<libraryDescription>University of Guam - RFK Memorial Library</libraryDescription>
<location>JUVENILE</location>
<homeLocation>JUVENILE</homeLocation>
<price currency="$" >25.00</price>
<category1>JUVENILE</category1>
<type>JUVENILE</type>
<numberOfPieces>1</numberOfPieces>
<dateCreated>2010-07-20</dateCreated>
<isPermanent>true</isPermanent>
</item>
</call>
我只想为每个具有标题,电话号码,发布日期和结帐数量的项目获取一行。但是,当我使用样式表打开XML报表时,它返回一个空的工作簿。我再次道歉,如果我错过了一些简单的事情,但我近15年来没有做过任何编码。
答案 0 :(得分:0)
您可以使用:
<xsl:for-each select="//catalog">
而不是
<xsl:for-each select="catalog">
对于您在评论中的附加问题,您可以使用此xslt:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<record>
<xsl:for-each select="//catalog">
<itemline>
<title><xsl:value-of select="marc/marcEntry[@label='Title']"/></title>
<callNumber><xsl:value-of select="call/callNumber"/></callNumber>
<yearOfPublication><xsl:value-of select="yearOfPublication"/></yearOfPublication>
<xsl:for-each select="call/item/totalCharges">
<xsl:copy-of select="."/>
</xsl:for-each>
</itemline>
</xsl:for-each>
</record>
</xsl:template>
</xsl:stylesheet>