我正在尝试将数据从xml填充到xslt,但无法做到这一点,因为我不知道xslt和xpath。尽管我尽了最大努力(使用concat()方法),但还是做不到。你能帮我做下面的Map吗----
xml:----(一段代码)
<supportingProductFeatures>
<type>NH</type>
<version>2.0.0</version>
<capacityAvailability>
<featureType>TY1</featureType>
<capacity>2</capacity>
<unitOfMeasure>Mbps</unitOfMeasure>
<highSpeedNotLessThan>true</highSpeedNotLessThan>
</capacityAvailability>
</supportingProductFeatures>
试图达到以下目标one:--
<DescribedBy>
<value>Yes</value>
<Characteristic>
<name>NH TY1 High Speed Tiers (greater or equal to 2Mbps)</name>
<type>abcd</type>
</Characteristic>
</DescribedBy>
条件到map:---
if ((highSpeedNotLessThan!=null))
{
if(highSpeedNotLessThan.equals("true"){
1) set value=yes
2) set name=concat(type +" "+featureType+" "+"High Speed Tiers (greater or equal to
"+capacity+unitOfMeasure+")"
3) set type="abcd"
}
else if(highSpeedNotLessThan.equals("false"){
1)set value=no
2) set name=concat(type +" "+featureType+" "+"High Speed Tiers (greater or equal to
"+capacity+unitOfMeasure+")"
3) set type="abcd"
}
}
这就是我所尝试过的far:--
<DescribedBy>
<xsl:if test="/supportingProductFeatures/capacityAvailability/highSpeedNotLessThan='true'">
<value>yes</value>
</xsl:if>
<xsl:if test="/supportingProductFeatures/capacityAvailability/highSpeedNotLessThan='false'">
<value>No</value>
</xsl:if>
<Characteristic>
<name>
<xsl:value-of select="concat(supportingProductFeatures/type,' ',supportingProductFeatures/capacityAvailability/featureType,' ','High Speed Tiers (greater or equal to ',supportingProductFeatures/capacityAvailability/capacity,supportingProductFeatures/capacityAvailability/unitOfMeasure)" />
</name>
<type>abcd</type>
</Characteristic>
</DescribedBy>
1条答案
按热度按时间oyxsuwqo1#
下面是如何使用xslt实现的。
看到它在这里工作了吗:https://xsltfiddle.liberty-development.net/bejbvrz
请注意,由于输出中的特征和类型对于true和false情况是相同的,所以您可以将它们从when条件中去掉,并将它们用于这两种情况,但我使用与编写伪代码相同的方法。