Ho fatto un XML e un XSLT veloce di prova:
XML:
codice:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<fw name="ciao">
<eth name="0">
<type name="1">
<rule name="a"/>
</type>
<type name="2">
<rule name="b"/>
</type>
</eth>
</fw>
XSLT:
codice:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template name="type" match="type">
<xsl:choose>
<xsl:when test="@name = 1">
<xsl:call-template name="rule1"></xsl:call-template>
</xsl:when>
<xsl:when test="@name = 2">
<xsl:call-template name="rule2"></xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="rule1" match="rule">
IPTABLES <xsl:value-of select="@name"></xsl:value-of>
</xsl:template>
<xsl:template name="rule2" match="rule">
IPTABLES -t <xsl:value-of select="@name"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
La trasformazione che appare è la seguente:
IPTABLES 1 IPTABLES -t 2
Io invece vorrei che venisse fuori IPTABLES a IPTABLES -t b
Come faccio?