我有包含多个customItems的XML:
<?xml version="1.0" ?>
<root>
<customItem>
<CustomerName>1Test</CustomerName>
<PONumber>321</PONumber>
<CustomerProofRequired>true</CustomerProofRequired>
<JobType>PVC Banner</JobType>
<ArtworkDescription>TestB2Bconvert4</ArtworkDescription>
<TrimSizeWidthinmm>5000</TrimSizeWidthinmm>
<TrimSizeHeightinmm>6000</TrimSizeHeightinmm>
<ChooseMedia>Bsmart PVC 510g</ChooseMedia>
<BleedRequired?>true</BleedRequired?>
<Replacementartwork?>false</Replacementartwork?>
<MultiItemJob>Yes</MultiItemJob>
<Quantity>1</Quantity>
<SquareMetres>30</SquareMetres>
<Price>120</Price>
</customItem>
<customItem>
<CustomerName>1Test</CustomerName>
<PONumber>321</PONumber>
<CustomerProofRequired>true</CustomerProofRequired>
<JobType>Vinyl Print</JobType>
<ArtworkDescription>TestB2Bconvert3</ArtworkDescription>
<TrimSizeWidthinmm>500</TrimSizeWidthinmm>
<TrimSizeHeightinmm>500</TrimSizeHeightinmm>
<ChooseMedia>Promotional (Budget Short Term Vinyl)</ChooseMedia>
<BleedRequired?>true</BleedRequired?>
<Replacementartwork?>false</Replacementartwork?>
<MultiItemJob>Yes</MultiItemJob>
<Quantity>7</Quantity>
<SquareMetres>0.25</SquareMetres>
<Price>1.75</Price>
</customItem>
</root>
我正在使用此XSLT对其进行转换:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<field-list>
<xsl:for-each select="root/customItem">
<field>
<xsl:value-of select="ArtworkDescription"/>
</field>
</xsl:for-each>
</field-list>
</xsl:template>
但我只在结果中得到第一个值“ArtworkDescription”:
<field-list>
<field>
TestB2Bconvert4
</field>
</field-list>
如果我从输入文件中删除了一些元素:
<?xml version="1.0" ?>
<root>
<customItem>
<CustomerName>1Test</CustomerName>
<PONumber>321</PONumber>
<CustomerProofRequired>true</CustomerProofRequired>
<JobType>PVC Banner</JobType>
<ArtworkDescription>TestB2Bconvert4</ArtworkDescription>
</customItem>
<customItem>
<CustomerName>1Test</CustomerName>
<PONumber>321</PONumber>
<CustomerProofRequired>true</CustomerProofRequired>
<JobType>Vinyl Print</JobType>
<ArtworkDescription>TestB2Bconvert3</ArtworkDescription>
</customItem>
</root>
我得到了我正在寻找的东西:
<field-list>
<field>
TestB2Bconvert4
</field>
<field>
TestB2Bconvert3
</field>
</field-list>
我无法弄清楚原因,有人可以帮助我吗?
答案 0 :(得分:0)
我自己回答了这个问题,因此可以从滚动列表级别帮助其他人。
感谢Martin Honnen,他发现我的输入XML的元素标签中有问号。这些在XML中是不允许的,并且会导致XSLT失败。