[英]How do I override a xml value in xslt?
I want to transform xml to another xml with few conditions. 我想以很少的条件将xml转换为另一个xml。 One of condition is whenever my xml element has
DC19DAKHN
or DC19D0000
, in transformed xml I would like to override them with value MN019015J
. 条件之一是每当我的xml元素具有
DC19DAKHN
或DC19D0000
,在转换后的xml中,我想使用值MN019015J
覆盖它们。
How do I do this in XSLT? 如何在XSLT中做到这一点?
My XML Code 我的XML代码
<MyID>DC19DAKHN</MyID>
My xslt output is 我的xslt输出是
<myID>DC19D0000</myID>
I want this to look like this instead 我希望它看起来像这样
<myID>MN019015J</myID>
Do I use If Choose? 我是否使用“如果选择”?
Try this: 尝试这个:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="MyID/text()[.='DC19DAKHN']">MN019015J</xsl:template>
<xsl:template match="myID/text()[.='DC19D0000']">MN019015J</xsl:template>
</xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.