【发布时间】:2021-04-12 03:01:25
【问题描述】:
我正在尝试将数据从 xml 填充到 xslt n 无法做到这一点,因为我不知道 xslt 和 xpath。即使我尽力了我的水平(使用 concat() 方法)但不能。你能帮我做下面的映射吗? :----
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>
试图达到以下目标:--
<DescribedBy>
<value>Yes</value>
<Characteristic>
<name>NH TY1 High Speed Tiers (greater or equal to 2Mbps)</name>
<type>abcd</type>
</Characteristic>
</DescribedBy>
映射条件:---
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"
}
}
这是我迄今为止尝试过的:--
<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>
【问题讨论】:
-
如果您不了解 XSLT 和 XPath,那么您应该了解这些并做一些教程。 “从 XML 到 XSLT”到底是什么意思?在你的代码 sn-p 中这是什么语言?它既不是 Java 也不是 XSLT。请尽量说明您的实际问题是什么。你的问题很混乱。
-
@vanje 使用 concat () 方法尝试了很多,但没有成功。所以寻求帮助
-
是的,你已经提到了。但这并没有让事情变得更清楚。你根本没有回答我的问题。也许你应该阅读How do I ask a good question? 和create a Minimal, Reproducible Example。现在完全不清楚你想要完成什么。
-
@priyranjan 那么请发布您失败的 XSLT 而不是一些难以理解的伪代码!
-
@Gyro Gearless..到目前为止我尝试过的,现在添加。