我正在尝试使用我的xslt将导入文件中收到的所有地址拉到我的输出文件中。 我确实设法通过我在xslt中的地址标签之间插入的代码来完成第一组地址 当使用与第一组地址相同的代码时,第二组地址不会通过,因为标签名称被复制。相反,它再次通过第一组地址
请问你能帮助我使用我的xslt填写所有地址来填充输出中的地址吗?
输出中的买方地址正在填充卖方的地址,因为标签名称相同。我试图在xslt中引用买家地址,以便在输出中通过买家,但只有卖家地址通过。很抱歉,但我没有可重现的例子。卖家地址正确使用这行代码 < / strong>但是当我为买家使用同一行代码时,它不起作用,只是将卖家地址拉到买家地址
*****这是导入文件xml *****
<?xml version="1.0" encoding="ISO-8859-1"?>
<UniversalInterchange xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<Body>
<OrgAddressGroup>
<OrgAddress>
<AddressType>Seller</AddressType>
<Address1>16 Far Away Place</Address1>
<Address2>17 Very Far Away Place</Address2>
<CompanyName>Test 123</CompanyName>
<City>Durban</City>
</OrgAddress>
<OrgAddress>
<AddressType>Buyer</AddressType>
<Address1>66 For Far Place</Address1>
<Address2>77 Not So Far Place</Address2>
<CompanyName>Test</CompanyName>
<Fax>+31(0)123456789</Fax>
<OrganizationCode>AAAbbbCCC</OrganizationCode>
<Phone>+31(0)12345678</Phone>
</OrgAddress>
<OrgAddress>
<AddressType>Sending</AddressType>
<Address1>123 Blue Rock Place</Address1>
<Address2>77 Highway Drive</Address2>
<CompanyName>Test</CompanyName>
<Fax>123456789</Fax>
<OrganizationCode>AABBCC</OrganizationCode>
<Phone>123456789</Phone>
</OrgAddress>
</OrgAddressGroup>
</Body>
</UniversalInterchange>
*************这是我的xslt *************
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="vDate" select="xyz"/>
<!-- This line of code and the in the orderDate tage is used to populate the date.These two line work together-->
<xsl:template match ="/">
<UniversalInterchange>
<Body>
<OrgAddressGroup>
<xsl:for-each select="UniversalInterchange/Body/OrgAddressGroup">
<OrgAddress>
<AddressType>Seller</AddressType>
<Address1>
<xsl:value-of select="OrgAddress/Address1"/>
<!-- <xsl:value-of select="UniversalInterchange/Body/OrgAddressGroup/OrgAddress/Address1"/>-->
</Address1>
<Address2>
<xsl:value-of select="OrgAddress/Address2"/>
</Address2>
<CompanyName></CompanyName>
<City></City>
</OrgAddress>
<OrgAddress>
<AddressType>Buyer</AddressType>
<Address1>
<xsl:value-of select="OrgAddress/Address1"/>
</Address1>
<Address2>
<xsl:value-of select="OrgAddress/Address2"/>
</Address2>
<CompanyName></CompanyName>
<Fax></Fax>
<OrganizationCode></OrganizationCode>
<Phone></Phone>
</OrgAddress>
<OrgAddress>
<AddressType>Sending</AddressType>
<Address1></Address1>
<Address2></Address2>
<CompanyName></CompanyName>
<Fax></Fax>
<OrganizationCode></OrganizationCode>
<Phone></Phone>
</OrgAddress>
</xsl:for-each>
</OrgAddressGroup>
</Body>
</UniversalInterchange>
</xsl:template>
</xsl:stylesheet>
***********当前输出***********
<UniversalInterchange>
<Body>
<OrgAddressGroup>
<OrgAddress>
<AddressType>Seller</AddressType>
<Address1>16 Far Away Place</Address1>
<Address2>17 Very Far Away Place</Address2>
<CompanyName/>
<City/>
</OrgAddress>
<OrgAddress>
<AddressType>Buyer</AddressType>
<Address1>16 Far Away Place</Address1>
<Address2>17 Very Far Away Place</Address2>
<CompanyName/>
<Fax/>
<OrganizationCode/>
<Phone/>
</OrgAddress>
<OrgAddress>
<AddressType>Sending</AddressType>
<Address1/>
<Address2/>
<CompanyName/>
<Fax/>
<OrganizationCode/>
<Phone/>
</OrgAddress>
</OrgAddressGroup>
</Body>
</UniversalInterchange>
********必需输出*********
<UniversalInterchange>
<Body>
<OrgAddressGroup>
<OrgAddress>
<AddressType>Seller</AddressType>
<Address1>16 Far Away Place</Address1>
<Address2>17 Very Far Away Place</Address2>
<CompanyName/>
<City/>
</OrgAddress>
<OrgAddress>
<AddressType>Buyer</AddressType>
<Address1>66 For Far Place</Address1>
<Address2>77 Not So Far Place</Address2>
<CompanyName/>
<Fax/>
<OrganizationCode/>
<Phone/>
</OrgAddress>
<OrgAddress>
<AddressType>Sending</AddressType>
<Address1/>123 Blue Rock Place</Address1>
<Address2/>77 Highway Drive</Address2>
<CompanyName/>
<Fax/>
<OrganizationCode/>
<Phone/>
</OrgAddress>
</OrgAddressGroup>
</Body>
</UniversalInterchange>
答案 0 :(得分:0)
在XSLT 1.0中。 (您显然正在使用),xsl:value-of
返回所选节点集的第一个节点的值。
如果您要处理所有OrgAddress
元素,请将xsl:for-each
指令选为OrgAddress
而不是其父OrganizationAddressGroup
。