Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 需要使用XSLT从属性值中删除一些文本_Xml_Xslt_Xslt 2.0 - Fatal编程技术网

Xml 需要使用XSLT从属性值中删除一些文本

Xml 需要使用XSLT从属性值中删除一些文本,xml,xslt,xslt-2.0,Xml,Xslt,Xslt 2.0,我需要使用XSLT从属性值中删除文本的一部分 我使用的XML: <img imageid="47" alt="cup." height="300" width="400" class="right" src="https://tneb.com/Services/Gets/Contents/ucr-images-v1/Images/cup-36" /> 我使用的XSL: <xsl:stylesheet version="2.0" xmlns:xsl="http://

我需要使用XSLT从属性值中删除文本的一部分

我使用的XML:

<img imageid="47" alt="cup." height="300" width="400" class="right" src="https://tneb.com/Services/Gets/Contents/ucr-images-v1/Images/cup-36" />

我使用的XSL:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all">

      <xsl:template match="img">
        <xsl:element name="image">
          <xsl:attribute name="id">
            <xsl:value-of select="@imageid"/>
          </xsl:attribute>
          <xsl:attribute name="alt">
            <xsl:value-of select="@alt"/>
          </xsl:attribute>
          <xsl:attribute name="height">
            <xsl:value-of select="@height"/>
          </xsl:attribute>
          <xsl:attribute name="width">
            <xsl:value-of select="@width"/>
          </xsl:attribute>
          <xsl:attribute name="align">
            <xsl:value-of select="@class"/>
          </xsl:attribute>
          <xsl:attribute name="href">
            <xsl:value-of select="@src"/>
          </xsl:attribute>
        </xsl:element>
      </xsl:template>

 </xsl:stylesheet>

我得到的输出是:

 <image id="47"
 alt="cup."
 height="300"
 width="400"
 align="right"
 href="https://tneb.com/Services/Gets/Contents/ucr-images-v1/Images/cup-36"/>

预期产出必须是:

<image id="47"
 alt="cup."
 height="300"
 width="400"
 align="right"
 href="/ucr-images-v1/Images/cup-36"/>

我需要从图像的属性值中删除一些文本。最后3只表示文件夹结构。所以我只需要它本身


请给我一些建议。提前感谢。

要仅获取路径的最后3个位置步骤,请更改:

<xsl:value-of select="@src"/>

致:


要仅获取路径的最后3个位置步骤,请更改:

<xsl:value-of select="@src"/>

致:



如果您知道需要路径的文件夹名称(如内容),则可以使用类似于
的内容。如果您知道需要路径的文件夹名称(如内容),则可以使用类似于