XSLT 1.0值映射 [英] XSLT 1.0 Value map

查看:116
本文介绍了XSLT 1.0值映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


在我的XSLT中,我必须替换对应于预定值的节点值,如下所示:


if节点值为CF,如果节点值为FT,则输出节点值为CE

,如果节点值为MO,则输出节点值为TX,
,则输出节点价值是  NM


等...


我关注了一些博客文章或论坛帖子,但它仍无效:


我在样式表的顶部添加了maping表

< xsl:stylesheet xmlns:xsl =" http://www.w3.org/1999/XSL/Transform"的xmlns:msxsl = QUOT;瓮:架构 - 微软-COM:XSLT"的xmlns:purk = QUOT; HTTP://obx2mapping.data" ...> 

< purk:obx2_map>
< entry key =" CE"> CE< / entry>
< entry key =" CF"> CE< / entry>
< entry key =" DT"> DT< / entry>
< entry key =" FT"> TX< / entry>
< entry key =" MO"> NM< / entry>
< entry key =" ST"> ST< / entry>
< entry key =" NM"> NM< / entry>
< entry key =" SN"> ST< / entry>
< entry key =" TX"> TX< / entry>
< entry key =" TM"> DT< / entry>
< entry key =" TS"> DT< / entry>
< / purk:obx2_map>

在节点内部,我把它放在:

< xsl:variable name =" obx2_sider"选择= QUOT; OBX_2_ValueType /文本()" /> 
< OBX_2_ValueType>< xsl:value-of select =" document('')/ * / purk:obx2_map / entry [@key ='$ obx2_sider']" />< / OBX_2_ValueType> ;

输出无效...


我能够在输出中显示带有此< xsl的变量内容: value-of select =" $ obx2_sider" />。


我的语法有问题吗?


谢谢





解决方案

不要在变量引用周围使用引号,而不是


  < xsl:value-of select =" document('')/ * / purk:obx2_map / entry [@key ='


obx2_sider']" />


使用


  < xsl:value-of select =" document('')/ * / purk:obx2_map / entry [@key =


obx2_sider]" />


Hello,

In my XSLT I have to replace a node value corresponding to a predifined value like this :

if node value is CF, then output node value is CE
if node value is FT, then output node value is TX
if node value is MO, then output node value is NM

etc ...

I have followed some blog post or forum posts, but it's still not working :

I have added the maping table at the top of my stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:purk="http://obx2mapping.data" ... >

  <purk:obx2_map>
	 <entry key="CE">CE</entry>
	 <entry key="CF">CE</entry>
	 <entry key="DT">DT</entry>
	 <entry key="FT">TX</entry>
	 <entry key="MO">NM</entry>
	 <entry key="ST">ST</entry>
	 <entry key="NM">NM</entry>
	 <entry key="SN">ST</entry>
	 <entry key="TX">TX</entry>
	 <entry key="TM">DT</entry>
	 <entry key="TS">DT</entry>
  </purk:obx2_map>

And inside the node, I put this :

<xsl:variable name="obx2_sider" select="OBX_2_ValueType/text()" />
<OBX_2_ValueType><xsl:value-of select="document('')/*/purk:obx2_map/entry[@key='$obx2_sider']"/></OBX_2_ValueType>

The output is nothing ...

I am able to display in the output the variable content with this <xsl:value-of select="$obx2_sider"/>.

Is there something wrong in my syntax ?

Thanks


解决方案

Don't use quotes around the variable reference i.e. instead of

  <xsl:value-of select="document('')/*/purk:obx2_map/entry[@key='


obx2_sider']"/>

use

  <xsl:value-of select="document('')/*/purk:obx2_map/entry[@key =


obx2_sider]"/>


这篇关于XSLT 1.0值映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆