AddExtensionObject遍布我的XML

时间:2011-11-08 12:40:10

标签: .net xml xslt

我正在使用XSLT来实现它的目的,即将1 xml表单映射到另一个。

由于M $缺乏对2.0的支持以及随附的所有可爱功能(无人比较任何人?我希望有人因为离开1.0而失去了工作)以及更多我希望使用AddExtensionObject来添加一些函数来添加我需要的支持。我相信这比允许运行脚本要安全得多。

令人烦恼的是,在我的所有标签上抹灰。例如。

<INVAC xmlns:myColor="urn:myColor">
<MEMBO>7131</MEMBO>
<FUNDNAME>Fund00b</FUNDNAME>
</INVAC>

当我遵循http://www.15seconds.com/issue/031112.htm

的修改版本时

我想使用额外的功能,但没有输出.......

提前感谢!

1 个答案:

答案 0 :(得分:1)

您已找到主要问题的答案 - exclude-result-prefixes的{​​{1}}属性应该用于指定我们不希望的所有名称空间前缀(以空格分隔的列表)要复制在文字结果元素上。

您的其他问题也很容易回答:

  

无案例比较任何人?

使用

xsl:stylesheet

这恰好评估 translate($s1, $vUpper, $vLower) = translate($s2, $vUpper, $vLower) 两个字符串true()$s1 ara不区分大小写的情况。

变量$s2应包含字母表中的所有大写字母,变量$vUpper应包含字母表的所有低位字母。

以下是完整示例

$vLower

应用于此XML文档时

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:param name="pNameOfElementsToDelete" select="'DeLetE'"/>

 <xsl:variable name="vUpper" select=
 "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>

 <xsl:variable name="vLower" select=
 "'abcdefghijklmnopqrstuvwxyz'"/>

 <xsl:template match="node()|@*" name="identity">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>

 <xsl:template match="*[true()]">
  <xsl:if test=
  "not(
   translate(name(), $vUpper, $vLower)
  =
   translate($pNameOfElementsToDelete, $vUpper, $vLower)
   )
 ">
   <xsl:call-template name="identity"/>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

此转换生成一个新的XML文档,其中任何元素的名称与<a> <b> <Delete/> </b> <dell/> <c> <deLete/> </c> </a> 不区分大小写:

"DeLetE"