小编Eer*_*ius的帖子

使用XSLT修改XML文档的属性

我有一个XML文件,它具有@url该元素的属性<matimage>.目前,@url属性中有一个特定的图像名称triangle.png.我想应用XSLT并修改此URL,以便类似assets/images/triangle.png.

我尝试了以下XSLT:

<?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" />

  <!-- Copy everything -->
  <xsl:template match="*">
    <xsl:copy>
     <xsl:copy-of select="@*" />
     <xsl:apply-templates />
   </xsl:copy>
  </xsl:template>

 <xsl:template match="@type[parent::matimage]">
   <xsl:attribute name="uri">
     <xsl:value-of select="NEW_VALUE"/>
   </xsl:attribute>
 </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

作为第一步,我尝试用新值替换旧值,但这似乎不起作用.请告诉我如何在@url属性的现有值之前添加或附加新值.

以下是XML示例:

   <material>
    <matimage url="triangle.png">
        Some text
    </matimage>
  </material>
Run Code Online (Sandbox Code Playgroud)

期望的输出:

   <material>
    <matimage url="assets/images/triangle.png">
        Some text
    </matimage>
  </material>
Run Code Online (Sandbox Code Playgroud)

xml xslt

2
推荐指数
1
解决办法
162
查看次数

继承只有私有构造函数的C#类

我想CompareConstraint在我的F#代码中继承XMLUnit.NET 类.

但是,该类只有一个私有构造函数.如果我尝试继承它,我得到这个编译错误:

This 'inherit' declaration specifies the inherited type but no arguments. Consider supplying arguments, e.g. 'inherit BaseType(args)'.

在F#中有没有办法继承没有公共构造函数的类?

f# xmlunit-2

2
推荐指数
1
解决办法
543
查看次数

标签 统计

f# ×1

xml ×1

xmlunit-2 ×1

xslt ×1