0

正如我之前所说,我已经开始学习 XSLT

当我工作时,我得到了错误类型的 XML 格式

输入

<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig note-ref="no">
<access-panel>113AL</access-panel>
<access-panel>119AL</access-panel>
</testingcongif>

输出

<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
<panel><panelid>113AL</panelid></panel> 
<panel><panelid>119AL</panelid></panel> 
</testingconfig>

我的 XSL

<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
    <xsl:for-each select="testingconfig">
    <panel>
        <panelid>
            <xsl:value-of select="*"/>
        </panelid>
    </panel>
</xsl:for-each>
</testingconfig>

为此输出的是

<testingconfig>
<panel>
    <panelid>
        113AL 119AL
    </panelid>
</panel>
</testingconfig>

任何人都可以帮助我在这里我做错了,请帮助我如何在 XSLT 2.0 中做到这一点

请帮助我

谢谢和问候

4

2 回答 2

7

您只需将其分解为一组转换规则。例如:

<xsl:template match="testingfig">
  <tscon><xsl:value-of select="."/></tscon>
</xsl:template>

<xsl:template match="config">
   <testingvalue>
       <testingtype>mar</testingtype>
       <testid>mar<xsl:value-of select="."/></testid>
   </testingvalue>
</xsl:template>

然而,我有点担心,通过给你这些例子,我会牵着你的手进入沼泽,在那里你会很快陷入困境。在我看来,从你的问题来看,你刚开始学习这门语言是正确的,在论坛上寻求一个简单问题的解决方案并不是最好的学习策略。您无法通过反复试验或复制点头示例来学习编程语言。您需要离开并阅读一些书籍或教程。

于 2012-05-18T08:51:42.333 回答
0
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
    <testingconfig>
        <xsl:for-each select="testingconfig/access-panel">
        <panel><panelid><xsl:value-of select="." /></panelid></panel>

        </xsl:for-each>
    </testingconfig>

</xsl:template>
</xsl:stylesheet>
于 2014-04-08T04:33:17.710 回答