有没有一种方法可以将XML标签的值存储在标签属性中

时间:2019-06-13 08:23:40

标签: xslt

im试图制作一个将XML文档转换为另一个XML文档并应用一些过滤器的xslt样式表。我有一个特殊的问题,我试图访问存储在标签(Name_BLANK_of_BLANK_programmer)内的值,并且希望将其存储到标签属性(Testplan name =“ HERE COMES THE VALUE”)中。

我要转换此=

<Testplan>
<Name_BLANK_of_BLANK_programmer>136 - MEL 1 S -  24 DC</Name_BLANK_of_BLANK_programmer>
<BlackboxType>0</BlackboxType>
<ShowTestStepGrafics>0</ShowTestStepGrafics>

进入此=

<Testplan number="136 - MEL 1 S -  24 DC">
<Instruction>3500</Instruction>
<Steps>

1 个答案:

答案 0 :(得分:0)

您没有上传适当的输入和期望的输出,因此我假设并建议您可以这样做,请参见link

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="xml" indent="yes"/>

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

    <xsl:template match="Testplan">
        <Testplan number="{Name_BLANK_of_BLANK_programmer}">
            <xsl:apply-templates select="node() except Name_BLANK_of_BLANK_programmer"/>
        </Testplan>
    </xsl:template>


</xsl:stylesheet>